What Is an API in Artificial Intelligence?
People who search "what is api in artificial intelligence" usually want a plain answer: an API is a way for your own program to send a request to an AI model running on someone else's computer, and get the result back. This page explains the pieces and ends with a short working example.

Last updated
Key details
- An API (application programming interface) is a defined way for two programs to talk to each other.
- A text AI API takes a list of messages in and returns generated text, measured and billed in tokens.
- A key identifies you, and prepaid credit pays for the tokens you use.
- With an OpenAI-compatible API, the same few lines of code work with many tools.
The short answer
API stands for application programming interface. It is a menu of requests that one program is allowed to send to another, together with the shape of the answer. A weather service has an API: you send a city, and you get a forecast. A payment service has one: you send an amount, and you get a receipt.
In artificial intelligence, the service on the other end is a trained model. Instead of a city, you send text, such as a question or the first half of a story. The model returns text. You never download the model, and you never need a powerful computer. All the heavy computation happens on the provider's servers, and your program only sends and receives small messages over the internet.
That is why so many apps can add AI features quickly: a chatbot, a summary button, a story generator and a support assistant can all be a few lines of code around one API call.
What happens in one request
When your code calls a text AI API, five things happen.
- Your program builds a request. It includes the address of the API, your key, the name of the model and a list of messages.
- The request travels over HTTPS. The standard format is JSON, a simple way of writing structured text.
- The provider checks your key and balance. If both are fine, the request goes to the model.
- The model generates text. It does this one small piece at a time, called a token.
- The answer returns as JSON. It contains the generated text and a count of the tokens used.
You can also ask for streaming. The provider then sends the text in pieces as it is produced, which is how chat windows show words appearing one after another.
Messages, roles and the model name
The central part of a request is the list of messages. Each message has a role and some content.
system: instructions about how the model should behave, such as its tone.user: what the person asks or writes.assistant: earlier answers from the model.
The model does not remember past requests by itself. For a conversation, your program sends the whole list again, with the new message at the end. That is also why long chats cost more over time: each request carries more history.
The request also names a model. On this service the name is uncensored, a single open-weight model run by an independent provider and tuned to answer without content refusals for lawful adult use. It is not the official API of any model vendor.
Tokens, in plain words
Models do not read letters or words. They read tokens, which are pieces of text, often a short word or part of a longer one. A rough rule for English is that 1,000 tokens equal about 750 words. Tokens matter for three reasons:
- Limit. The context window is the most tokens a request can hold, prompt and answer together. Here it is 100,000 tokens.
- Cost. Providers bill per token. The price here is $0.15 per 1M input tokens and $0.50 per 1M output tokens.
- Speed. More output tokens take longer to generate.
As an example, a question of 100 tokens that gets an answer of 300 tokens costs 100 × $0.15 / 1,000,000 = $0.000015 for input and 300 × $0.50 / 1,000,000 = $0.00015 for output. The total is $0.000165, which is a small fraction of a cent. You would need about 6,000 such exchanges to spend one dollar.
Keys and credit
An API key is a long secret string that tells the provider who is calling. You send it in a header: Authorization: Bearer YOUR_KEY. Anyone with the key can spend your credit, so keep it out of public code.
On this service you sign up with Google or with email and password, then get a key on the API key page. New users can claim $0.50 of trial credit with one click. It needs no card, lasts 7 days, and is one per person. After that you pay as you go from prepaid credit: any whole amount from $20 to $500, in crypto (USDT on TRC20 or USDC on Base), with no subscription. Full details are on the pricing page.
A short working example
Here is a complete call in Python, using the official openai package. The service is OpenAI-compatible, so you only change the base URL and key:
from openai import OpenAI
client = OpenAI(api_key="YOUR_KEY", base_url="https://api.uncensoredartificialintelligence.com/v1")
reply = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Explain an API in one sentence."}],
)
print(reply.choices[0].message.content)Replace YOUR_KEY with your key. The program sends one message and prints the answer. The same request with curl looks like this:
curl https://api.uncensoredartificialintelligence.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Explain an API in one sentence."}]
}'The response is JSON like the sample below. The text of the answer is in choices[0].message.content, and the usage block shows the tokens counted for billing:
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "uncensored",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "An API is a set of rules that lets one program ask another program to do something."
},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 14, "completion_tokens": 21, "total_tokens": 35}
}The exact id and wording will differ. If something fails, check the key, the base URL (it ends in /v1) and the model id. The documentation covers streaming, JSON mode and tool calling.
A few terms you will meet
Documentation for AI APIs uses some words that are easy to skim past.
- Endpoint: a specific URL for one kind of request, such as
/v1/chat/completions. - Base URL: the shared start of those addresses. Tools ask for this one.
- Prompt: the text you send. The completion is the text that comes back.
- Temperature: a setting for how varied the answer is. Low values are steady, high values are more creative.
- Rate limit: the number of requests allowed in a period. Going over it returns HTTP 429.
- Streaming: receiving the answer in small pieces instead of waiting for the whole thing.
Once these are familiar, most provider documentation reads easily.
What an AI API cannot do
A text API is a specialised tool. This one is text only: it does not create images, audio or video, it does not produce embeddings and it does not offer fine-tuning. The model can be wrong or invent facts, so important answers should be checked. And each key has limits: a full key allows 8 concurrent requests and 300 requests per minute, a trial key 2 and 60. If you go over, you get HTTP 429 and can retry after a pause.
Sexual content involving minors is never allowed, and prompts are not used for training. If you want to understand how models without content refusals fit in, read Uncensored AI: Myths vs. Facts.
More guides
Common questions
Is an API the same as an AI model?
No. The model is the trained system that generates text. The API is the doorway your program uses to send it requests and read its answers.
Do I need to know how to code to use one?
Basic scripting helps, but many ready-made apps let you paste a base URL, a key and a model name. Then no code is needed.
What is a token?
A token is a small piece of text, often a short word or part of a word. Limits and prices are measured in tokens; 1,000 tokens are about 750 English words.
Is it safe to put my key in a web page?
No. Anyone can read it and spend your credit. Keep it on a server and let the page call your server.