Tokens, Context Windows & Cost
Why full history is sent every turn and what it costs.
Claude Has No Memory
Here is the most important idea in this lesson: the Claude API keeps NO state between turns.
The model does not remember your last message. Each API call starts fresh. So how do chatbots seem to remember?
You send the full conversation history in every single request. The messages field carries the whole back-and-forth, every time.
What a Request Carries
A Claude API request has a few key fields:
model— which Claude model to usemax_tokens— the cap on the reply lengthsystem— the system promptmessages— the FULL history every turntools/tool_choice— optional tool config
Notice messages grows over time. Turn 1 sends 1 message. Turn 10 sends all 19 prior messages plus the new one.
resp = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
system="You are a support agent.",
messages=[
{"role": "user", "content": "My order is late."},
{"role": "assistant", "content": "I can help. What is your order ID?"},
{"role": "user", "content": "It's #4821."},
],
)All lessons in this course
- The Claude Model Family
- Anatomy of an API Request
- Stop Reasons Explained
- Tokens, Context Windows & Cost