System messages are a powerful prompt-engineering technique that set persistent instructions for an AI assistant before any user interaction begins. They define the assistant’s role, tone, and behavior for the entire session, making responses predictable and aligned with your application’s needs—whether that’s customer support, tutoring, travel planning, or virtual assistance. System messages are commonly used with chat completion APIs such as OpenAI Chat Completions and Azure OpenAI Service.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.

- Sets a persistent instruction for the assistant’s role and tone.
- Applies across the session until changed or overridden.
- Helps ensure consistent structure, style, and constraints in replies.
- Imagine an assistant instructed to behave like a friendly, budget-focused travel planner. The system message drives that behavior across multiple user turns, so the assistant consistently prioritizes low-cost options and a conversational tone.
- The same pattern applies to roles such as professional customer support agents, technical tutors, or financial advisors—each role is defined via the system message.
System messages set a persistent instruction for the assistant’s role and tone at the start of a conversation. They help ensure consistent, role-specific responses across the session until the system message is changed or overridden.
- Role enforcement: Make the assistant act as an expert, support agent, tutor, or persona.
- Tone control: Ensure replies are formal, informal, concise, or verbose.
- Safety and constraints: Enforce policies, data-handling rules, or response formats.
- Structured output: Require JSON, YAML, or a specific bullet/step format.
| Aspect | Recommendation | Example |
|---|---|---|
| Keep it concise | Use short, precise instructions to avoid unintended behavior | ”Be a formal support agent. Keep replies ≤ 6 sentences.” |
| Be explicit about format | If you need structured output, request it in the system message | ”Return answers as numbered steps. Use JSON for diagnostics.” |
| Avoid sensitive data | Do not include secrets or private information in system messages | N/A |
| Combine with user messages | Use system messages for role/tone, then refine with user instructions | System: role; User: specific request details |
| Test iteratively | Try variations to find the most reliable phrasing for your use case | A/B test different tones, verbosity, or constraints |
- Use a system message to set non-negotiable constraints (e.g., safety rules, legal disclaimers).
- Reserve conversation-specific details for the user message so the system message remains reusable.
- If the assistant must return machine-readable output, enforce that format explicitly in the system message.
- OpenAI Chat Completions Guide
- Azure OpenAI Service documentation
- Prompt engineering techniques and best practices