EN ▾

AI Chatbot for Roleplaying: Uncensored API Setup

Developers often assume OpenRouter provides true uncensored access, but its default models still apply strict safety filters to NSFW content. This article clarifies the reality of 'uncensored' models versus filtered defaults, helping you choose the right API for adult content generation without hidden refusals.

Stage with glowing masks and rising chat bubbles representing a roleplay chatbot

What a roleplay bot actually needs

An ai chatbot for roleplaying is different from a help-desk bot. Nobody checks whether it answers correctly. They check whether the innkeeper still has the limp she had forty messages ago, and whether the villain stays a villain when the scene turns dark.

That gives you a short list of requirements, and each one maps to something the API provides:

  • No mid-scene refusals. The model is an open-weight one, tuned to answer without content refusals for lawful adult use. Fiction, including dark themes, stays fiction.
  • Memory. The context window is 100,000 tokens, prompt and completion together. That holds a very long scene.
  • Speed you can feel. Streaming over SSE puts the first words on screen while the rest is still being written.
  • Control. Temperature, top_p, stop sequences, seed and penalties are passed through, so you can tune voice and repetition.

Anything outside that list is not offered. It is text only: no images, voice or embeddings. If your project needs a portrait for each character, you will need a separate tool for that.

Two ways to build it

RouteBest forTrade-off
A roleplay front end that accepts an OpenAI-compatible endpointWriters who want character libraries, lorebooks and swipes without codingYou adapt to the app's prompt layout
Your own script or botA companion app, a Discord or Telegram character, a game with a narratorYou write the memory logic yourself

Both use the same three values: the base URL https://api.unrestrictedaichatbot.cc/v1, your key, and the model ID uncensored. The quickstart docs show the raw request format. If you chose a front end, set its source to a custom OpenAI-compatible endpoint and paste those values in. The rest of this article is for the second route.

Write a system prompt that holds a character

The system message is the anchor. It is sent first on every request, so it never scrolls out of memory. Spend your effort here.

A workable structure has four parts: who the character is, how they speak, what the setting is, and what the model must not do. The last part matters more than people expect. Tell the model not to write the user's actions or dialogue, and not to break character to comment on the story.

You are Maren, a half-retired smuggler who runs a dockside tavern. Voice: dry, tired, quick to tease. Short sentences. Never explains jokes. Setting: a rain-soaked port city, late evening, three patrons in the room. Rules: write only Maren and the world. Never write the user's lines or decisions. Stay in character. Replies are 2 to 4 short paragraphs. All participants are adults.

Notice that the example is plain prose, not a wall of bullet points. Models imitate the register of the prompt, so a prompt written in clipped, concrete sentences tends to produce the same.

A working Python loop with memory

The API is stateless, so memory is a list you maintain. The script below keeps the system prompt fixed and drops the oldest turns once the list gets long.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.unrestrictedaichatbot.cc/v1",
    api_key="YOUR_API_KEY",
)

SYSTEM = "You are Maren, a dry, tired tavern owner. Write only Maren and the world."
history = []
MAX_TURNS = 24  # keep the last 24 messages

while True:
    user_text = input("You: ")
    history.append({"role": "user", "content": user_text})
    history = history[-MAX_TURNS:]

    stream = client.chat.completions.create(
        model="uncensored",
        messages=[{"role": "system", "content": SYSTEM}] + history,
        temperature=0.9,
        max_tokens=400,
        stream=True,
    )

    parts = []
    print("Maren: ", end="")
    for chunk in stream:
        if chunk.choices and chunk.choices[0].delta.content:
            piece = chunk.choices[0].delta.content
            parts.append(piece)
            print(piece, end="", flush=True)
    print()
    history.append({"role": "assistant", "content": "".join(parts)})

Trimming by message count is the simplest option. A better one trims by estimated tokens, and the best one summarizes old turns into a short note appended to the system prompt. For a long campaign, ask the model once every 30 messages to write a five-line summary of what has happened, then store that summary in place of the messages it replaced.

Narrator, single character, or both

Decide early whether the bot plays one character or runs the whole world. The choice changes the system prompt more than any other decision.

One character

Best for companion-style chats. The prompt describes a person, and the user is the only other speaker. Replies stay short, and the personality is easy to keep steady because there is only one voice to hold.

A narrator with a cast

Best for adventures and tabletop-style play. The model describes scenes and speaks for several non-player characters. This mode needs firmer rules: who is allowed to speak, how to mark a change of speaker, and where the scene ends so the user gets a turn. A short line such as "end every reply with an open moment for the player to act" works better than it sounds.

A story with a fixed premise

If you run a serialized story, put the premise and the current chapter summary into the system prompt and rewrite the summary as the plot moves. The model then has the facts that matter without carrying forty old messages.

Whichever mode you choose, write a first message by hand. The opening sets length, tense and tone for the rest of the session, and models tend to follow their own earlier output closely.

Keep the character consistent

Most roleplay failures fall into a few patterns, and each has a cheap fix.

  • The character slowly turns into a generic assistant. Repeat two or three key traits in a short reminder placed as the last system-style message. Recency helps.
  • Replies get longer and flowery. Lower max_tokens, and state the paragraph limit in the prompt.
  • The same phrases keep returning. Add a small frequency penalty, or raise the temperature a little.
  • The model plays your character. Add a stop sequence such as your character's name followed by a colon, and keep the rule in the system prompt.
  • You want reproducible tests. Pass a fixed seed while you tune the prompt.

Change one thing at a time. With two changes at once you cannot tell which one helped.

What it costs per message

Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, billed from prepaid credit. Take a bot with a 400-token system prompt plus 24 recent messages, about 2,500 prompt tokens in total, and a 250-token reply:

  • Input: 2,500 × $0.15 / 1,000,000 = $0.000375
  • Output: 250 × $0.50 / 1,000,000 = $0.000125
  • Total: $0.0005 per reply

That is $0.50 for 1,000 replies, and a $20 top-up pays for about 40,000. Failed or refused requests are not charged. Top-ups run from $20 to $500 in crypto (USDT on TRC20 or USDC on Base), with a bonus of +5% from $50, +10% from $100 and +15% from $200; see the pricing page. To test the whole loop first, claim the trial credit on the API key page.

Limits and ground rules

A full key allows 8 concurrent requests and 300 per minute, and the trial key allows 2 and 60. A single chat never gets near those numbers; a public bot with many users might, so queue requests if you expect a crowd.

Keep the content on the right side of two lines. Use is for lawful adult fiction and companionship apps, and sexual content involving minors is not allowed under any framing. Your prompts are not used for training, but they are still your users' words, so tell them what you store. If you wondered how this differs from going through a model marketplace, the OpenRouter NSFW myths and facts page walks through it.

Questions and answers

How long can a roleplay session get before the bot forgets?

The window is 100,000 tokens, prompt plus completion, which is a very long scene. Past that, or whenever you want lower cost, trim old messages and keep a short summary.

Can I stream the replies?

Yes. Set stream to true and the API sends tokens over SSE, with usage at the end.

Does the model refuse dark fiction?

It is tuned to answer without content refusals for lawful adult use. The one fixed limit is sexual content involving minors.

Do I need a subscription?

No. You pay per token from prepaid credit, and the credit never expires.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key