Uncensored Model API for Roleplay and Story Writing
For uncensored model api roleplay, you need three things: a model that stays in character without breaking the scene, a way to stream replies, and a context window large enough to remember the story. This article builds that loop step by step.
Updated

Key points
- Keep character and world rules in a stable system prompt, and let the 100,000-token window hold the running story.
- Stream replies so the scene appears word by word, and close the stream if the user leaves.
- Trim or summarize old turns once history grows; a 6,000-token turn costs about $0.0012.
- The service is for lawful adult fiction; sexual content involving minors is never allowed.
What roleplay needs from an API
Interactive fiction is a demanding use of a language model. The model must keep a character's voice for hours, remember facts from the first scene in the fiftieth, and write dark or mature themes without stopping to lecture. Standard hosted models often interrupt such scenes with refusals or disclaimers. That is the gap an uncensored model closes.
This endpoint serves one open-weight model, tuned to answer without content refusals for lawful adult use. It speaks the OpenAI chat format, so any frontend or script that supports a custom OpenAI base URL can drive it. The model ID is uncensored. Streaming, a 100,000-token context window and the usual sampling controls cover the needs of a story tool. For a plain explanation of the service itself, see the quickstart docs.
One rule is fixed: no sexual content involving minors. If you build a public roleplay app on this API, state that rule in your own terms and enforce it in your own input checks too.
Design the system prompt as a character sheet
The system message is the one part of the request that never changes between turns, so treat it as a stable character sheet. A good one is short enough to read in a minute and specific enough that a stranger could continue the scene from it. Cover these points:
- Role. Who the model plays, and who it never plays. Say plainly that it does not write the user's lines or actions.
- Voice. Sentence length, vocabulary, mannerisms, point of view and tense. One sample line is worth a paragraph of adjectives.
- World facts. Names, places, rules of magic or technology, and relationships that must stay consistent.
- Format. Whether to use narration in prose, quoted dialogue, or script style. How long a reply should be, for example two to four paragraphs.
- Boundaries. Themes you want to avoid for your own audience, written as plain instructions.
Because the model is not adding its own refusals, your system prompt decides the tone. A vague prompt gives vague fiction. Write the boundaries you actually want, since nobody else will apply them for you.
A streaming chat loop in Python
Here is a small terminal roleplay loop. It keeps the history in a list, streams each reply and appends the finished text back to the history.
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredmodel.top/v1", api_key="YOUR_KEY")
SYSTEM = (
"You are Mara, a weary ship captain in a fantasy sea story. "
"Write in third person, past tense, two to four paragraphs. "
"Never write the user's actions or dialogue."
)
history = [{"role": "system", "content": SYSTEM}]
while True:
user = input("\n> ")
if not user:
break
history.append({"role": "user", "content": user})
stream = client.chat.completions.create(
model="uncensored",
messages=history,
stream=True,
temperature=0.9,
top_p=0.95,
presence_penalty=0.3,
)
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)
history.append({"role": "assistant", "content": reply})
Two settings are worth explaining. A temperature near 0.9 keeps prose varied without drifting into nonsense. A small presence penalty discourages the model from circling back to the same images in every reply. Both are passed through to the model, as are top_p, stop, seed and the frequency penalty. If you want reproducible reruns while tuning a prompt, fix the seed.
Streaming details that matter for a story app
Streaming makes the difference between a tool that feels alive and one that makes the reader wait for a wall of text. The API sends server-sent events, and the last chunk includes usage numbers, so you can show or log the token cost per turn.
Two practical points. First, a streamed request holds its concurrency slot until the stream ends. A full key allows 8 at once and a trial key allows 2, so a web app with many readers must queue or limit parallel scenes. If a reader closes the tab, abort the request on your side so the slot is freed. Second, handle HTTP 429 calmly. The error code concurrency means too many scenes at once, rate_limited means too many requests per minute, and a Retry-After: 5 header means a short wait is enough.
In Node, the same streaming call looks like this:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uncensoredmodel.top/v1",
apiKey: process.env.API_KEY,
});
const stream = await client.chat.completions.create({
model: "uncensored",
messages: [
{ role: "system", content: "You narrate a slow-burn mystery in second person." },
{ role: "user", content: "I step into the lamplit archive." },
],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Using the 100k context without wasting it
A window of 100,000 tokens, prompt plus completion, is large for fiction. A novel chapter runs a few thousand words, so you can keep a long stretch of the story verbatim. That does not mean you should send everything every time. Each turn resends the whole history, and you pay input rates on all of it, so a smarter structure gives better scenes for less money.
- Pin the essentials. System prompt, character sheet and a short "story so far" summary go first and stay stable.
- Keep recent turns whole. The last 10 to 20 exchanges give the model the rhythm and detail of the current scene.
- Summarize the middle. When history passes a size you choose, for example 40,000 tokens, ask the model to condense the oldest part into a few hundred words and replace those turns with the summary.
- Add a lorebook on demand. Short entries about people and places can be inserted only when a keyword appears in the latest message. Frontends such as SillyTavern, which can add an OpenAI-compatible endpoint, already do this.
You do not need to set max_tokens. The completion can use the rest of the window. For a story app, though, a reply length instruction in the system prompt is usually kinder to the reader than a hard cut-off.
Beyond plain chat: JSON mode and tool calling
Roleplay gets more interesting when the app tracks state. Two features help. JSON mode, enabled with response_format: {"type": "json_object"}, makes the model return a JSON object. You can run a second, cheap call after each scene that asks for something like the current location, the inventory and a mood value, then store that in your own database and feed it back into the next prompt. Mention the word JSON and describe the keys in the prompt so the output is predictable.
Tool calling suits game mechanics. Define a roll_dice function in the tools list, let the model request a roll when the story needs luck, run the roll in your code and return the result as a message with role: "tool". The model then continues the scene using the real number. This keeps the fairness of the dice in your hands rather than in the model's imagination.
Common problems and how to fix them
Most weak roleplay sessions trace back to a handful of causes, and each has a direct fix.
- The model writes the user's lines. Add a plain rule to the system prompt: never write the user's dialogue, thoughts or actions, and end each reply at a point where the user can act. Repeating that rule in a short final system message close to the latest turn makes it stick better than a rule buried at the top.
- Replies grow longer and longer. The model copies the length of earlier replies. State a target length, and trim any overlong reply in your history before sending it back.
- The character drifts out of voice. Long histories dilute the system prompt. Put a three-line reminder of voice and goals into the summary block, and consider one sample line of dialogue.
- Repetition of phrases and images. Raise the presence penalty a little, from 0.3 toward 0.6, or lower top_p slightly. Change one value at a time and fix the seed so you can compare.
- Facts contradict earlier scenes. Keep a short list of established facts in your own storage, such as names, injuries and promises, and pin it in the prompt. Models forget details that appeared once, long ago.
When a request fails, nothing is charged, so you can retry without worrying about wasted credit.
What a session costs
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, from prepaid credit. Suppose a scene turn sends 6,000 input tokens (system prompt, summary and recent turns) and receives 600 output tokens. Input costs 6,000 x $0.15 / 1M = $0.0009. Output costs 600 x $0.50 / 1M = $0.0003. One turn is $0.0012, and 1,000 turns come to $1.20.
If you let the history grow to 60,000 input tokens per turn with the same 600-token reply, input costs $0.009 and output $0.0003, so $0.0093 per turn. That is almost eight times as much, which is the reason to trim and summarize. The $0.50 trial credit covers roughly 416 turns at the smaller size ($0.50 / $0.0012). Top-ups start at $20 and add a bonus from $50. The pricing page lists the payment options, and you can get a key on the API key page.
More guides
Questions and answers
Can I use SillyTavern or another roleplay frontend?
Frontends that accept a custom OpenAI-compatible endpoint can use it. Enter the base URL, your key and the model ID uncensored.
How much story can the model remember?
The context window is 100,000 tokens for prompt plus completion. For longer stories, summarize older turns and keep recent ones whole.
Does it write images or voices for characters?
No. The service is text only, with no image, audio or video generation.
Is there any content the API will not write?
Yes. Sexual content involving minors is never allowed. Other lawful adult fiction is not blocked by the model's own refusals.
How many scenes can run at once?
A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 and 60.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.