EN ▾

Uncensored LLM API for Developersnsfwroleplay.cc

Get API key
uncensored https://api.nsfwroleplay.cc/v1

How to Prompt LLM for Roleplay: System Prompts That Work

Learning how to prompt llm for roleplay comes down to three things: a stable system prompt, a compact character sheet, and a plan for what history to keep. This page gives templates and code for each.

Updated

Puppet theatre with character marionettes and looping speech bubbles, illustrating prompting for roleplay
Isometric illustration of coins feeding a terminal with flowing data, representing low per-token API cost
per 1M input tokens
$0.15
Output tokens / 1M
$0.50
token context
100,000
trial credit
$0.50
requests per minute
300

Key points

  1. Put rules and the persona in the system message; keep the scene state in the conversation.
  2. Describe how the character speaks with examples, not adjectives.
  3. Trim old turns on a schedule and keep a short running summary of facts.
  4. Use temperature 0.8 to 1.0 and light penalties for lively, non-repeating replies.

Step 1: write the system prompt

The system message is the one part of the prompt that stays fixed for the whole session. Use it for rules that never change: who the model plays, who it never plays, the format of replies and the content limits of your app. Keep it under about 400 words so it does not crowd out the story.

A working skeleton has five blocks:

  1. Role. "You play Mira, a smuggler pilot, in an ongoing story with the user."
  2. Style. Person, tense, reply length. "Third person, past tense, 120 to 220 words per reply."
  3. Boundaries of play. "Never write the user character's actions or speech. End each reply on a moment the user can respond to."
  4. Consistency rules. "Keep facts from the character sheet and the summary. If unsure, stay vague rather than invent."
  5. App limits. "All characters are adults. Content stays within lawful adult fiction."

The model used here is tuned to answer without content refusals for lawful adult use, so the system prompt does not need elaborate jailbreak text. Plain instructions work better and cost fewer tokens. Sexual content involving minors is never allowed, so state in your own app rules that all characters are adults.

Step 2: build the character sheet

A character sheet is the data the model reads every turn. Keep it short and concrete. Long backstories dilute the details that actually shape replies.

Name: Mira Vance
Role: freelance smuggler pilot, 34
Voice: dry, clipped, swears mildly, never explains jokes
Wants: pay off a debt to the Orlek syndicate
Fears: being owned by anyone
Habit: taps the dashboard twice before every jump
Example lines:
"Sit down. Touch nothing red."
"I don't do favors. I do invoices."

The example lines are the strongest part. Models imitate sample dialogue more reliably than a list like "sarcastic, guarded, loyal". Two to four lines are enough. If you have several characters, give each a separate block with its own examples, and label who is speaking in the history.

Scene setup belongs next to the sheet: place, time, what just happened, what the user character knows. Update it when the story moves. The guide to detailed roleplay responses shows how to ask for longer descriptive replies on top of this base.

Step 3: send it through the API

The endpoint is OpenAI-compatible, so the official SDK works. Get a key on the API key page.

from openai import OpenAI

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

SYSTEM = open("system.txt").read() + "\n\n" + open("mira_sheet.txt").read()
history = []  # list of {"role": ..., "content": ...}

def turn(user_text, summary=""):
    history.append({"role": "user", "content": user_text})
    messages = [{"role": "system", "content": SYSTEM}]
    if summary:
        messages.append({"role": "system", "content": "Story so far: " + summary})
    messages += history[-20:]
    r = client.chat.completions.create(
        model="uncensored",
        messages=messages,
        temperature=0.9,
        top_p=0.95,
        frequency_penalty=0.3,
        presence_penalty=0.2,
        stream=False,
    )
    reply = r.choices[0].message.content
    history.append({"role": "assistant", "content": reply})
    return reply

print(turn("I step into the cockpit. 'You're late,' I say."))

Streaming is a one-line change (stream=True) and lets users read as the text arrives. The full list of fields is in the API docs.

Settings: what each one does to a scene

SettingRange to tryEffect in roleplay
temperature0.8 to 1.0Lower is steadier and safer; higher gives surprising turns but more drift
top_p0.9 to 0.95Cuts the least likely words; adjust this or temperature, not both at once
frequency_penalty0.2 to 0.5Fewer repeated words and stock phrases
presence_penalty0.1 to 0.4Pushes toward new topics and details
max_tokensoptionalCaps reply length if the model rambles
stopfor example the user's name followed by a colonStops the model from writing the user's lines

Change one setting at a time and replay the same three user messages. Compare results before moving on. If replies start to loop, raise the frequency penalty slightly before touching temperature.

Step 4: manage history and memory

The model does not remember anything between calls. Every request must carry what it needs. The context window is 100,000 tokens for prompt plus reply, which is large, but cost and focus both improve if you do not send everything.

Sliding window plus summary

Keep the system prompt and sheet, the last 15 to 25 messages, and a running summary of earlier events written as short facts: names, promises, injuries, locations, what each character knows. Every 20 turns, ask the model to update the summary in 150 words or less, then drop the old turns it covers.

When to keep everything

For stories under about 30,000 tokens, sending the full history is simple and loses nothing. At $0.15 per 1M input tokens, a 6,000-token window costs 6,000 / 1,000,000 x $0.15 = $0.0009 per turn in input. See the pricing page for output rates and top-ups.

Pin the important facts

Facts the user cares about, like a character's secret or an oath, should live in the summary or sheet, not only deep in the history. Facts in the middle of a very long prompt are the easiest to lose.

Narrator mode and multiple characters

One persona is the simplest setup. Many stories need more: a narrator, a group of companions, a rival. There are two ways to handle that.

Narrator style. The model plays the world and every non-user character. The system prompt says "You are the narrator. Describe the scene, voice every character except the user, and keep each character's speech distinct." Put each character's sheet in a labeled block. This is easier to run and gives richer scenes, but characters can blur together if sheets are weak.

One call per character. Each character has its own system prompt and sees the shared scene log. Your code decides who speaks next. It costs more calls and needs more code, but voices stay clean. It also lets you use different temperatures: 1.0 for a chaotic trickster, 0.7 for a careful advisor.

Whichever you choose, tag every line in the history with the speaker, for example "Mira: ...". Untagged text invites confusion about who said what. A short example of the first turn in the prompt shows the tagging format better than any rule.

Test the setup with a stress scene: put three characters in a room with conflicting goals and let the user say little. If two of them start to sound alike within five turns, strengthen their example lines before changing anything else.

Troubleshooting common failures

  • The model speaks for the user. Add the explicit rule and a stop sequence. Also end your own messages with a clear action or line, so the model has a natural handoff.
  • Every reply has the same shape. Raise the frequency penalty, vary your inputs, and add a rule such as "Do not begin two replies in a row with the same word".
  • The character becomes generic. Re-add example lines to the sheet and shorten the system prompt. Generic speech often means the voice section got buried.
  • Facts contradict earlier turns. Update the summary more often and pin the contradicting fact.
  • Errors or 429 responses. Check the troubleshooting page. The codes rate_limited and concurrency mean you sent too many requests per minute or at once; wait and retry.

A final habit: save every session's system prompt and settings with the transcript. When a story goes well, you can reproduce the conditions.

Questions and answers

Should instructions go in the system message or the user message?

Put fixed rules and the persona in the system message. Put the current scene action in the user message. Use a second system message for the running summary.

What temperature is best for roleplay?

Start at 0.9 with top_p around 0.95 and light penalties. Lower it if the story drifts, raise it slightly if replies feel flat.

How long can a roleplay session be?

The window is 100,000 tokens for prompt plus reply. Beyond that, summarize older turns and keep key facts pinned.

Do I need a special jailbreak prompt?

No. The model is tuned to answer lawful adult fiction without content refusals, so plain role and style instructions are enough.

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.