Uncensored AI Model API: Python Quickstart
An uncensored ai model api works like any other chat API, so the fastest start is the OpenAI Python SDK pointed at a different base URL. This quickstart goes from key to streaming output and adds the system prompt habits that matter for a model that does not refuse.

Summary
- Base URL https://api.modelaiuncensored.com/v1, model ID uncensored, auth with a Bearer key.
- A system prompt sets persona, format and your product rules. It is not a switch for refusals.
- Streaming, JSON mode and tool calling are supported. Resend history each turn since the API is stateless.
- The trial key gives $0.50 of credit, 2 concurrent requests and 60 requests per minute.
Get a key and install the SDK
Sign up on the API key page with Google or with email and password, then claim the $0.50 trial credit with one click. It is valid for 7 days, needs no payment details and is limited to one per person. If you need to replace a key later, regenerate it on the same page. The old key stops working at once.
pip install openai
export API_KEY="YOUR_KEY"
The service is a hosted, OpenAI-compatible text API. It runs one open-weight model, run by an independent provider, tuned to answer without content refusals for lawful adult use. It is not an official API of any model vendor.
Your first request
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.modelaiuncensored.com/v1",
api_key=os.environ["API_KEY"],
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a direct, plain-spoken assistant."},
{"role": "user", "content": "Give me a blunt critique of this opening line: 'It was a dark night.'"},
],
)
print(resp.choices[0].message.content)
The same request over curl, handy for a quick check from a terminal:
curl https://api.modelaiuncensored.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "uncensored", "messages": [{"role": "user", "content": "Hello"}]}'
The response is a standard chat completion object. The text is in choices[0].message.content, the reason it stopped is in choices[0].finish_reason, and the token counts are in usage. A finish_reason of length means the reply hit your max_tokens cap, so raise it or ask for a shorter answer. The usage block is what you are billed on, at $0.15 per 1M input tokens and $0.50 per 1M output tokens.
System prompt tips for a model that does not refuse
Without refusals, the model follows your instructions more literally, which makes the system prompt the most important text in your app.
Say who it is and where it works
Give a role and a setting in two or three sentences: "You are the narrator of a dark fantasy story for adult readers." Specific context beats long lists of rules.
Write your own limits
The model will not infer your brand boundaries. If your product excludes some themes, name them. If your characters are adults, say so in the character description. The service itself never allows sexual content involving minors.
Fix the output format
State point of view, tense, length in paragraphs and whether replies should include dialogue. A line such as "Reply in 2 to 4 paragraphs, no headings, no commentary" removes a lot of noise.
Drop the filler
If you do not want preambles or sign-offs, say so: "Start directly with the answer." Short, concrete instructions work better than a wall of text, and they save input tokens on every request.
Three system prompts you can copy
These are starting points. Edit the details to suit your product.
PROMPTS = {
"narrator": (
"You are the narrator of an interactive dark fantasy story for adult readers. "
"Write in second person, present tense. Reply in 2 to 4 paragraphs. "
"End with a situation that invites the reader's next move. "
"Do not add commentary or disclaimers."
),
"character": (
"You are Mara, a 34-year-old smuggler: dry humour, guarded, loyal to a few people. "
"Stay in character and speak in first person. Keep replies under 120 words. "
"Never mention being an AI unless the user asks directly."
),
"editor": (
"You are a frank fiction editor. Give a critique in three bullet points: "
"what works, what drags, one concrete rewrite. No flattery."
),
}
r = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": PROMPTS["editor"]},
{"role": "user", "content": "Critique: 'The rain fell. She walked. It was sad.'"},
],
temperature=0.7,
)
print(r.choices[0].message.content)
Three mistakes show up again and again. Contradictory instructions, such as "be brief" next to "describe everything in detail", make output erratic. A prompt of 2,000 tokens costs input tokens on every single request. And instructions placed only at the start fade in long chats, so repeat the key rule in a short reminder message every ten turns or so.
Keep conversation history
The API is stateless. The model remembers nothing between calls, so you resend the conversation each time. A minimal chat loop:
history = [{"role": "system", "content": "You are a witty travel writer."}]
while True:
user = input("you> ")
if not user:
break
history.append({"role": "user", "content": user})
r = client.chat.completions.create(model="uncensored", messages=history)
answer = r.choices[0].message.content
history.append({"role": "assistant", "content": answer})
print("bot>", answer)
The context window is 100,000 tokens, counting the prompt and the reply together. That is enough for long sessions, but input cost grows with every turn, so summarize or drop the oldest turns once a chat gets long.
A simple trim keeps the system message and the most recent turns. This sketch keeps the last 20 exchanges:
MAX_EXCHANGES = 20
messages = [history[0]] + history[1:][-MAX_EXCHANGES * 2:]
r = client.chat.completions.create(model="uncensored", messages=messages)
For a story that must remember early events, replace the dropped turns with a short summary message instead of cutting them without a trace.
In a real app, keep one history list per user session and store it in your own database. Never share a list between users, and do not let a user edit the system message. Because the model sees only what you send, whatever you leave out of the list is simply forgotten.
Stream the answer
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Describe a market at dawn in five sentences."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if getattr(chunk, "usage", None):
print("\n", chunk.usage)
Streaming uses server-sent events and ends with the usage numbers. A streamed request keeps its concurrency slot until it finishes, so in a web app close the stream when the user leaves the page.
If streaming appears to arrive all at once in a web app, a proxy or framework in front of your server is probably buffering the response. Disable buffering for the streaming route, and pass chunks to the browser as they come. Test with a long reply, because short ones hide the problem.
Temperature, JSON mode and tools
| Task | Temperature | Notes |
|---|---|---|
| Data extraction, classification | 0.0 to 0.3 | Pair with JSON mode |
| Assistant chat | 0.5 to 0.8 | Balanced and predictable |
| Fiction, roleplay | 0.8 to 1.1 | More variety; add a frequency penalty if replies repeat |
These are starting points, not rules. Tune them against your own prompts. For structured output, pass response_format={"type": "json_object"} and say in the prompt which keys you expect. Tool calling works with tools and tool_choice, and results go back as messages with role: "tool". Both are described in the docs.
Two more passed-through settings are worth knowing. seed makes tests repeatable by aiming for the same output on the same input. The frequency and presence penalties reduce loops when a character repeats a phrase. Change one setting at a time and rerun the same ten prompts, so you can tell which change made the difference.
A minimal JSON mode call looks like this:
import json
r = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": 'Return a JSON object with keys "mood" and "next_scene".'},
{"role": "user", "content": "The hero has just lost the duel."},
],
response_format={"type": "json_object"},
)
state = json.loads(r.choices[0].message.content)
print(state["mood"], "->", state["next_scene"])
This is the pattern behind most story-state features: the model writes the scene, a second small call returns structured state, and your code stores it in a database for the next turn.
Limits, errors and cost
A full key allows 8 concurrent requests and 300 requests per minute. Beyond that the API returns HTTP 429 with the code rate_limited or concurrency. Temporary overload also gives a 429, with Retry-After: 5. Wait and retry. The SDK does a couple of automatic retries for you.
Prices are $0.15 per 1M input tokens and $0.50 per 1M output tokens. A request with 1,000 input tokens and 300 output tokens costs $0.00015 plus $0.00015, so $0.0003. The X-Balance-USD response header shows your remaining credit. We break down more workloads in pricing, and compare model options in our uncensored AI model comparison.
For batch jobs, a small thread pool sized to your key avoids most 429 responses:
from concurrent.futures import ThreadPoolExecutor
def run(prompt):
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": prompt}],
)
return r.choices[0].message.content
with ThreadPoolExecutor(max_workers=8) as pool: # use 2 with a trial key
results = list(pool.map(run, ["Idea one", "Idea two", "Idea three"]))More guides
Common questions
Which model name do I use?
Use uncensored as the model ID in every request.
Does the OpenAI Python SDK work as is?
Yes. Set base_url to https://api.modelaiuncensored.com/v1 and pass your key as api_key. No other changes are needed.
Can the API generate images?
No. It is text only. It offers no image, audio or video generation, no embeddings and no fine-tuning.
What happens when my trial credit runs out?
Requests stop until you top up. Top-ups are any whole amount from $20 to $500, paid in crypto, and credit never expires.
Get your API key
Sign up, copy the token, update your base URL. Simple.