System Prompts
Set persistent rules for tone, behaviour, and safety.
- ✓What a system prompt is and why it is special
- ✓Locking tone, persona, and refusal rules
- ✓Requesting structured output reliably
Explanation
Most chat APIs let you set a system prompt — instructions that apply to the whole conversation, separate from the user's messages. It is where you fix the persona, rules, and boundaries.
Use it to lock tone ('always professional and concise'), define refusals ('never give medical diagnoses'), and require a consistent format ('always reply in valid JSON with keys answer and confidence').
Because it persists, the system prompt is how products keep an assistant on-brand and on-task across many user turns.
Code Example
| 1 | |
| 2 | |
| 3 | |
Every AI product you use has a hidden system prompt shaping its personality and guardrails.
- • Putting rules in each user message instead of once in the system prompt.
Write a system prompt for an HR assistant that stays friendly, refuses legal advice, and always suggests a next step.
1. What makes a system prompt different from a normal message?