A chat request is a stateless list of messages plus a system prompt. Stateless means the server keeps no memory, so you resend the whole conversation each turn.
{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"system": "You are a concise Python tutor.",
"messages": [
{"role": "user", "content": "What is a decorator?"},
{"role": "assistant", "content": "A decorator wraps a function..."},
{"role": "user", "content": "Show me one."}
]
}
Roles label who said what. user is your input, and assistant is the model's earlier reply. Replaying past assistant turns is the model's only memory.
The system prompt holds standing instructions: persona, tone, rules. Anthropic takes it as a top-level system field, outside messages. OpenAI puts it inside messages under a system or developer role.
The reply comes back as one assistant message. Append it to messages before the next call.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓