What free actually means for a chatbot API
If you search for an api for chatbot free, you usually want one of two things: a way to prototype without paying anything, or a way to run a small bot so cheaply that the bill is a rounding error. This service covers both, with one honest caveat. It is not a free tier that renews every month. It is prepaid credit with a trial on top.
The trial works like this. After you sign up with Google, or with email and password, the API key page shows a button that claims $0.50 of trial credit. It is one per person, valid for 7 days, and needs no card. The trial key runs at 2 concurrent requests and 60 requests per minute, which is plenty for building and testing a bot by yourself.
The model behind the endpoint is a single open-weight model, uncensored, run by an independent provider and tuned to answer without content refusals for lawful adult use. It is text only. If your chatbot needs images, voice or embeddings, this is not the right backend for those parts. The hard limit is that sexual content involving minors is never allowed.
That matters for hobby bots. A Discord helper, a tabletop game master or a companion character for adults can answer without the model stopping to refuse an ordinary request, and the cost stays low enough that you can leave it running while you decide whether anyone uses it.
The rest of this article puts numbers on the trial, shows a working chatbot, and covers the two features that make a bot useful beyond plain chat: JSON mode and tool calling.
The cost of one chatbot turn
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. You pay for what you use, and failed or refused requests are not charged. Here is a plain chatbot turn worked out exactly.
Say a turn sends 2,000 tokens in (system prompt, recent history and the new message) and gets 300 tokens back.
- Input: 2,000 / 1,000,000 x $0.15 = $0.0003
- Output: 300 / 1,000,000 x $0.50 = $0.00015
- Total: $0.00045 per turn
A thousand such turns cost $0.45. The $0.50 trial therefore covers about 1,100 turns of this size (0.50 / 0.00045 is just over 1,111). That is enough to test a bot with real traffic from a handful of friends before you spend anything.
Output tokens cost more than three times as much as input tokens, so the cheapest lever is usually reply length. A bot that answers in 150 tokens instead of 300 saves $0.000075 per turn on output alone. Input is where history piles up, which the next sections cover.
A working chatbot in Python
The API is OpenAI-compatible, so the official openai package works unchanged. Install it with pip install openai, create a key from the API key page, and run this. It keeps the conversation in a list, streams the reply, and trims old messages so input cost stays flat.
from openai import OpenAI
client = OpenAI(
base_url="https://api.uncensoredstory.top/v1",
api_key="YOUR_KEY",
)
SYSTEM = "You are Sam, a dry-humored assistant for a hobby forum. Keep replies under 120 words."
history = [{"role": "system", "content": SYSTEM}]
MAX_TURNS = 12 # user+assistant pairs kept in context
def chat(user_text):
history.append({"role": "user", "content": user_text})
stream = client.chat.completions.create(
model="uncensored",
messages=history,
temperature=0.8,
stream=True,
)
reply = ""
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
piece = chunk.choices[0].delta.content
reply += piece
print(piece, end="", flush=True)
print()
history.append({"role": "assistant", "content": reply})
# keep the system message plus the last MAX_TURNS pairs
del history[1:-MAX_TURNS * 2]
while True:
chat(input("you> "))
Streaming returns server-sent events, and usage is reported at the end of the stream. The response headers include X-Balance-USD, so you can read your remaining credit without a separate call. The full parameter list is in the API docs.
One detail matters for bots on a website: a streamed request holds its concurrency slot until the stream finishes. If the user closes the tab, make sure your server cancels the upstream request, or the slot stays busy.
What a whole conversation costs
Chat is stateless. Every request must carry the history, so input tokens grow with each turn. Here is a 10-turn conversation worked out in full. Assume a 500-token system prompt, 100 tokens per user message and 200 tokens per reply, with nothing trimmed.
Turn n sends 500 + (n - 1) x 300 + 100 input tokens. That gives 600 tokens on turn 1, 900 on turn 2, and 3,300 on turn 10.
- Total input: 10 x 600 + 300 x (0 + 1 + ... + 9) = 6,000 + 13,500 = 19,500 tokens
- Total output: 10 x 200 = 2,000 tokens
- Input cost: 19,500 / 1,000,000 x $0.15 = $0.002925
- Output cost: 2,000 / 1,000,000 x $0.50 = $0.001
- Total: $0.003925, about $0.0039 per conversation
So 1,000 conversations of this shape cost about $3.93, and a $20 top-up covers roughly 5,000 of them. The trial's $0.50 covers about 127. Top-ups are any whole amount from $20 to $500, with a bonus of 5% from $50, 10% from $100 and 15% from $200. Credit never expires, so a small bot can run for months on one top-up. Payment is by crypto (USDT on TRC20, USDC on Base). Current rates are always on the pricing page.
The trimming in the code above matters for cost. Without it, a long-running chat resends everything every time, and the quadratic growth adds up. With a 12-pair window, the input per turn stops growing after the window fills.
JSON mode for bots that feed other code
Many chatbots are not only talking. They also have to hand something to your application: a ticket category, a sentiment label, a slot-filling result. JSON mode makes the model return a valid JSON object, so you can parse it without regex clean-up.
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredstory.top/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": "Return a JSON object with keys intent (string) and urgency (1 to 5)."},
{"role": "user", "content": "My order never arrived and I need it for Friday."},
],
temperature=0,
)
data = json.loads(resp.choices[0].message.content)
print(data["intent"], data["urgency"])
Describe the keys you want in the prompt as well as setting the flag. JSON mode guarantees valid syntax; it cannot know your schema, so validate the fields in your own code and retry once if a key is missing. Setting temperature to 0 makes classification output steadier, and a fixed seed helps when you want repeatable test runs.
Tool calling: a bot that looks things up
Tool calling lets the model ask your code to run a function and then use the result in its answer. The shape is the same as in the OpenAI API: you pass tools, the model replies with tool_calls, and you send the result back as a message with role: "tool".
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredstory.top/v1", api_key="YOUR_KEY")
tools = [{
"type": "function",
"function": {
"name": "order_status",
"description": "Look up an order by its id",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
},
}]
def order_status(order_id):
return {"order_id": order_id, "status": "shipped", "eta": "Thursday"}
messages = [{"role": "user", "content": "Where is order A-1042?"}]
first = client.chat.completions.create(model="uncensored", messages=messages, tools=tools)
msg = first.choices[0].message
if msg.tool_calls:
messages.append(msg)
for call in msg.tool_calls:
args = json.loads(call.function.arguments)
result = order_status(**args)
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})
final = client.chat.completions.create(model="uncensored", messages=messages, tools=tools)
print(final.choices[0].message.content)
A tool round trip is two requests, so it costs about twice a plain turn plus the tokens of the tool definitions, which are sent every time. Keep descriptions short. Use tool_choice when you need to force a specific function.
Limits to plan for and when another option fits better
A full key allows 8 concurrent requests and 300 requests per minute; the trial key allows 2 and 60. Go over the per-minute limit and you get HTTP 429 with error code rate_limited. Too many requests at once returns 429 with concurrency. Temporary overload also returns 429, with a Retry-After: 5 header. A small backoff handles all three:
import time
from openai import OpenAI, RateLimitError
client = OpenAI(base_url="https://api.uncensoredstory.top/v1", api_key="YOUR_KEY")
def ask(messages, tries=4):
for attempt in range(tries):
try:
return client.chat.completions.create(model="uncensored", messages=messages)
except RateLimitError as e:
wait = float(e.response.headers.get("retry-after", 2 ** attempt))
time.sleep(wait)
raise RuntimeError("still rate limited")
Eight concurrent streams is a real ceiling for a public bot. If you expect dozens of simultaneous chats, queue requests on your side.
Be honest about fit, too. If you need a permanently free tier for a hobby project and your bot never touches sensitive or adult themes, a provider with a standing free quota may suit you better; check their current pricing and terms. If you need images, speech or embeddings, you need another service for those parts. This API is for text chat where the model must not refuse lawful adult requests, such as fiction, roleplay and companion bots for adults. Prompts are not used for training. A sensible path is to claim the trial, run the script above, and decide after you have seen your own per-turn numbers.
