Chat APIs split input into roles: system for persistent instructions and persona, user for the human turn, assistant for model turns, and, in OpenAI's API, developer for app-owner rules ranked above the user. Anthropic's API takes the system prompt as a separate top-level system parameter instead of a message role.

System vs user vs developer rolesDiagram with these labels, in reading order: weights higher; weights lower; generates response; System; Instructions; Developer; Rules; User; Input; Assistant; Responses; Context; Window.weights higherweights higherweights lowergenerates responseSystemInstructionsDeveloperRulesUserInputAssistantResponsesContextWindow
Roles in Chat API Structure

Role precedence in a shared context window

All roles sit in one context window and all of them can influence the response. The roles carry a priority: system and developer instructions are meant to outrank user text. If the system role says to withhold personal data and a user asks for it, the model is trained to follow the system instruction, though this is not guaranteed.

The model is trained to treat each role differently, so it can serve the user's question inside the limits the application owner set.

  • Put durable rules in system.
  • Put app-owner policies in developer.
  • Put requests and untrusted data in user.
  • Keep secrets out of prompts.

The boundary is learned behavior

Privilege levels in software, such as root configuration against user input, are enforced by permission checks. The role boundary has no such check. It is a soft boundary shaped by the model's training, which means a determined user can still craft inputs that get an unintended result.

Prioritization is a hint Role weights guide the model but do not enforce policy, so user input can sometimes override system instructions.

Prompt injection when everything is one blob

A common first design concatenates all inputs into one block of text and treats it equally. That loses the priority signal between user requests and system instructions, and it leaves the model open to prompt injection: a user, or content the user supplies, can craft text that the model follows as an instruction.

Separating roles gives the model a way to resolve conflicts between user text and the system or developer policy. It improves the odds and must still be paired with application-side controls.

Enforce trust boundaries in application code

Use system and developer to set durable rules, define the persona and state the output contract. Do not place sensitive information or hard trust boundaries in the prompt. Enforce those in your application code, where a permission check is an actual check.

Example scenario: an ambiguous system role

Suppose error rates rise 40% after a release (an illustrative figure) because the system role is ambiguous or set wrongly, so the model produces off-topic replies or loses the thread of the conversation.

System vs user vs developer rolesDiagram with these labels, in reading order: If unclear instructions; If clear instructions; If roles misaligned; If roles aligned; If overrides present; If no overrides; User Instructions Clarity; System Role Misalignment; Developer Overrides; Update System Instructions; Refine User Prompts; Adjust Developer; Constraints.If unclear instructionsIf clear instructionsIf roles misalignedIf roles alignedIf overrides presentIf no overridesUser Instructions ClaritySystem Role MisalignmentDeveloper OverridesUpdate System InstructionsRefine User PromptsAdjust DeveloperConstraints
Debugging role confusion
  • Check how the system role is configured in the API settings.
  • Review recent failing interactions (for example the last 100) for patterns.
  • A/B test a clearly defined system role against the ambiguous one.
The call Write the system role with explicit instructions on persona and context. The prompt gets longer and takes more maintenance. Monitor user feedback scores and response relevance.

Back to the knowledge baseRequest an assessment