What Is a Chatbot API? How It Works, With Code
A chatbot API is a web endpoint that takes a list of messages and returns the next message from a language model. Here is how that works, what the parts mean and how to make your first call.

Key points
- You send a list of role-tagged messages over HTTPS and get the model's reply back as JSON or as a stream.
- The API is stateless: you resend the history on every call, which is why context window size and token price both matter.
- Tool calling lets the model request actions from your code, and JSON mode makes the output machine-readable.
- A 10-turn chat with a 500-token system message uses about 19,500 input tokens in total, roughly $0.004.
The short answer
So, what is chatbot api in plain terms? It is a doorway to a language model. You do not run the model yourself. You send an HTTP request that contains a conversation, and the server sends back what the assistant would say next. The chat window you know from a website is just a front end that makes this request every time you press enter.
Most chatbot APIs today follow the shape OpenAI popularised: a POST to /v1/chat/completions with a JSON body holding a model name and a list of messages. Because so many tools copied that shape, a client written for one provider often works for another after you change two values, the base URL and the key. That is what OpenAI-compatible means, and it is how the service on this site works. Its base URL is https://api.uncensoredstory.cc/v1 and its model ID is uncensored.
Anatomy of a request
A request has four parts that matter at the start.
- Authentication. A header,
Authorization: Bearer <key>. The key identifies your account and your balance. - Model. A string that picks which model answers. Here it is
uncensored. - Messages. An array of objects, each with a
roleandcontent. - Settings. Optional values such as
temperature,max_tokens,stopandseed.
There are three common roles. system holds standing instructions: who the assistant is, what tone to use, what to avoid. user is what the person typed. assistant is what the model said earlier. A fourth role, tool, carries results from functions you ran for the model, which we get to below.
Here is the smallest working call.
curl https://api.uncensoredstory.cc/v1/chat/completions -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d '{
"model": "uncensored",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Explain DNS in two sentences."}
]
}'
The reply is a JSON object. The text lives at choices[0].message.content, and a usage block says how many tokens went in and out. The response headers add X-Request-Id for tracing and X-Balance-USD for the credit you have left.
Why the API forgets everything
The first surprise for new developers is that a chatbot API has no memory. Each request stands alone. If you ask "what is my name?" after telling it your name in a previous call, it will not know, unless you include that earlier exchange in the new request.
So your application keeps the conversation and sends it all back every time. A tiny chat loop in Python looks like this:
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredstory.cc/v1", api_key="YOUR_KEY")
messages = [{"role": "system", "content": "You are a helpful assistant."}]
while True:
text = input("you: ")
messages.append({"role": "user", "content": text})
resp = client.chat.completions.create(model="uncensored", messages=messages)
answer = resp.choices[0].message.content
messages.append({"role": "assistant", "content": answer})
print("bot:", answer)
The list grows with every turn. That has two consequences, and they are the heart of how chatbot APIs behave in production: the request gets bigger, and the price goes up with it.
Context window and tokens
Models read text in tokens, which are chunks of a word. Short English words are often one token, and longer or unusual words split into several. The context window is the maximum number of tokens the model can handle in one request, counting the prompt and the reply together. For this API it is 100,000 tokens. Reaching it is rare in casual chat, but long documents, large system prompts and story-length histories can get there.
When a conversation outgrows the window, you must cut something. The usual options are to drop the oldest turns, or to ask the model to summarise them into a short note and keep the note. The request body is also capped at 8 MB, which only matters if you paste very large inputs.
Because the history is resent, the cost of a chat grows faster than its length. Take a chat with a 500-token system message where each turn adds 100 tokens from the user and 200 from the assistant. Over 10 turns:
- Input at turn n is 500 + (n - 1) x 300 + 100 tokens, so turn 1 sends 600 and turn 10 sends 3,300.
- Total input across all 10 turns: 10 x 600 + 300 x (0 + 1 + ... + 9) = 6,000 + 13,500 = 19,500 tokens.
- Total output: 10 x 200 = 2,000 tokens.
At $0.15 per 1M input tokens that is 19,500 x $0.15 / 1,000,000 = $0.002925. At $0.50 per 1M output tokens it is 2,000 x $0.50 / 1,000,000 = $0.001. The whole chat costs $0.003925, about four tenths of a cent. Failed or refused requests are not charged.
Streaming, JSON and tools
Three features turn a plain question-and-answer endpoint into something you can build products on.
Streaming
With stream: true the server sends the answer as it is generated, as server-sent events, and reports token usage at the end. Users see words appear immediately instead of waiting for the full reply. The catch is that a streamed request holds one of your concurrency slots until it finishes.
JSON mode
Set response_format to {"type": "json_object"} and tell the model what shape you want. You get a parseable object, which suits classification, extraction and any case where code, not a person, reads the answer.
Tool calling
You describe functions in a tools array. The model can answer with a tool_calls entry that names a function and its arguments. Your code runs the function, adds the result as a message with role: "tool", and calls the API again so the model can use it. This is how a chatbot checks an order status, queries a database or does arithmetic correctly. The model never runs code itself. It only asks.
Limits, errors and keys
Every API has limits, and a production chatbot must handle them. A full key here allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 and 60. When you exceed a limit the API returns HTTP 429 with the error code rate_limited (too many requests per minute) or concurrency (too many at once). Under temporary overload it also returns 429 with a Retry-After: 5 header. The right response is to wait and retry, ideally with a short delay that grows on repeated failures.
# client = OpenAI(base_url="https://api.uncensoredstory.cc/v1", api_key="YOUR_KEY")
import time
def ask(messages, tries=4):
for i in range(tries):
try:
return client.chat.completions.create(model="uncensored", messages=messages)
except Exception as e:
if getattr(e, "status_code", None) == 429 and i < tries - 1:
time.sleep(5 * (i + 1))
continue
raise
Keep the key on a server. Anyone who can read it can spend your balance, so never ship it inside a mobile app or browser script. Prompts sent to this service are not used for training.
Picking a provider and getting started
When you compare chatbot APIs, look at five things: which models are offered, how the price is stated and billed, the context window, the rate limits, and what the content policy allows. A general-purpose assistant API usually refuses some topics. This one serves 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 big vendor and it only handles text, so there is no image, audio or embedding support and no fine-tuning. Check other providers' current pricing yourself before comparing.
Billing is prepaid credit with no subscription, $0.15 per 1M input tokens and $0.50 per 1M output tokens. Top-ups run from $20 to $500, with +5% from $50, +10% from $100 and +15% from $200, paid by crypto (USDT on TRC20, USDC on Base). New users can claim $0.50 of trial credit with one click on the API key page, valid for 7 days, no payment needed. The quickstart has the same calls in more languages, the pricing page has the full numbers, and the pay-per-token checklist helps you judge any provider before you commit.
More guides
Questions and answers
Is a chatbot API the same as a chatbot?
No. The API is the model endpoint. A chatbot is an application that uses it, adding a chat interface, memory, rules and sometimes tools.
Do I need to know machine learning to use one?
No. If you can send an HTTP request or use a client library, you can use it. The model is hosted for you.
Can I use the OpenAI SDK with a different provider?
Yes, when the provider is OpenAI-compatible. Change the base URL and the key, and set the model name the provider gives you.
How is a chatbot API billed?
By tokens, counted separately for input and output. Here that is $0.15 per 1M input and $0.50 per 1M output tokens, from prepaid credit.
Why do I get a 429 error?
You hit a rate or concurrency limit, or the service is briefly overloaded. Wait a few seconds and try again.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.