Skip to content
AI Dev Toolkit.
Esc
  • Loading…

AI glossary · Models and context

What is a system prompt?

Also called: system message, system instructions, developer message

Definition

A system prompt is the set of standing instructions a developer sends with every request to set a model’s role, rules and output format, kept separate from what the user types.

Explained

How does a system prompt work?

The model reads it before each user message, and because it is re-sent on every call, it is billed as input every time. For ready-made starting points by task, see our system prompt library.

It typically says who the assistant is, what it may and may not do, which tools to call and how answers should look. Keep secrets such as API keys out of it: it is ordinary text that the model may repeat if a user asks the right way.

Each API takes it in a different place. OpenAI’s Chat Completions uses a developer message (or the older system role), and its Responses API has a top-level instructions field. Anthropic’s Messages API takes a top-level system, and Gemini’s generateContent takes systemInstruction, which accepts text only. Our message format guide shows all four side by side.

Models keep no state between calls, so the system prompt is sent, and billed as input tokens, on every request and every turn of a conversation.

Example

A 78-token system prompt sent 1,000,000 times

The prompt below is 68 words and 78 tokens with OpenAI’s o200k_base tokenizer, counted as plain text. On GPT-6.1 Sol at $2 per million input tokens, sending it with 1,000,000 requests costs $156.00 before a single user message is counted.

It is too short to cache: OpenAI’s minimum cacheable prefix is 1,024 tokens on GPT-5.6 and later. Once a system prompt grows past that with tool definitions and examples, prompt caching makes the repeated part much cheaper, as long as it stays identical at the top of every request.

System prompt (78 tokens, o200k_base)
You are the support assistant for an online bike shop.
Answer questions about orders, deliveries, returns and bike parts.
Keep replies to three sentences or fewer unless the customer asks for more detail.
Call the check_order tool before you say anything about an order, and never guess a delivery date.
If you do not know the answer, say so and offer to pass the question to a person.

Cost and quality

Why does the system prompt matter for cost and behaviour?

It is the cheapest lever on quality you have: role, rules and format in one place, applied to every turn without retraining anything. Anthropic’s prompting guide notes that even a single sentence setting a role makes a difference.

It is also a fixed cost on every call, and a long list of rarely needed rules competes for the model’s attention. Keep it focused, put reference material in retrieval or tools, and measure it with the token counter when it grows.

Don’t mix up

What is the difference between a system prompt and a user prompt?

System prompt vs user prompt
The user prompt comes from the person using the app and changes every turn. The system prompt is yours and stays the same across the conversation.
System message vs developer message
OpenAI’s newer models use the developer role for the same job: its reasoning best practices guide says reasoning models support developer messages rather than system messages from o1-2024-12-17 on. Anthropic and Gemini have no developer role; use their top-level fields.

FAQ

Questions people ask

Can users see the system prompt?

Not directly in most apps, but assume it can leak: users can often coax a model into repeating its instructions. Never put API keys, passwords or private data in a system prompt, and enforce real permissions in your code rather than relying on instructions such as “never reveal this”. Treat the prompt as public text that shapes behaviour, not as a security boundary.

Is a system prompt the same as custom instructions in a chat app?

They are related but not the same. Custom or project instructions in chat apps are text you supply that the app adds to each conversation, alongside its own hidden instructions that you cannot edit. Through the API there is no hidden layer from an app: you write the system prompt yourself and decide exactly what it says.

Does the system prompt count toward the context window?

Yes. The system prompt, tool definitions and any examples it holds sit in the context window on every request, alongside the conversation and the reply. A long one leaves less room for documents and chat history, and it adds to the input cost of every call unless prompt caching discounts the repeated prefix.

Go deeper

Try it and read more

Related

All 41 terms in the AI glossary

Keep exploring