Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI & ML · Const

System Prompt

A system prompt is an application-level instruction supplied as a system-role message to guide model behavior. For newer o1 models, use a developer message instead.

How it works

A system prompt is an application-provided instruction supplied with a system-role message to guide model behavior. In Chat Completions, it is included in the messages array alongside user and assistant messages; however, the documentation notes that newer o1 models use developer messages instead of system messages.

Syntax

{ "role": "system", "content": "..." }

Parameters

NameTypeDescription
messagesarrayThe ordered conversation messages, including the system or developer instruction and user input.
modelstringThe model that generates the completion.

Returns

A chat completion containing the model-generated assistant message.

Key points

  • Developer instructions are intended to control application behavior and take precedence over end-user instructions.
  • Model outputs are represented as assistant-role messages in the conversation structure.
  • A system message carries the instruction content that establishes the model's behavior.
  • System-message content must use text content rather than other multimodal content types.

Common mistakes

  • For o1 models and newer, use a developer message rather than a system message when providing application-level instructions.

Example: System message in Chat Completions

from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "system", "content": "You are a concise coding tutor."},
        {"role": "user", "content": "Explain recursion in one sentence."}
    ]
)
print(response.choices[0].message.content)

Creates a chat completion with a system message that sets application-level behavior before the user's request.

When to use it

Behavior control

Set a consistent persona or response style for a chat application.

Instruction hierarchy

Define application rules before processing user input.

Conversation guidance

Provide stable context for multi-turn conversations.

  • developer message
  • user message
  • assistant message
  • Chat Completions

Source: Chat Completions | OpenAI API Reference. Checked 2026-10-15.