LLM System Prompt Builder
UpdatedWhat is a system prompt? A system prompt is the standing instruction an LLM receives before any user message: it sets the role, rules and output format for every reply. The builder below writes one section by section. Keeping it stable also makes it cacheable, and cache hits cost 10 percent of the normal input price or less on most current models.
Your system prompt appears here as you type. Start with a role, for example: Senior backend engineer answering Python API questions.
What is an LLM system prompt?
An LLM system prompt is the standing instruction set that defines how a model behaves across an entire conversation. It is sent in a separate API field from user messages: OpenAI takes it as the first message with role system or developer, Anthropic exposes it as a top-level system parameter, Google uses systemInstruction. The model treats this slot as persistent context that shapes every turn that follows.
Consider the same model running two products. A customer-support API might ship a system prompt like “You are a tier-one support agent for an analytics SaaS. Confirm the user's account tier before quoting limits. Never promise refunds. Escalate billing disputes over $500.” A creative-writing assistant on the same model might ship “You are a fiction collaborator. Match the user's prose style. Avoid summarizing back what the user wrote. Offer two alternative directions per scene.” Same model weights, same temperature, completely different product behavior. The only thing that changed is the system message.
System prompt vs user prompt: what's the difference?
The system prompt sets the rules for the whole conversation: who the model is, what it must and must not do, and how replies should look. The user prompt is the request for one turn. You write the system prompt once and send it unchanged with every call, while the user prompt changes every time.
| System prompt | User prompt | |
|---|---|---|
| Who writes it | The developer building the product | The person using the product, or your code filling in a request |
| How long it applies | Every turn of the conversation | One turn |
| API field | system or developer message (OpenAI), system parameter (Anthropic), systemInstruction (Gemini) | A message with role user |
| What belongs there | Role, rules, safety limits, output format, examples that apply to every request | The question, the document to process, per-request data such as today's date |
| Caching | The best candidate, because the same prefix repeats on every call | Rarely cached, because it changes every time |
When the two conflict, the system prompt is meant to win. OpenAI's Model Spec says that when developer and user messages are both present, the developer messages have greater authority. That is why persona, safety rules and output format belong in the system slot. It is still not a security boundary: a user message can talk a model past a soft rule, so anything that must hold (permissions, payments, data access) belongs in your own code.
LLM system prompt template
A reusable LLM system prompt template has four sections in a fixed order: role, context, rules and output format. The template below uses the same tagged layout our builder produces, so you can paste it into your API's system field, replace the bracketed parts and delete any section you don't need.
<role>
You are [role], helping [audience] with [task].
</role>
<context>
[Background the model needs: the product, who the users are, facts it can rely on.]
</context>
<rules>
- [Your most important rule, written as one concrete instruction.]
- [What to do when a request is out of scope.]
- If you are not sure of an answer, say so instead of guessing.
</rules>
<format>
[Length, structure and style of every reply. For example: answer in 2 to 4 sentences and put code in a fenced code block.]
</format>The tags are plain text, not an API feature. They mark where each section starts and ends, for the model and for the next person who edits the prompt. The builder above fills the same four sections from a form and leaves out any section you leave empty, so its output always matches this layout. Put the rule that matters most at the top of the list and keep each rule to one concrete instruction.
How system prompts and prompt caching work together
System prompts ship with every API call. That makes them the biggest caching opportunity available, because the same prefix repeats across millions of requests with zero variation.
Here is the math on a real workload. A SaaS API sends a 4,000-token system prompt (role, rules, three examples, output schema) on 1,000,000 calls a month to GPT-6.1 Sol. That is 4,000M input tokens of system prompt, which cost $8,000 a month at the standard $2 per million. With caching on and a 90 percent hit rate, $360 goes on cache hits at $0.10 per million and $800 on the misses, for about $1,160 in total (before the small surcharge on cache writes). Same prompt, same answers, a fraction of the bill. For a measured case, see what caching a 4,500-token system prompt saved on a support classifier.
The discount varies by model. Cache hits cost 10 percent of the input price on most current models, 5 percent on Claude Opus 5.5 and 2.5 percent on Claude Fable 5.1. Writes cost a little more than normal input on Anthropic and on OpenAI's GPT-5.6 and later, and every provider has a minimum prefix length (from 512 tokens on the newest Claude models to 4,096 on recent Gemini models). Past that minimum, any system prompt that repeats more than a few times is cheaper with caching on. The LLM cost calculator has a caching toggle to see the effect across every model.
LLM system prompt best practices
Keep the system prompt short, specific and stable. Put the role, rules and output format in it, move anything that changes per request into the user message, prefer a few concrete examples over long rule lists, and keep secrets out. A prompt that never changes is also cheaper, because the repeated prefix can be cached.
- Keep it byte-for-byte stable. Changing the system prompt mid-conversation breaks the cache. Cache keys are computed over the exact byte sequence of the prefix, so a single trailing space, a swapped synonym, or a reordered rule invalidates the cached prefix and forces a full re-bill at the standard input rate.
- Move per-request data to the user message. Placing user-variable content (today's date, the requesting user's name, a per-tenant configuration block) inside the system prompt forces a re-cache on every call. We keep the system prompt static and move anything that varies per request into the user message, where cache misses are expected and cheap.
- Show examples instead of stacking rules. A 600-token bullet list of edge-case rules often loses to three concrete input/output examples covering the same edge cases, even when the example block uses fewer tokens. Models pattern-match more reliably from examples than they comply with prose rules, so we trade rule density for example density when the budget is tight.
- Treat it as public. Users can often get a model to repeat or paraphrase its instructions, and OWASP's guidance on system prompt leakage says the system prompt should not be treated as a secret or used as a security control. Never put API keys, passwords, connection strings or internal permission rules in it, and enforce access checks in your own code.
When to use this tool
We built the system prompt builder for three concrete situations. The first is shipping an API product where the same instructions ride along with every customer call. A consistent role, a stable safety boundary, and a fixed output schema all live in the system slot, get cached once, and amortize across the entire user base. The second is deploying a customer-facing chatbot with a consistent persona and safety rules. Persona drift across sessions is almost always a system-prompt problem (rules buried past 4K tokens, conflicting instructions, or persona language hidden inside a user message), and the builder forces the persona, rules, and format into named slots so drift is easier to spot. The third is standardizing safety and compliance behavior across an organization's multiple AI features. When five product surfaces share a refusal policy, the policy belongs in a single shared system block that every team imports, not five drifting copies.
Frequently asked
How long can a system prompt be?
The hard limit is the model's context window, which now reaches 1.05M tokens on the largest models we track. The practical limit is much lower: past roughly 4,000 tokens, rules start to get lost and every call pays for the whole prompt. Count your system prompt's tokens to see where yours stands. Above that size, turn on prompt caching and move examples into retrieval before adding more rules.
Should I put examples in the system prompt or the user message?
Examples that apply to every conversation belong in the system prompt, where they are cached after the first call. Examples tied to one request belong in the user message. Most few-shot cases (consistent tone, a fixed JSON schema, classification labels) are the first kind, so we default to the system slot.
Why is my system prompt being ignored?
Three causes, most common first. The rule is vague or buried deep in a long prompt, a forceful user message conflicts with a soft system rule, or a small open-weight model doesn't separate roles well. Make critical rules short and concrete, put them near the top, and repeat the most important one in the user message if it keeps slipping.
Do all LLMs support system prompts?
Every API model in our list does, across all 7 providers. Some local and base models have no separate system field, so the system text is simply prepended to the user message. Formatting habits differ (XML tags suit Claude, markdown sections suit OpenAI models), but the structure carries over.
Can users see or leak my system prompt?
Assume they can. Your app doesn't have to show the system prompt to anyone, but users can often get a model to repeat or paraphrase it, and an instruction to keep it secret is not a guarantee. OWASP's guidance on system prompt leakage says the system prompt should not be treated as a secret or used as a security control. Never put API keys, passwords, connection strings or internal permission rules in it, and enforce access checks in your own code.
Sources: Anthropic's prompting best practices · OpenAI's prompt caching guide · Anthropic's prompt caching docs. How we check our data