What Is a System Prompt?
Also called system message, system instructions
Short Answer
A system prompt is a set of instructions given to a language model before the user's messages, defining its role, rules, tone and output format for the whole conversation. Developers write it; users usually do not see it. It is how a general model becomes a specific assistant.
- Taught in lesson 88
Why It Matters
The system prompt is how a general model becomes a specific product: a support assistant, a medical information bot or a coding helper. Writing and maintaining it is a core part of building AI products, and protecting it from manipulation is part of AI security.
How It Works
In a chat API, messages carry roles: system for the developer's instructions, user for the person and assistant for the model. The system prompt typically sets who the assistant is, what it may and may not do, and how to format answers.
A system prompt is not a security barrier: users can try to override it with prompt injection, so sensitive rules must also be enforced in code.
A good system prompt is clear and structured: who the assistant is, what it should and should not do, how to handle missing information, the tone and the output format. It is tested like code, because it shapes every answer. It should not be the only safety measure, since determined users can sometimes get a model to ignore or reveal it; sensitive rules and data are enforced in code as well.
System Prompt in Practice
Everyday Example
A banking app's system prompt tells the model to answer only about the bank's products, to never give investment advice and to keep answers under 100 words.
Industry Example: Pharma
A medical information assistant's system prompt requires answers based only on the approved label, a standard safety statement, and a handover to a human for adverse event reports.
Where You Meet It
- The developer settings of chat APIs.
- Custom assistants built in AI tools.
- Agent instructions that define role and limits.
- Security reviews of AI applications.
Key Ideas Around It
- Message roles
- System, user and assistant messages in a chat API.
- Persona
- The role and tone the assistant takes.
- Guardrails
- Checks around the model beyond the prompt.
- Prompt leaking
- A user getting the model to reveal its hidden instructions.
A Common Mix-Up
A system prompt is not secret security. Never put passwords or confidential data in it, and enforce important rules in code too.
Check YourselfShould an API key be placed in a system prompt?
No. Users may get the model to reveal its instructions; secrets belong in secure code, never in prompts.
Learn It on ai2hired
S8 · #88The Anthropic API
Coming in Season 8, Harnessing Models (CAM). Every ai2hired lesson is free on YouTube.
Questions People Ask
Can users see the system prompt?
Not normally, but it can sometimes be extracted with clever questions, so never put secrets such as passwords or keys in it.
What should a system prompt contain?
The assistant's role, its audience, the rules and limits, the output format and how to handle cases it cannot answer.
Related Terms
Learn AI From Zero to Hired
Free lessons on YouTube, each one built from what real AI job ads ask for.