The basic structure: loop, history, API
An unfiltered chatbot is technically not a special case. You need the same building blocks as for any bot: an input loop, a list of messages, and a model that responds. The difference lies in the model. We use the API of kiohnezensurapi.com, which provides a single open-weight model from an independent provider, tuned for responses without content refusal for lawful use by adults.
Prerequisites: Python 3.9 or newer, pip install openai and a key from the Get API key page. The free trial credit of $0.50 (once per person, valid for 7 days, no payment details required) is enough for the entire guide.
The complete code
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.kiohnezensurapi.com/v1",
api_key=os.environ["KI_KEY"],
)
SYSTEM = (
"Du bist Rex, ein trockener, direkter Gesprächspartner. "
"Du antwortest auf Deutsch, in kurzen Absätzen, ohne Vorträge."
)
verlauf = [{"role": "system", "content": SYSTEM}]
MAX_NACHRICHTEN = 20 # ohne System-Prompt
def kuerzen():
rest = verlauf[1:][-MAX_NACHRICHTEN:]
verlauf[:] = [verlauf[0]] + rest
while True:
text = input("Du: ").strip()
if text in ("", "exit"):
break
verlauf.append({"role": "user", "content": text})
kuerzen()
stream = client.chat.completions.create(
model="uncensored",
messages=verlauf,
stream=True,
temperature=0.8,
max_tokens=600,
)
antwort = ""
print("Rex: ", end="", flush=True)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
teil = chunk.choices[0].delta.content
antwort += teil
print(teil, end="", flush=True)
print()
verlauf.append({"role": "assistant", "content": antwort})Save this as bot.py, set KI_KEY in the environment and start with python bot.py. The function kuerzen keeps only the last 20 messages plus the system prompt so that the history does not grow indefinitely.
How the code works
System prompt
The first message with role: system sets personality and style. It is sent with every request. Keep it short; it counts as input every time.
History
The API does not store anything between calls. Therefore, append every user message and every response to the list. Without the bot's response, it forgets what it said itself.
Streaming
With stream: true, the response arrives via Server-Sent Events in small chunks. This feels faster because the text appears immediately. Note: A streaming request occupies a slot in the rate limit for parallel requests until the stream ends. With a test key, 2 are allowed; with a full key, 8.
max_tokens
The parameter is optional. Without it, the response may use the rest of the 100,000-token window. For a chat, a cap makes sense; it protects against sprawling responses and thus unnecessary costs.
Cost calculation for your bot
Prices: $0.15 per 1M input tokens, $0.50 per 1M output tokens. Assume the system prompt has 100 tokens and the history averages 3,000 tokens, with a response of 300 tokens.
- Input: 3,100 / 1,000,000 × $0.15 = $0.000465
- Output: 300 / 1,000,000 × $0.50 = $0.00015
- Total: $0.000615 per message
That’s $0.615 per 1,000 messages. With the $0.50 free trial credit, you get roughly 813 messages (0.50 / 0.000615 ≈ 813). A user sending 50 messages a day costs about $0.92 per month (30 days, 1,500 messages).
The biggest lever is conversation length. If the bot sent an average of 10,000 instead of 3,000 tokens, the input would rise to 10,100 / 1,000,000 × $0.15 = $0.001515 per message, totaling $0.001665 with the response. Trimming or summarizing old rounds saves money directly. Failed or rejected requests are not charged.
Improvements for daily use
- Memory through summarization: Summarize older messages with a separate API call in a single paragraph and replace them. This lets the bot keep the thread while keeping costs low.
- Error handling: Catch HTTP 429. The error code
rate_limitedmeans too many requests per minute,concurrencymeans too many simultaneous ones. Under load, the header containsRetry-After: 5; wait 5 seconds. - Persistence: Save the conversation as a JSON file or in a database so chats survive a restart.
- Multiple users: Maintain a separate conversation list per user. With many users at once, the 8 concurrent requests limit throughput; use a queue.
- Protect your key: Never put it in your frontend. Call the API from your server.
Other parameters like top_p, stop and seed, as well as function calling, are described in the documentation.
What "uncensored" does not mean
The bot answers where other assistants would refuse. This does not replace your responsibility as the operator. Sexual content involving minors is excluded without exception, and the service is intended for lawful use by adults. If you offer the bot publicly, you should require an age check and define terms of use. Prompts are not used for training; your own data protection obligations to your users remain unaffected.
Additionally, the API is text-only: image or voice chat requires other services. Background information is provided in the article AI without restrictions, and the pricing tiers are on the pricing page. Top up starts at $20 with USDT on TRC20 or USDC on Base, with a +5% bonus from $50.

