EN ▾
Get API key

System Prompt for Roleplay: Structure and Examples

A good system prompt for roleplay states who the character is, how they speak, what the scene is and what the model must not do. Here is a layout that holds up over long chats, with API code.

Updated

A small stage with masks and a glowing scroll, illustrating a system prompt that defines a roleplay character

Key points

  1. Split the prompt into role, voice, scene, rules and format, and keep each part short.
  2. Show a sample line of dialogue instead of describing the voice in adjectives.
  3. Pin facts in the system message and trim or summarize the old chat around them.
  4. Use temperature and a repeat penalty to tune variety, and test with a fixed seed.

What the system message does

The best system prompt for roleplay is not the longest one. It is the one that gives the model a stable answer to four questions: who am I playing, how do I talk, where are we and what are the ground rules. The system message is the first message in the list you send, and the model treats it as standing instructions that apply to the whole conversation. Your later messages are the scene itself.

The API follows the OpenAI chat format, so the system message is an ordinary object with role set to system. The model ID is uncensored. It is an open-weight model that answers without content refusals for lawful adult use, which means a plain, direct prompt works better than the long defensive preambles people write for filtered models. You do not need to argue the model into staying in character. You need to describe the character clearly.

One rule is fixed and no prompt changes it: the model never produces sexual content involving minors. Any character in your setup should be an adult, and it helps to say so in plain words, such as giving an age in the character description.

A five-part layout

Prompts that stay consistent over hundreds of messages tend to share a shape. Use short labeled blocks, one idea per block.

  1. Role. One or two sentences: name, age, occupation, relationship to the user.
  2. Voice. How the character speaks, plus a sample line.
  3. Scene. Place, time, what just happened, what the character wants.
  4. Rules. Point of view, length, what to avoid, who controls whom.
  5. Format. How actions, thoughts and speech are marked.

Here is a complete example for a fantasy tavern scene.

You are Mara Venn, a 34-year-old innkeeper in the river town of Holloway. You are dry, observant and quietly protective of regulars. You speak in short sentences and avoid long speeches. Sample line: "Sit. You look like you walked here from the coast. Soup is still hot."

Scene: a stormy evening. The user plays a traveler who arrived an hour ago and has not said where they are headed. You suspect they are running from something, but you will not pry directly.

Rules: write in third person, past tense, 120 to 220 words per reply. Never write the user's actions, words or thoughts. Stay in character. End each reply on a moment the user can respond to.

Format: actions in plain prose, spoken lines in double quotes.

That is under 200 words and covers everything the model needs. Notice how the voice is shown with a line of dialogue. The model copies a sample far more reliably than it follows an adjective list such as "witty, mysterious, warm".

Rules that prevent the most common failures

Roleplay fails in predictable ways. Each one has a short fix you can put in the rules block.

The model speaks for you

If the reply keeps writing your character's reactions, say it directly: "Never write the user's actions, words, feelings or decisions." Say it once, in the rules. Repeating it five times makes the instruction louder than the character.

Replies grow or shrink

Give a range such as 100 to 200 words. Models drift toward whatever length the recent messages had, so a clear number holds it steady. If you also set max_tokens, make it comfortably above your word range, since cutting a reply mid-sentence looks worse than a long one.

The character becomes generic

When every reply starts to sound like a helpful assistant, the voice block is too thin. Add two more sample lines in different moods, one calm and one angry. Add a verbal habit too, for example a favorite phrase or a way of changing the subject.

The story stalls

Tell the model that the character has goals and acts on them: "Mara wants to learn the traveler's name by the end of the night, and nudges the conversation that way." A character with a want pushes the scene. A character with only a description waits for you to do something.

Repeated phrases

Open-weight models can fall into loops of stock phrases. Raise the frequency or presence penalty slightly, and edit the earlier replies that contain the phrase, since the model imitates its own history.

Sending it through the API

Put the system prompt in the first message and send the whole history on every call. The endpoint is POST /v1/chat/completions and sampling parameters pass through.

from openai import OpenAI

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

SYSTEM = (
    "You are Mara Venn, a 34-year-old innkeeper in the river town of Holloway.\n"
    "Voice: dry, observant, short sentences. Sample line: 'Sit. Soup is still hot.'\n"
    "Scene: a stormy evening; the user plays a traveler who arrived an hour ago.\n"
    "Rules: third person, past tense, 120 to 220 words. Never write the user's actions or words.\n"
    "Format: actions in plain prose, speech in double quotes."
)

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

def turn(user_text):
    history.append({"role": "user", "content": user_text})
    r = client.chat.completions.create(
        model="uncensored",
        messages=history,
        temperature=0.85,
        top_p=0.95,
        frequency_penalty=0.3,
        presence_penalty=0.2,
    )
    reply = r.choices[0].message.content
    history.append({"role": "assistant", "content": reply})
    return reply

print(turn("I shake the rain off my coat and ask if there is a free room."))

For a live feel, add stream=True and print chunks as they arrive. Streaming uses server-sent events, and usage comes at the end. The quickstart docs show the streaming loop. Chat frontends that accept an OpenAI-compatible endpoint can use the same prompt: paste it into the system or character field, set the base URL to https://api.nsfwroleplay.top/v1, and choose uncensored as the model.

Sampling settings for roleplay

Settings change how the same prompt feels. These starting points suit most character chats:

SettingStarting valueEffect
temperature0.8 to 0.9Higher gives more surprising lines, lower keeps the character on rails.
top_p0.9 to 0.95Trims unlikely words without flattening the style.
frequency_penalty0.2 to 0.4Discourages repeating the same words.
presence_penalty0.1 to 0.3Nudges toward new topics.
seedfixed while testingMakes comparisons between prompt versions fair.

Change one value at a time. To compare two versions of a prompt, fix seed and temperature, run the same three user messages through both, and read the results side by side. Without a fixed seed, the difference you see may only be luck.

Memory in long sessions

The context window is 100,000 tokens for prompt and completion together, so a long session fits a lot, but not everything. The cost of a long chat also grows because the history is resent every time. Suppose a session has a 600-token system prompt and has reached a history of 30,000 tokens. One more turn sends 30,600 tokens in and gets 300 back. That costs 0.0306 x $0.15 + 0.0003 x $0.50 = $0.00459 + $0.00015 = $0.00474, about half a cent. Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, and failed or refused requests are not charged.

Half a cent is small, but it repeats every turn. A practical routine keeps the cost and the drift down:

  • Keep the system prompt as the permanent anchor. Never trim it.
  • Every 20 to 30 turns, ask the model to write a summary of what has happened: names, promises made, injuries, locations. Insert it as a second system message or at the top of the history.
  • Drop the messages the summary replaced and keep the last 10 or so verbatim.
  • Store key facts in a small "story so far" list that you edit by hand when the model gets something wrong.

This works for companion apps too, where the character should remember the user's preferences. Store those in your own database and inject them into the system message at the start of each session, since the model keeps no memory between requests.

Where to try it

New accounts can claim $0.50 of trial credit with one click on the API key page. It is one per person, valid for 7 days, and needs no payment details. A trial key allows 2 concurrent requests and 60 requests per minute, which suits testing a single chat. A full key allows 8 concurrent requests and 300 requests per minute. Streams hold a slot until they end, so close abandoned ones.

Top-ups run from $20 to $500 in whole amounts, with +5% from $50, +10% from $100 and +15% from $200. Payment is crypto only, USDT on TRC20 or USDC on Base, and credit never expires. See the pricing page. For a general look at the service and how it relates to other hosted options, the hosted API overview is a good next page. Prompts are not used for training.

Questions and answers

How long should a roleplay system prompt be?

Most work well at 150 to 400 words. Short labeled blocks for role, voice, scene, rules and format beat one long paragraph.

Should I tell the model it is uncensored?

There is no need. The model is already tuned to answer without content refusals for lawful adult use, so describe the character and the scene directly.

Why does the character forget details?

The model sees only what you send each time. Keep facts in the system message, summarize old turns and resend the summary.

Can I use the same prompt in a chat frontend?

Yes. Any frontend that accepts an OpenAI-compatible endpoint can use it. Set the base URL, add your key, choose the model ID uncensored and paste the prompt into the system field.

Are there content limits?

One rule is fixed: no sexual content involving minors. Characters should be adults. Beyond that, the service is meant for lawful adult use.

Your key is one form away

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

Get API keyRead the docs