EN ▾
Get API key

Unfiltered AI Character Chat: Build One with an API

An unfiltered ai character chat is a small program wrapped around a chat API: a character definition, a message history, and a loop that streams replies. This guide builds one in Python, including memory that does not blow up your token bill, for adult fiction and companion apps.

Updated

Abstract masks above glowing chat bubbles, representing building an AI character chat with an API

What you are building

For an unfiltered ai character chat you need four parts: a character sheet (who the character is), a system prompt built from it, a history of the conversation, and a client that calls the API and prints the reply as it arrives. The model on this API is one open-weight model tuned to answer without content refusals for lawful adult use, so a well-written character is not interrupted by generic refusals.

This is for adults writing fiction, roleplay and companion-style apps. The service is text only, and sexual content involving minors is blocked, so your system prompt should state that every character is an adult. Keep what you build non-explicit in any shared or public demo.

You need an API key from the API key page. A trial credit of $0.50 is enough for a few hundred test messages.

Step 1: write the character sheet

Store the character as plain data, not as one long paragraph. It is easier to edit and to reuse across models.

{
  "name": "Mara Voss",
  "age": 34,
  "role": "Salvage pilot and reluctant leader",
  "voice": "Dry humour, short sentences, never lectures",
  "traits": ["loyal", "secretive about her past", "hates small talk"],
  "scenario": "A cargo ship drifting near an abandoned station. The user is a new crew member.",
  "rules": [
    "Stay in character and in the story.",
    "All characters are adults.",
    "Never speak or act for the user."
  ]
}

Good sheets are specific about voice and behaviour, and thin on backstory. Models follow "answers in two or three short sentences, avoids emotion words" far better than "has a complicated personality".

Step 2: turn it into a system prompt

The system prompt is rebuilt from the sheet at the start of each request. Put the stable, important rules at the top and the memory summary at the bottom, close to the conversation.

import json
from openai import OpenAI

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

sheet = json.load(open("mara.json"))

def system_prompt(sheet, summary=""):
    lines = [
        f"You are {sheet['name']}, {sheet['role']}.",
        f"Voice: {sheet['voice']}.",
        "Traits: " + ", ".join(sheet["traits"]) + ".",
        f"Scenario: {sheet['scenario']}",
        "Rules:",
        *[f"- {r}" for r in sheet["rules"]],
    ]
    if summary:
        lines += ["", "Story so far:", summary]
    return "\n".join(lines)

Step 3: history, memory and cost

Every request must include the history you want the character to remember, and you pay for those input tokens each time. A naive loop that sends everything gets slow and costly as the story grows. Use two tiers instead.

  • Recent window: the last 12 messages, verbatim.
  • Summary: a few sentences about everything older, updated when the window overflows.
history, summary = [], ""
WINDOW = 12

def fold_old_turns():
    global history, summary
    if len(history) <= WINDOW:
        return
    old, history = history[:-WINDOW], history[-WINDOW:]
    text = "\n".join(f"{m['role']}: {m['content']}" for m in old)
    r = client.chat.completions.create(
        model="uncensored",
        messages=[{"role": "user", "content":
            "Update this story summary in under 120 words. Keep names, "
            "promises and unresolved plot points.\n\nCurrent summary:\n"
            f"{summary}\n\nNew events:\n{text}"}],
        temperature=0.3,
    )
    summary = r.choices[0].message.content

Cost check: a 12-message window averaging 150 tokens each is 1,800 tokens, plus about 400 for the system prompt and summary, so around 2,200 input tokens. With a 250 token reply, one turn costs 2,200 x $0.15 / 1M = $0.00033 plus 250 x $0.50 / 1M = $0.000125, about $0.000455. A thousand turns cost about $0.46.

Step 4: the streaming chat loop

def chat_turn(user_text):
    history.append({"role": "user", "content": user_text})
    messages = [{"role": "system", "content": system_prompt(sheet, summary)}] + history
    stream = client.chat.completions.create(
        model="uncensored",
        messages=messages,
        stream=True,
        temperature=0.9,
        top_p=0.95,
        max_tokens=300,
    )
    reply = ""
    for chunk in stream:
        piece = chunk.choices[0].delta.content or ""
        reply += piece
        print(piece, end="", flush=True)
    print()
    history.append({"role": "assistant", "content": reply})
    fold_old_turns()

while True:
    chat_turn(input("you> "))

Streaming makes the character feel alive because the first words appear within moments. Streamed requests hold one of your concurrent slots until the stream ends (8 on a full key, 2 on a trial key), so close streams you abandon.

Tuning the character

  • Temperature 0.8 to 1.0 for lively dialogue; drop to 0.3 for the summary call, where accuracy matters.
  • Frequency and presence penalties (small values such as 0.3) reduce repeated phrases in long sessions. They are passed through to the model.
  • Stop sequences. If the character starts writing the user's lines, add a stop such as ["\nyou:"] matching your format.
  • Seed. A fixed seed helps you reproduce a bad reply while debugging.
  • Length. A line in the sheet like "replies in 2 to 4 sentences" controls both style and cost.

If the character drifts out of voice after many turns, repeat the two most important rules in a short final system message just before the latest user message. This is cheap and often enough.

Common problems and fixes

The character repeats itself

Long sessions fall into loops where each reply echoes the last. Raise the frequency penalty slightly, vary temperature between 0.8 and 1.0, and make sure the summary holds events, not the character's own catchphrases.

The character speaks for the user

Add the rule "Never write the user's actions or dialogue" to the sheet, and add a stop sequence that matches your user label. Check that the history roles are correct: user lines must use role: "user", not be pasted into an assistant message.

Replies get too long

Set max_tokens and also state the target length in the sheet. A hard cut at 300 tokens can end a reply mid-sentence, so the length instruction does most of the work and the cap is a safety net.

The summary loses important facts

List what must survive in the summary prompt: names, promises, injuries, locations and open questions. Keep the summary under a fixed word count so it cannot grow without bound.

Shipping it to users

For a web or bot front end, keep the API key on your server and let the client talk to your own endpoint. Store each user's history and summary yourself; the API does not keep conversations for you. Add a per-user message limit, since the full key allows 300 requests per minute and 8 at once, and a busy shared character can reach that quickly. On a 429 (rate_limited or concurrency), wait and retry.

Prompts are not used for training. Put an age gate and clear adult-use terms on anything public, and keep demos tame. More background is on the unfiltered AI chatbot overview and a list of options at unfiltered AI chat bots. Top-ups are $20 to $500, paid in crypto (USDT on TRC20 or USDC on Base); see the pricing page and the docs.

Questions and answers

Can the character remember things across sessions?

The API itself is stateless. Save the history and rolling summary in your own database and send them with each request.

How much does a character chat cost?

At $0.15 per 1M input and $0.50 per 1M output tokens, a typical turn with about 2,200 input and 250 output tokens costs around $0.00046.

Is there content the model will not write?

Yes. Sexual content involving minors is blocked with no exceptions, and the service is for lawful adult use only.

Which model name do I use?

Use uncensored as the model ID with the OpenAI SDK and this site's base URL.

Your key is one form away

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

Key points

  • A character chat is a system prompt plus history; the quality comes from how you write and maintain both.
  • Keep the last N turns verbatim and fold older ones into a short summary to hold memory cheaply.
  • Stream replies with stream: true so the character feels responsive.
  • For lawful adult use only; content involving minors is blocked with no exceptions.

Start with trial credit

Email and password, key on screen right away.