Behavior control
Set a consistent persona or response style for a chat application.
AI & ML · Const
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.
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.
{ "role": "system", "content": "..." }| Name | Type | Description |
|---|---|---|
messages | array | The ordered conversation messages, including the system or developer instruction and user input. |
model | string | The model that generates the completion. |
A chat completion containing the model-generated assistant message.
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.
Set a consistent persona or response style for a chat application.
Define application rules before processing user input.
Provide stable context for multi-turn conversations.
developer messageuser messageassistant messageChat Completions