EN ▾
Get API key

Unrestricted AI Chatbot Character: Build One via API

An unrestricted AI chatbot character is a system prompt plus a message history that you resend on each request. This guide shows the prompt, the Python loop and the settings that keep the voice steady.

Updated

Theatre mask made of speech bubbles on a stage linked to stacked message tiles, representing a chatbot character

Key points

  • The character lives in your messages array, since the API stores no state between calls.
  • Fix voice, format rules and scene boundaries in the system prompt, and always keep it as message zero.
  • Trim or summarise old turns well before the 100,000-token window fills.
  • A 40-turn scene at typical sizes costs about $0.023 at $0.15 and $0.50 per 1M tokens.

What a character is when you call an API

A chatbot character is not a feature of the model. It is text you send with every request. The model reads a system message that describes who the character is, then reads the conversation so far, and continues it in that voice. Nothing is stored on the server between calls, so the character lives in your messages array and nowhere else.

That fact shapes the whole workflow. You write the persona once, keep it as the first message, and send the full history on every turn. If you want a second character, you write a second system prompt. If you want the character to remember something, you put it in the prompt or in the history you resend. The API gives you a text-in, text-out endpoint, and the character is what you build on top of it.

The endpoint here is OpenAI-compatible, so any OpenAI SDK or chat front end can drive it after you change two values: the base URL and the key. The model ID is uncensored. It is a single open-weight model run by an independent provider and tuned to answer without content refusals for lawful adult use, which matters for characters because a roleplay persona that breaks the scene with a canned refusal is not much use. The hard limit stays in place: nothing involving minors, ever.

Write the system prompt before you write any code

Most character quality comes from the system prompt, not from settings. A prompt that says "you are a pirate" gives you a pirate for three turns and a generic assistant with an eyepatch after that. A prompt that fixes voice, boundaries and scene rules holds up much longer. These five parts cover most of what you need.

  1. Identity in one or two sentences. Name, role, place. Concrete nouns beat adjectives: "salvage pilot on Kestrel Dock" says more than "a brave and clever adventurer".
  2. Voice. How the character talks. Short or long sentences, dry or warm, any verbal habits. Two or three traits are enough.
  3. Format rules. Person and tense, reply length, how actions are marked. Models drift toward long replies, so state the length you want.
  4. Boundaries of the scene. Never speak for the user, never narrate the user's feelings, and what the character does when the conversation goes somewhere it would not go.
  5. Facts the character must keep straight. Names of other people, the setting, a running problem. Keep it short, since every token is resent each turn.

Here is a complete example in code. It builds one persona and holds a conversation through a plain list of messages.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.unrestrictedchatbot.cc/v1",
    api_key=os.environ["UNRESTRICTED_API_KEY"],
)

SYSTEM = """You are Mara Venn, a salvage pilot on the frontier station Kestrel Dock.
Voice: dry, quick, protective of her crew, allergic to speeches.
Rules of the scene:
- Stay in character. Never mention being an AI or a model.
- Write in first person, one to three short paragraphs per reply.
- Actions go in *asterisks*. Never speak or act for the user.
- If the user steers somewhere you would not go, Mara deflects in character."""

messages = [{"role": "system", "content": SYSTEM}]

def say(text):
    messages.append({"role": "user", "content": text})
    r = client.chat.completions.create(
        model="uncensored",
        messages=messages,
        temperature=0.9,
        top_p=0.95,
    )
    reply = r.choices[0].message.content
    messages.append({"role": "assistant", "content": reply})
    return reply

print(say("*I drop my duffel on your hull plating.* Heard you take passengers."))

Set UNRESTRICTED_API_KEY in your shell first. Keep the key out of source files and out of any front-end code that ships to a browser.

Test the same persona from the command line

Before you wire a character into an app, run it once with curl. If the persona behaves here, any later oddity comes from your app code and not from the prompt. The request is the same shape as any chat completion.

curl https://api.unrestrictedchatbot.cc/v1/chat/completions \
  -H "Authorization: Bearer $UNRESTRICTED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "temperature": 0.9,
    "messages": [
      {"role": "system", "content": "You are Mara Venn, a dry-witted salvage pilot. Stay in character."},
      {"role": "user", "content": "*I knock on the airlock.* Anyone home?"}
    ]
  }'

The reply comes back as JSON with the text in choices[0].message.content. The response headers include X-Request-Id, which is useful if you ever contact support about a specific call, and X-Balance-USD, which shows your remaining credit after the request.

Keep the character stable over a long chat

Characters fail in a predictable way: the voice flattens as the history grows, or the model starts echoing phrases from its own earlier replies. The context window is 100,000 tokens, prompt and completion together, which is room for a very long scene, but a long history does not guarantee a steady voice. A few habits help.

Resend the system prompt as the first message, always

If you trim history, trim from the middle or the oldest end and keep message zero. Losing the system prompt is the fastest way to lose the character.

Trim on purpose instead of waiting for an error

The version below keeps the system prompt and the most recent 24 exchanges, and streams the answer so the user sees words immediately. Streaming uses server-sent events through stream: true.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.unrestrictedchatbot.cc/v1",
    api_key=os.environ["UNRESTRICTED_API_KEY"],
)

KEEP_TURNS = 24  # user+assistant pairs kept verbatim

def trimmed(messages):
    head = messages[:1]          # the system prompt always stays
    tail = messages[1:][-KEEP_TURNS * 2:]
    return head + tail

def chat_stream(messages, user_text):
    messages.append({"role": "user", "content": user_text})
    stream = client.chat.completions.create(
        model="uncensored",
        messages=trimmed(messages),
        temperature=0.9,
        stream=True,
    )
    parts = []
    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()
    messages.append({"role": "assistant", "content": "".join(parts)})

Summarise old turns into a memory note

When a story is long, ask the model itself, in a separate call, to write a short summary of the events that were trimmed, and add that summary to the system prompt under a heading such as "What has happened so far". It costs one extra request now and then, and it keeps plot facts alive after the raw messages are gone.

Correct drift early

If the character slips, a short out-of-scene system message late in the history, such as "Reminder: Mara keeps replies under three paragraphs and never speaks for the user", often fixes it. Models weigh recent instructions heavily, so a reminder near the end works better than adding more text at the top.

Settings that change how a character feels

The sampling parameters you pass are forwarded to the model: temperature, top_p, stop, seed and the frequency and presence penalties. For character work they behave like this.

SettingStarting valueWhat it does for a character
temperature0.8 to 1.0Higher gives livelier, less predictable lines. Below 0.6 characters start to sound like each other.
top_p0.9 to 0.95Cuts off the unlikely tail of words. Change this or temperature, not both at once.
presence / frequency penalty0.2 to 0.5Reduces repeated phrases and pet words across a long chat.
stopa marker such as the user's name followed by a colonEnds the reply if the model starts writing the user's lines.
seedany integerHelps you compare two prompt versions on the same input while you tune.
max_tokensoptionalCaps reply length as a safety net. If unset, the reply can use the rest of the window.

Change one setting at a time and rerun the same three or four user messages. It is easy to blame temperature for what is really a vague prompt, so test the prompt first and the numbers second.

Use a ready-made chat client instead of writing one

You do not have to build the interface. Front ends built for character chat, SillyTavern being a well-known one, let you add a custom OpenAI-compatible endpoint. In general you paste the base URL https://api.unrestrictedchatbot.cc/v1, paste your key, and set the model name to uncensored. The client then handles character profiles, history and formatting, and the API only supplies the text. Exact menu names change between versions, so check your client's own documentation for where the custom endpoint option sits.

The quickstart in the docs lists the supported request fields, including tool calling and JSON mode. Tool calling is handy for characters that need to look something up or change game state, and JSON mode helps when you want a character to return structured data such as a mood score next to its line.

Limits and costs to plan around

Be clear about what you are building on. The model is text only. There is no image, audio or video generation, no embeddings and no fine-tuning, so a character with a portrait or a voice needs other services alongside this one. The context window is 100,000 tokens, and a long roleplay will eventually exceed it, which is why the trimming and summary habits above matter.

Cost is small for chat. Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens from prepaid credit. Take a 40-turn scene where each request sends an average of 3,000 input tokens (the persona plus history) and gets about 250 tokens back. Input is 40 x 3,000 = 120,000 tokens, which costs $0.018. Output is 40 x 250 = 10,000 tokens, which costs $0.005. The whole scene is $0.023. Failed or refused requests are not charged. The pricing page has the top-up options and the bonus tiers, and the article on cost and trade-offs goes deeper on how history length drives the bill.

A full key allows 8 concurrent requests and 300 requests per minute. A streamed reply holds its concurrency slot until the stream ends, so if you run several characters for several users, a ninth simultaneous stream gets a 429 with the error code concurrency. Retry after a short pause.

Top-ups are by crypto (USDT on TRC20, USDC on Base) on this site: any whole amount from $20 to $500. New users can claim $0.50 of trial credit with one click on the key page after sign-up. It is valid for 7 days, one per person, and uses lower limits of 2 concurrent requests and 60 per minute. That is enough to try your character prompt through a few dozen exchanges. Create the key on the API key page and test the persona before you top up.

One last point about content. The model answers without content refusals for lawful adult use, and prompts are not used for training. Characters are for fiction, roleplay and companion apps for adults. Anything involving minors is off the table, and you should write that into your own app's rules as well.

Questions and answers

Can I make an unrestricted AI chatbot character without writing code?

Yes. Use a chat client that accepts a custom OpenAI-compatible endpoint, enter the base URL and your key, and set the model to uncensored. The character itself is just the persona text you put in the client's system prompt or character field.

Does the API remember my character between sessions?

No. The server keeps no conversation state. Your app stores the system prompt and the history and sends them again with each request.

How long can a character conversation get?

The context window is 100,000 tokens, counting the prompt and the reply together. Long stories should trim old turns or replace them with a short summary before they get near that size.

Can the character send images or speak aloud?

No. The service is text only, with no image, audio or video generation. You can pair the text output with other tools if your app needs those.

Are there content limits?

The model is tuned to answer without content refusals for lawful adult use. Sexual content involving minors is not allowed under any framing.

Your key is one form away

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