Anthropic Claude API
Part of the AI Engineer Roadmap
In short
Claude's Messages API is small and strict: a system prompt, a list of messages and a token limit. Learn its shape once and tool use, streaming and vision all fit on top.
The API powering Claude models — known for large context windows, strong reasoning, and a similar message-based interface to other major LLM APIs.

Think of it like this
Briefing a new intern
On day one you give an intern a short brief: who we are, how to reply, what not to do. Then you pass them the email thread so far. Claude works the same: the system prompt is the brief, messages are the thread, and it remembers nothing you don't send.
Watch it happen
What comes back from messages.create
1/5Every call returns one Message object with an id, the model name and a role of assistant.
The big ideas
What you need to know
System is separate
The system prompt is its own field, not a message. Put your rules and persona there.
Stateless by design
Send the whole conversation every time, alternating user and assistant turns. The API stores nothing between calls.
max_tokens is required
You must set a ceiling on reply length. If stop_reason is max_tokens, the answer was cut off.
Content is blocks
Replies are lists of typed blocks. Loop through them and check type before reading text.
See it in code
Walk through the code
1import anthropic2 3client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY4 5message = client.messages.create(6 model="claude-opus-5-5",7 max_tokens=1024,8 system="You are a patient DSA tutor. Answer in under 100 words.",9 messages=[{"role": "user", "content": "Why is binary search O(log n)?"}],10)11for block in message.content:12 if block.type == "text":13 print(block.text)14print(message.stop_reason, message.usage.output_tokens)1/4Model and a required max_tokens ceiling for the reply.
A complete call with the official anthropic Python SDK. The current model list is on Anthropic's docs.
Save yourself the pain
Common mistakes
Oops
Reading message.content[0].text and assuming it's always there.
Do this instead
Loop over the blocks and check block.type. Tool calls and other block types can come first.
Oops
Ignoring stop_reason.
Do this instead
If it's max_tokens, the reply was cut. Raise the limit or ask for a shorter answer.
Your mission
A two-turn chat
Quick check
You ask Claude a follow-up and it has no idea what you said before. Why?
Go deeper
- 1Work through Anthropic's API docs and make calls for messages, tool use and streaming.
- 2Compare Claude's system-prompt handling against OpenAI's for the same use case.
- 3Test the same prompt across Claude and GPT to build intuition for model differences.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.