Zenaique

What are the three message roles in a chat style LLM prompt and what does each represent?

Flashcard·Easy·4.0 · 0·~30s·Asked atFiddler AiPromptlayer·Relevant atAnthropic
Attempt it
TL;DR

system carries standing orders, user carries the current turn's input, and assistant replays prior model responses so the next call has context.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a new employee at a help desk. Before the shift the manager hands them a short briefing: who they work for, what tone to use, what they must never say. That briefing is the system message. During the shift, customers walk up and ask questions; each question is a user message. The employee writes their previous answers on a notepad and keeps referring to it, so the conversation feels continuous. Those notes are the assistant messages. Every new question, the employee re-reads the briefing, the conversation so far, and the new question, then replies.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Every chat style LLM API is built on the same three core roles: system, user, assistant. The labels look almost trivial, but the placement decisions they force are where a lot of production prompt-engineering quality lives.

What each role carries

The system message is the model's standing orders for the call. It holds persona, tone, output format, refusal behavior, schema, tool descriptions and jurisdiction-specific rules: anything that should hold true across every turn of the conversation. By convention it is set once per session and reused.

The user message is the dynamic surface. In a chatbot it is whatever the human typed; in a backend pipeline it is whatever your application is asking. Retrieved RAG context typically belongs here too, alongside the query that needs it. Long documents go above the query, with the query at the end of the prompt.

The assistant message is the model's earlier replies replayed back to it. A stateless API such as Chat Completions does not remember anything across calls, so your code stores the prior responses and resends them as assistant turns on every new request. Without this, multi-turn coherence collapses.

Two further roles sit beside these three. A tool role (or a tool-result block on Anthropic) carries the output of a tool call back to the model. With OpenAI's o1 and newer models, a developer message takes the place of the system message and is prioritized ahead of user messages.

Stateless chat APIs, and what that means
Where retrieved context and dynamic facts go
Multi-turn memory and the long-conversation problem
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • OpenAI's Chat Completions API accepts system, user, assistant and tool messages. With o1 and newer models, a developer message replaces the system message, and the Responses API also takes top-level instructions.
  • Anthropic's Messages API has explicit user/assistant turns plus a top-level system parameter; marking the system block with cache_control lets prompt caching reuse it on repeated calls.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QIf the API is stateless, how do production chatbots get long-conversation memory without blowing the context window?
A

Sliding window of recent turns plus a running summary in system or a dedicated summary message. Mention vector store recall for older turns when truly long-horizon.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Putting the user's per-turn question into the system message; the system role is for persistent rules, not the current query.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • The three role labels and one-sentence purpose of each

  • Which chat APIs are stateless and what that means for transcripts

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Pair each decoding strategy with its determinism and diversity profile.
Match pairs·Easy