EN ▾
Get API key

Build an Unfiltered Roleplay Prompt Generator

Updated

A roleplay prompt generator turns a one-line idea into a full character card, a scene and an opening message. Here is how to build one yourself on top of an OpenAI-compatible endpoint.

What the generator does

An unfiltered roleplay prompt generator is a small program that takes a seed such as "a disgraced court magician hiding in a harbor town" and returns the pieces a roleplay or story app needs: a name, a voice, a backstory, rules for how the character behaves, and a first message. You can use the output as a system prompt, paste it into a character card field, or store it in a database.

The word unfiltered matters for one practical reason. Many hosted assistants soften or refuse dark themes in fiction, such as war, crime, grief, horror or morally grey villains, even when the request is plainly a story. The model behind this API is open-weight, run by an independent provider, and tuned to answer without content refusals for lawful adult use, so the generator keeps working when the premise gets heavy. The hard limit still applies: no sexual content involving minors, and your prompts should never ask for it.

You will build three steps: generate a card, generate an opening scene, and use the result as the system prompt in a chat loop. The whole thing is about sixty lines of Python.

Setup in two minutes

Create an account on the key page and claim the $0.50 trial credit with one click. It needs no card, it is valid for 7 days, and it is far more than this project will use. Then install the SDK:

pip install openai

The client needs only the base URL, your key and the model ID:

from openai import OpenAI

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

If you would rather use Node or plain curl, the documentation has the same call in those forms.

Step 1: generate a character card as JSON

Free-form text is hard to reuse, so ask for JSON. The API supports JSON mode through response_format. Put the schema in the system message, since the model follows an explicit shape better than a loose request.

import json

CARD_SYSTEM = '''You design characters for adult interactive fiction.
Return one JSON object with these keys:
name, age (adult, 21 or older), role, voice (how they speak, 2 sentences),
backstory (4 sentences), goals (list of 3), flaws (list of 2),
rules (list of 4 short behaviour rules for the roleplay), setting.
Output JSON only.'''

def make_card(premise, temperature=0.9):
    r = client.chat.completions.create(
        model=MODEL,
        temperature=temperature,
        response_format={"type": "json_object"},
        messages=[
            {"role": "system", "content": CARD_SYSTEM},
            {"role": "user", "content": premise},
        ],
    )
    return json.loads(r.choices[0].message.content)

card = make_card("a disgraced court magician hiding in a harbor town")
print(json.dumps(card, indent=2))

Notice the age line in the schema. Requiring an adult age in the template is a cheap, explicit guard, and it keeps your generator on the right side of the one rule that cannot be bent. Add a check in code too: reject any card whose age is missing or below 21 and regenerate.

A temperature of 0.9 gives varied cards. Lower it to 0.5 when you want consistent structure, and raise it toward 1.1 if every result feels alike. You can also pass a seed to repeat a good result.

Step 2: write the opening scene in the character's voice

The card is data. The opening message is what a player reads first, so it deserves its own call with the card as context:

def opening(card, player_hint="a stranger asking for a favor"):
    persona = (
        f"You are {card['name']}, {card['role']}. Voice: {card['voice']} "
        f"Backstory: {card['backstory']} Setting: {card['setting']}. "
        "Rules: " + " ".join(card["rules"])
    )
    r = client.chat.completions.create(
        model=MODEL,
        temperature=0.85,
        max_tokens=250,
        messages=[
            {"role": "system", "content": persona},
            {"role": "user", "content": f"Open the scene. The player is {player_hint}. "
                                        "Write 2 short paragraphs, stay in character, end on a hook."},
        ],
    )
    return r.choices[0].message.content

print(opening(card))

The persona string is also your reusable system prompt. Store it next to the JSON, and any later chat call can start with it.

Step 3: run the roleplay loop

A basic loop keeps the message list and appends each turn. Streaming makes it feel alive, so use stream=True and print chunks as they arrive:

def chat(persona, first_message):
    history = [
        {"role": "system", "content": persona},
        {"role": "assistant", "content": first_message},
    ]
    while True:
        user = input("> ")
        if user in ("quit", "exit"):
            break
        history.append({"role": "user", "content": user})
        stream = client.chat.completions.create(
            model=MODEL, messages=history, stream=True, temperature=0.85,
        )
        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)
        print()
        history.append({"role": "assistant", "content": reply})

The context window is 100,000 tokens for prompt plus reply, which is plenty for a long session. Once the history gets large, keep the system prompt and the last dozen or so messages, and fold older turns into a two-line summary. This also keeps cost down.

Prompt tricks that improve the output

  • Give behaviour rules, not adjectives. "Never reveals the vault location unless bribed" produces better play than "mysterious".
  • Ask for flaws. A character with two concrete flaws creates conflict without your help.
  • Fix the point of view. Add "write in second person, present tense" or "third person, past tense" to the rules list.
  • Add a length rule. "Replies are 80 to 150 words" prevents essays on every turn.
  • Use stop. If the model tends to write the player's lines too, add a stop sequence such as the player's name followed by a colon.
  • Generate several and pick. Call make_card five times with different seeds and keep the best one.

Tool calling for game state

If your project tracks inventory, health or relationship scores, the API supports tool calling: you define functions in tools, the model returns tool_calls, and you send results back as role: "tool" messages. That lets the character update state without brittle text parsing.

Validate, store and reuse the cards

Generated JSON is not always clean. A small wrapper that checks the fields and retries once will save you from bad cards later:

REQUIRED = ["name", "age", "role", "voice", "backstory", "goals", "flaws", "rules", "setting"]

def safe_card(premise, tries=3):
    for _ in range(tries):
        try:
            card = make_card(premise)
        except Exception:
            continue
        if all(k in card for k in REQUIRED) and isinstance(card["age"], int) and card["age"] >= 21:
            return card
    raise RuntimeError("no valid card after retries")

import pathlib
cards = [safe_card(p) for p in [
    "a retired bounty hunter running a noodle bar",
    "an exiled queen training sellswords",
]]
pathlib.Path("cards.json").write_text(json.dumps(cards, indent=2))

Failed or refused requests are not charged, so a retry that returns nothing usable costs you nothing on that attempt. When a call does succeed but the JSON is wrong, you pay for it, which is why the retry count is capped at three.

Once you have a file of cards, you can build on it. A small web page can list them, a Discord bot can load one as its persona, and a story tool can use the setting field to seed a world. Keep the prompt that made each card in the file as well, so you can regenerate with a different temperature later without guessing what you asked.

Varying the generator

The same pattern fits other creative helpers. Swap the schema and you have a villain generator with motives and weaknesses, a tavern rumor table, a faction sheet for a tabletop campaign, or a set of ten scene hooks for a writing prompt. In each case the steps stay the same: define the keys, request JSON, validate, store. The model does not need special flags for darker subject matter, which is the main reason to run this kind of tool against an endpoint that does not refuse lawful adult fiction.

What it costs to run

A card call might send 250 input tokens and return 450 output tokens. The math is 250 x $0.15 / 1,000,000 = $0.0000375 for input, plus 450 x $0.50 / 1,000,000 = $0.000225 for output, so $0.0002625 in total. An opening scene with a 600 token persona prompt and 250 output tokens comes to $0.00009 + $0.000125 = $0.000215. A complete card with its opening costs $0.0004775, so 100 of them cost $0.04775, under five cents.

The $0.50 trial easily covers hundreds of experiments. Past that, top-ups start at $20 and are paid in USDT on TRC20 or USDC on Base. See the pricing page for the bonus tiers.

Keep the rate limits in mind if you generate in bulk: a trial key allows 2 concurrent requests and 60 per minute, a funded key 8 and 300. On a 429, read the error code, wait, and retry. Prompts are not used for training, and failed or refused requests are not billed.

Questions and answers

Can the generator write dark or violent fiction?

The model is tuned to answer without content refusals for lawful adult use, so mature themes in fiction are fine. Sexual content involving minors is never allowed.

Do I need to host anything myself?

No. The script runs on your machine and calls the hosted API. You only need a key and the OpenAI SDK.

Why use JSON mode for character cards?

It returns a valid JSON object you can parse and store, so you can feed the fields into other prompts without cleaning up text.

How long can a roleplay session be?

The context window is 100,000 tokens, prompt plus reply. For very long sessions, summarize old turns to save cost.

Your key is one form away

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

Start with trial credit

Email and password, key on screen right away.

Stage with floating masks and glowing cards produced by a machine, symbolising a roleplay character generator