Skip to main content

System Prompt

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/system-prompt

In short

A system prompt is the instructions an app gives a language model before the conversation starts, setting its role, rules, tone and what it should know.

What is a system prompt?

Chat models receive messages with roles. The user's messages hold what the person types, the assistant's messages hold the model's earlier replies, and the system prompt, set by the developer, frames everything else: "You are a support assistant for a bookshop. Answer only questions about orders. Reply in the customer's language." The user usually never sees it.

A good system prompt describes who the model is acting as, what it should and shouldn't do, the format of its answers, and any context it needs, such as today's date, the user's plan or relevant documents. Products built on the same model can behave completely differently because of their system prompts.

APIs expose it in different ways: Anthropic's Messages API has a separate system parameter, while OpenAI's chat APIs use a message with the system or developer role. Models are trained to give these instructions more weight than ordinary user messages, which helps keep an assistant on task.

A common misconception is that a system prompt is a security boundary. Users can sometimes trick a model into ignoring or revealing its instructions, an attack known as prompt injection or jailbreaking. Secrets don't belong in a system prompt, and real permissions should be enforced in code, not only in words to the model.

Key takeaways

  • The system prompt sets the model's role, rules and context before the chat.
  • It is written by the developer and usually hidden from the user.
  • Models give it more weight than ordinary user messages.
  • Anthropic uses a system parameter; OpenAI uses a system or developer message.
  • It is not a security boundary: never put secrets in it.

Example

Setting a system prompt with Anthropic's APIpython
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=400,
    system=(
        "You are the help assistant for Software Dictionary. "
        "Explain programming terms simply, in at most three sentences, "
        "and suggest one related term at the end."
    ),
    messages=[{"role": "user", "content": "What is a webhook?"}],
)
print(message.content[0].text)

Readers ask

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

The system prompt comes from the developer and sets the rules for the whole conversation. User prompts are the individual messages a person sends within those rules.

Can users see the system prompt?

Not normally, but it should not be treated as secret. A determined user can sometimes get a model to repeat its instructions, so keep passwords, keys and private data out of it.

How long should a system prompt be?

As long as it needs to be clear. Short prompts work for simple assistants, while products often use long ones with examples and rules. Everything in it uses part of the context window on every request.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings