LLM System Prompt for Roleplay: Templates and Pitfalls
A good llm system prompt for roleplay names the character, the setting, the voice and the rules of the scene in a few short paragraphs, and then stays out of the way. Below are three templates, the cost of long prompts, and fixes for personas that drift.
- Cover five things: who the character is, the setting, voice, boundaries and reply format.
- Short, concrete prompts hold a persona better than long lists of adjectives.
- A resent system prompt costs a tiny amount per turn but adds up; measure it.
- Re-anchor the character every few dozen turns so a long chat does not drift.

Key points
What the system prompt does in a roleplay chat
In an OpenAI-style chat request, the system message is the first item in the messages list. It tells the model how to behave for the whole conversation. In roleplay it carries the character sheet, the world and the ground rules. The user messages then carry the story itself.
The model has no memory between calls. Your app resends the system prompt and the recent messages on every turn, so the prompt shapes each reply. That is useful, because you can change the persona by editing one string, and costly, because the prompt is billed as input tokens on every request.
This guide covers lawful adult fiction and companion-style chat. The service has a hard limit: no sexual content involving minors, and characters must be adults. Nothing in a template should work around that rule.
The five parts of a prompt that works
- Identity. Name, role and two or three defining traits. "Captain Rhea Voss, a dry-witted smuggler who hides how much she cares" says more than a list of ten adjectives.
- Setting. Where and when the scene happens, in a sentence or two. Add only what the model must keep consistent.
- Voice. How the character speaks: short or long sentences, slang, formality, verbal habits. One example line helps a lot.
- Boundaries. What the model should not do: speak for the user, jump ahead in the plot, break character to lecture.
- Format. Length of replies, whether to use actions in asterisks, whether to end on a prompt for the user.
Write in the second person ("You are...") for the character, and use plain declarative sentences. Models follow clear instructions more reliably than atmospheric prose.
Three templates you can adapt
Template 1: adventure narrator
You are the narrator of a fantasy adventure. The user plays Ilan, a young cartographer.
Setting: the salt-road cities, where maps are traded like currency.
Style: vivid but brief. Write 2 to 4 short paragraphs per reply.
Rules: never decide Ilan's actions or words. End each reply with a moment that invites a choice.
Keep track of names, injuries and items that appear.
Template 2: single character
You are Mara, a 34-year-old night-shift pharmacist. You are warm, a little sarcastic and tired.
You talk in short sentences and use "well" and "anyway" often.
Stay in character at all times. Do not describe the user's actions or thoughts.
Reply in 1 to 3 sentences unless asked for more.
Template 3: companion with memory notes
You are Theo, an easygoing companion who likes dry jokes and old films.
Known facts about the user (update when they change):
- Name: Sam. Works as a bike courier. Dislikes mornings.
Be supportive but honest. If Sam asks for something you cannot or should not do, say so plainly and in character.
Do not claim to be human if sincerely asked.
The block of known facts in the third template is how long-term memory is done in practice: your app keeps a short list and inserts it into the system prompt. These are plain text files, nothing exotic; copy them into your own system message and edit the details. Change names and traits first, since a template used unchanged gives the same flat result as everyone else's.
Sending the prompt through the API
Here is how a template goes into a request to the endpoint on this site, with the model ID uncensored:
from openai import OpenAI
import os
client = OpenAI(base_url="https://api.nsfwllm.cc/v1",
api_key=os.environ["NSFW_API_KEY"])
SYSTEM = open("mara.txt").read()
history = [{"role": "system", "content": SYSTEM}]
def turn(text):
history.append({"role": "user", "content": text})
r = client.chat.completions.create(
model="uncensored",
messages=history,
temperature=0.9,
top_p=0.95,
)
reply = r.choices[0].message.content
history.append({"role": "assistant", "content": reply})
return reply
print(turn("Rough night?"))
Roleplay usually likes a higher temperature than factual tasks. Values around 0.8 to 1.0 give varied dialogue; drop it if the character starts wandering. The service runs one open-weight model tuned to answer without content refusals for lawful adult use, so the scene is shaped by your prompt rather than by a built-in filter. It is not an official product of any model vendor. For background on the model family, see the Dolphin LLM myths versus facts article, and read the docs for all request fields.
What a long prompt costs
The system prompt is input, billed at $0.15 per 1M tokens. A rich 800 token character sheet costs 800 / 1,000,000 x $0.15 = $0.00012 per request. Over 1,000 turns that is $0.12. A 3,000 token world bible costs $0.00045 per request, or $0.45 per 1,000 turns.
Output is $0.50 per 1M tokens. A 250 token reply costs $0.000125. So a turn with an 800 token prompt, 1,200 tokens of recent history and a 250 token reply costs:
- Input: 2,000 tokens = $0.0003
- Output: 250 tokens = $0.000125
- Total: $0.000425, so 1,000 turns cost $0.425
The prompt is not the main expense; the growing history is. Still, trim anything the scene does not need. Failed or refused requests are not charged, and credit never expires. Top-ups are crypto only (USDT on TRC20 or USDC on Base), from $20 to $500, with +5% from $50, +10% from $100 and +15% from $200. See pricing for details.
Keeping the persona steady in long chats
The most common complaint is drift: after a few hundred messages the character turns generic, forgets a rule or repeats itself. Causes and fixes:
- The system prompt got trimmed. When you cut old messages, always keep the first message. A trim function should keep index 0 and drop from the middle.
- The model copies its own pattern. If every reply starts the same way, later replies do too. Add a line such as "vary how you open each reply", and use the repetition-related penalties, which are passed through.
- Rules are buried. Put the two or three rules that matter most at the end of the system prompt, and repeat a short reminder as a system message every 20 or 30 turns.
- The history is too long. The window is 100,000 tokens for prompt plus completion. You will rarely hit it in roleplay, but quality often improves when you summarize old events into a few lines.
A summary can be produced by the same endpoint: send the old turns with an instruction to write a short recap, then store the recap in the system prompt.
Pitfalls to avoid
- Writing the user's lines. If the model speaks for the user, add an explicit rule and keep replies short enough that it has no room to.
- Contradictions. "Shy but outspoken" confuses a model. Pick one trait and show the other in a specific situation.
- Huge lists of forbidden topics. Long no-lists tend to put the forbidden idea in the model's attention. State what the character does instead.
- Hidden age ambiguity. Always state that characters are adults. Content involving minors is never allowed on this service.
- Testing in one long chat. Test a prompt over ten fresh starts, not one continued thread, to see how stable it really is.
Pick a first prompt, run it from the API key page with the $0.50 trial credit (one click after sign-up, valid for 7 days, no payment needed), and adjust from what you see. The open-source model API page describes what kind of model you are talking to.
More guides
Questions and answers
How long should a roleplay system prompt be?
Usually 150 to 500 tokens is enough for one character. Add detail only where the model keeps getting something wrong.
Does a long system prompt make replies slower or more expensive?
It adds input tokens to every request. At $0.15 per 1M tokens, an 800 token prompt costs $0.00012 per turn.
Why does my character forget its personality?
Usually the system message was trimmed away or buried by history. Keep it as the first message and repeat a short reminder periodically.
Are there content rules?
The model answers without content refusals for lawful adult use. Sexual content involving minors is never allowed.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.