DeepSeek Roleplay Prompt Setup for API Users
A good DeepSeek roleplay prompt is a short system message with a clear persona, a scene, and a few style rules, plus sampler settings that keep the voice stable. This guide shows the structure and the API code.
Updated
Key points
- Split the system prompt into role, persona, scene and style rules, and keep each part short.
- Use a temperature of about 0.8 to 1.0 for lively dialogue and a mild repetition penalty for long sessions.
- Send the persona every request, trim old turns, and store a short running summary.
- The model here is an independent open-weight model without content refusals, not DeepSeek's official API; the minors rule is absolute.


The structure that works
People who search for a deepseek roleplay prompt usually want a template they can paste. A template is fine, but the structure matters more than the exact words. Split the system message into four labelled blocks, each doing one job.
ROLE
You are the narrator and the character Mira in an ongoing fiction between adults.
PERSONA
Mira is a sharp-tongued ship mechanic in her thirties. Dry humour, hates small talk,
loyal once trusted. She speaks in short sentences and swears mildly.
SCENE
A cargo ship stalled in a dust storm. Mira and the user's character are repairing the engine.
STYLE
Write in third person past tense. 80 to 150 words per reply. End on a moment the user
can respond to. Never speak or act for the user's character.
Notice what is missing: long lists of adjectives, and rules like "be creative". Concrete habits (short sentences, mild swearing, no acting for the user) change the output. Vague praise does not. This site serves an OpenAI-compatible endpoint with the model uncensored, an open-weight model from an independent provider. It is not the official DeepSeek API, so a template built here carries over to any chat model, though results will vary by model.
Sending it through the API
Put the blocks in the system message and the conversation after it. Here is a working Python example.
from openai import OpenAI
client = OpenAI(base_url="https://api.deepseeknsfw.com/v1", api_key="YOUR_KEY")
SYSTEM = open("mira_system.txt").read()
history = []
def turn(user_text):
history.append({"role": "user", "content": user_text})
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "system", "content": SYSTEM}] + history[-24:],
temperature=0.9,
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("The engine coughs and dies again. What do you see?"))
The system message is resent on each request, since the API keeps no memory of earlier calls. Cutting the history to the last 24 messages controls cost and prevents the story from drowning the persona. The base URL, key and model name are all you change from any OpenAI-style client. The docs list every parameter that is passed through.
Sampler settings and what they change
Roleplay wants variety without nonsense. These starting values suit most stories; adjust one at a time.
| Setting | Start at | Effect |
|---|---|---|
temperature | 0.8 to 1.0 | Higher gives livelier word choice; above 1.1 replies can drift |
top_p | 0.9 to 0.95 | Trims unlikely words; lower it if the voice gets odd |
frequency_penalty | 0.2 to 0.4 | Reduces repeated phrases in long sessions |
presence_penalty | 0.0 to 0.3 | Nudges the story toward new topics |
stop | ["\nUser:"] | Ends the reply before it writes the user's lines |
seed | fixed number | Makes A/B tests of two prompts comparable |
If replies start looping ("she smiled, she smiled"), raise the frequency penalty by 0.1 before touching anything else. If the character forgets its voice, the fix is usually in the prompt, not in the sampler.
Keep long sessions coherent
A 100,000-token window is large, but filling it is slow and expensive, and attention to early details fades. A cleaner pattern is a running summary.
- Keep the last 10 to 20 turns verbatim.
- Every 20 turns, ask the model to summarise the earlier events in 150 words: who knows what, where everyone is, open threads.
- Insert that summary as a second system message after the persona.
- Drop the turns the summary covers.
def summarise(old_turns):
text = "\n".join(f"{m['role']}: {m['content']}" for m in old_turns)
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise these events in 150 words. Facts only: who knows what, locations, open threads.\n\n" + text}],
temperature=0.2,
)
return r.choices[0].message.content
Use a low temperature for summaries so details stay accurate. Store the summary with the session so a reload does not erase the story.
What to expect without refusals
The model behind this API is tuned to answer without content refusals for lawful adult use. In practice that means a fiction with dark themes, villains, morally grey choices and mature drama will continue instead of stopping with a disclaimer. You still control the tone through the prompt. If you want a story to stay light, say so in the style block, because the model follows what you write and does not guess.
Keep your content professional and legal. Roleplay here is for adults, and there is one hard limit: no sexual content involving minors. Do not set up personas that are minors in any romantic or sexual context, and add an age statement to your own app's terms. No prompt changes that rule.
It also helps to write what the model should refuse to do on your behalf, such as controlling the user's character, summarising the story mid-scene or breaking the fourth wall with out-of-character notes. These style rules do more for quality than permissions do.
Common prompt mistakes
After a few dozen sessions, the same problems come up. Most have a cheap fix in the prompt.
- The character speaks for the user. Add one line: "Never write the user's words, thoughts or actions", and set a
stopsequence on the user's name tag. - Every reply is the same length. Give a range instead of a number, such as "40 to 150 words", and allow short answers when the moment is quiet.
- The persona turns generic after 30 turns. Your persona block is probably too abstract. Replace traits like "confident" with habits: how the character greets, what she refuses to discuss, what she does with her hands.
- The scene never moves. Add a pacing rule: "Introduce one new detail or complication every two replies."
- Out-of-character notes appear. State that the narrator stays in the fiction, and use a separate channel in your app for rules and meta questions.
Group scenes
For several characters, name each in the persona block with one line of voice. Ask the narrator to tag speakers with the character name at the start of each paragraph, then parse that tag in your front end to colour the lines. Keep the cast to three or four, since every extra voice dilutes the others.
Test changes with a fixed seed and the same three opening messages. If a new prompt gives better replies across all three, keep it. If it helps one and hurts two, revert.
Cost and limits for a long story
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. A roleplay turn with an 800-token system prompt, 2,200 tokens of history and a 120-token user message sends about 3,120 input tokens. The reply is 200 tokens.
Input: 3,120 / 1,000,000 x $0.15 = $0.000468. Output: 200 / 1,000,000 x $0.50 = $0.0001. One turn costs $0.000568, so 1,000 turns cost about $0.57. A $20 top-up funds roughly 35,000 turns at that size. Credit never expires, and failed or refused requests are not charged.
This site accepts crypto only (USDT on TRC20 or USDC on Base), with top-ups from $20 to $500 and bonuses of +5% from $50, +10% from $100 and +15% from $200. The pricing page has details. A full key allows 8 concurrent requests and 300 per minute, which is plenty for a story app; the page about the DeepSeek API rate limit explains how to handle 429 errors if you run many sessions at once. New users can start with the $0.50 trial from the key page, and if you are comparing it with other options, see the page on the DeepSeek V4 API and the answer to whether DeepSeek has a free API.
More guides
Questions and answers
Is this the official DeepSeek API?
No. It is an independent OpenAI-compatible service that runs one open-weight model. It is not affiliated with DeepSeek or any other vendor.
Where does the persona go?
In the system message, sent on every request. The API does not remember earlier calls, so you resend the persona and the recent turns each time.
What temperature should I use for roleplay?
Start between 0.8 and 1.0 with top_p around 0.95. Add a small frequency penalty if replies repeat phrases.
Are there content limits?
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.