What you are actually building
When people search for a Gemini API for chatbot work, they usually want three things: a model that holds a conversation, a way to stream words as they are generated, and a price that does not grow painful when users chat for an hour. Google's Gemini is one option for that, and its own documentation is the place to check its features and pricing. This page covers a different one: a hosted text API with one open-weight model, which is not Gemini and not affiliated with Google, and which is tuned to answer without content refusals for lawful adult use.
The reason that matters for chatbots is practical. Companion apps, interactive fiction, roleplay tools and adult-oriented assistants regularly hit refusals on mainstream hosted models, and a refusal in the middle of a story breaks the product. Here the model is meant to stay in character. The one hard line is that sexual content involving minors is never allowed.
The interface is the OpenAI chat completions format, so any OpenAI SDK works after you change the base URL and key. The model ID is uncensored. Two methods exist: POST /v1/chat/completions and GET /v1/models. That is all a chatbot needs.
The core loop in Python
The API remembers nothing between calls. Memory is a list of messages that your program keeps and sends again each turn. A system message goes first and sets the persona; user and assistant messages follow in order.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.uncensoredgemini.top/v1",
api_key=os.environ["UNCENSORED_API_KEY"],
)
history = [
{"role": "system", "content": "You are Mara, a dry-witted ship's navigator in an ongoing space opera. Stay in character."},
]
while True:
user = input("you> ")
if not user:
break
history.append({"role": "user", "content": user})
stream = client.chat.completions.create(
model="uncensored",
messages=history,
stream=True,
temperature=0.8,
)
reply = ""
print("mara> ", end="")
for part in stream:
if part.choices and part.choices[0].delta.content:
piece = part.choices[0].delta.content
reply += piece
print(piece, end="", flush=True)
print()
history.append({"role": "assistant", "content": reply})
Two lines deserve attention. The if part.choices check guards against a final chunk that carries usage data and no text; usage is reported at the end of a stream. And the assistant reply is appended after the loop finishes, so the next call sees the complete turn.
Persona, memory and the 100,000-token window
The context window is 100,000 tokens, counting the prompt and the completion together. For a chatbot that is generous, but a long-running roleplay can still fill it, and every extra token you resend costs input price on every later turn. Three habits keep this under control.
- Pin the system message. Drop old turns from the middle, never the persona at the top.
- Trim by token estimate. A rough rule for English is four characters per token. Cut the oldest turns once the history passes a budget you choose, for example 12,000 tokens.
- Summarise instead of deleting. Ask the model for a short summary of the oldest twenty turns, replace them with one message, and the character keeps its memory of the plot.
Sampling settings are passed through: temperature, top_p, stop, seed and the frequency and presence penalties. For character chat, a temperature between 0.7 and 1.0 gives varied dialogue, and a small presence penalty reduces the loops where a character repeats the same phrase. For a support or FAQ bot, use 0.2 or lower and a firm system prompt.
A Node backend that streams to the browser
Never put the API key in front-end code. Run a thin server that holds the key, accepts the conversation from your page, and forwards the stream. This Express example uses the official OpenAI package for Node.
import express from "express";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uncensoredgemini.top/v1",
apiKey: process.env.UNCENSORED_API_KEY,
});
const app = express();
app.use(express.json({ limit: "1mb" }));
app.post("/chat", async (req, res) => {
const messages = Array.isArray(req.body.messages) ? req.body.messages.slice(-40) : [];
res.setHeader("Content-Type", "text/event-stream");
res.setHeader("Cache-Control", "no-cache");
try {
const stream = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "system", content: "You are a friendly storyteller." }, ...messages],
stream: true,
});
for await (const part of stream) {
const text = part.choices[0]?.delta?.content;
if (text) res.write("data: " + JSON.stringify(text) + "\n\n");
}
res.write("data: [DONE]\n\n");
} catch (err) {
res.write("data: " + JSON.stringify({ error: "busy, try again" }) + "\n\n");
}
res.end();
});
app.listen(3000);
The server sets the system message itself and only accepts user and assistant turns from the browser, which stops a visitor from rewriting your persona. It also slices the history to the last 40 messages as a blunt size guard. The request body limit on the API is 8 MB, far above anything a chat needs, but your own endpoint should be stricter.
What a conversation costs
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, billed from prepaid credit. Here is a worked example for a typical chat with a 400-token system prompt, where each user message is about 60 tokens and each reply about 200 tokens, over ten turns.
- Each completed turn adds 260 tokens of history (60 + 200).
- Input on turn n is 400 + 60 + 260 × (n - 1). Summed over ten turns: 10 × 460 + 260 × 45 = 4,600 + 11,700 = 16,300 input tokens.
- Output is 10 × 200 = 2,000 tokens.
- Input cost: 16,300 × $0.15 / 1M = $0.002445. Output cost: 2,000 × $0.50 / 1M = $0.001. Total: $0.003445.
So a thousand such conversations cost about $3.45, and the $0.50 trial credit covers roughly 145 of them. Input dominates as chats grow, because the full history is resent each turn. That is the reason to trim and summarise. Failed or refused requests are not charged, and credit never expires, so unused balance simply waits.
Top-ups are any whole amount from $20 to $500, with a +5% bonus from $50, +10% from $100 and +15% from $200. This site takes crypto only: USDT on TRC20 or USDC on Base. Details are on the pricing page.
Keeping the character consistent
Long chats drift. After a few hundred turns the persona softens, the tone flattens and details from the system prompt are forgotten. The fix is cheap and mostly about prompt structure rather than model settings.
- Put the rules the character must never break in the first lines of the system message, short and imperative.
- Re-send a compact "recap note" every few turns: location, relationships, open threads, three lines at most.
- Keep user-visible instructions separate from hidden ones, and never echo the system prompt back to the user.
- Lower the temperature when the character starts inventing facts, and raise it when replies feel repetitive.
For public products, add your own age gate and terms. The model is tuned for lawful adult use, and the minors rule is absolute, so an app that serves adult fiction should verify that its users are adults before showing them anything. That responsibility sits with the application you build, not with the API. The comparison page covers a similar trade-off from the cost side.
Limits you will meet with real users
A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 and 60. Because a stream occupies its slot until the last token arrives, 8 slots means 8 replies being written at the same moment, not 8 requests per second. If your chatbot has more simultaneous users than that, you need a queue.
A simple approach is a per-process semaphore set to 8 and a short wait before returning a friendly "busy" message. When the API answers 429, read the error code: concurrency means too many at once, rate_limited means too many per minute, and a 429 with Retry-After: 5 means temporary overload, so wait five seconds and retry. The response headers X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency are useful to log: the balance header lets you warn yourself before credit runs out.
Tools, JSON and next steps
Once the basic loop works, two features turn a chatbot into an application. Tool calling lets the model ask your code to look up a character sheet, roll dice or fetch an order. JSON mode (response_format: {"type":"json_object"}) lets you extract structured state, such as inventory or mood, from each reply for your UI. Both follow the OpenAI format, and the API docs show the request shapes.
If you are comparing hosted options, the site also has a short page on the Grok-style API trade-offs. To start, get an API key, run the Python loop above and watch the X-Balance-USD header drop by fractions of a cent per turn. Prompts are not used for training. This is a text-only service: no images, audio or embeddings, so a voice or image feature needs another provider on the side.
