System Prompts and Persona Definition
Write powerful system prompts that constrain model behavior, define a persona, set output format expectations, and reduce off-topic responses.
What Is the System Prompt?
In OpenAI's chat completions API, messages have three roles: system, user, and assistant. The system message appears at the beginning of the conversation and is not shown to end users. It defines the model's behavior, persona, constraints, and output format for the entire conversation.
Think of the system prompt as the director's brief: it tells the model who it is, what it should and should not do, how it should format responses, and what knowledge or context it has access to. Everything after that brief follows the rules set there. A well-crafted system prompt is the most reliable lever you have for shaping consistent model behavior.
Anatomy of a Strong System Prompt
A strong system prompt typically contains several distinct sections:
- Identity: Who the assistant is and what it knows (e.g., 'You are Aria, an expert customer support agent for AcmeCorp.')
- Scope: What topics are in and out of bounds (e.g., 'Only answer questions about our software products.')
- Tone and style: How the model should communicate (e.g., 'Be concise, professional, and empathetic.')
- Output format: Structure requirements (e.g., 'Always respond in markdown with headers and bullet points.')
- Safety rules: Explicit refusals (e.g., 'Never provide legal advice or share user personal data.')
All lessons in this course
- Zero-Shot and Few-Shot Prompting
- Chain-of-Thought and Step-by-Step Reasoning
- System Prompts and Persona Definition
- Prompt Iteration and Debugging