Skip to main content
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.
A dark presentation slide with the KodeKloud logo at the top and the centered title "Using a System Message." Small copyright text appears in the lower-left corner.
What a system message does:
  • 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.
Example scenario
  • 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.
Example: customer support system message Below is a minimal conversation that uses a system message to make the assistant act as a professional customer support agent for an electronics store. The assistant responds formally and concisely to a laptop-charging question.
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.
When to use system messages
  • 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.
Best practices and considerations Practical tips
  • 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.
Further reading and references Summary System messages are a foundational tool for controlling assistant behavior across a session. Use them to define role, tone, constraints, and output format—keeping the message concise and explicit will yield the most consistent results.

Watch Video