Messages API
Anthropic's main API for Claude: you send a model name, an optional system prompt and a list of messages, and get back content blocks, a stop reason and usage.
In more detail
Every call is stateless, so the client resends the conversation each turn. Replies arrive as a list of typed content blocks, such as text, tool_use and thinking, which code should join or dispatch by type rather than assume a single string.
Related terms
- content block — One typed piece of a message, such as text, an image, a tool call, a tool result or a thinking block.
- stop reason — The field in a model reply that says why generation ended, such as a natural end, the token cap, a stop sequence, a tool call or a refusal.
- usage block — The part of a model reply that reports how many tokens the call read and wrote, split by type, which is what you are billed for.
- Responses API — OpenAI's current API for generating model output, which takes input items and returns a list of output items with usage.
Taught in
- The Request And The Response — AI Engineering: LLM Apps, RAG & Agents
- Cost, Latency And Caching — AI Engineering: LLM Apps, RAG & Agents
- Anatomy Of A Prompt — AI Engineering: LLM Apps, RAG & Agents
- Structured Output — AI Engineering: LLM Apps, RAG & Agents
- Memory And Compaction — AI Engineering: LLM Apps, RAG & Agents
- How RAG Works And When To Use It — AI Engineering: LLM Apps, RAG & Agents
- Retrieval That Finds The Right Thing — AI Engineering: LLM Apps, RAG & Agents
- Grounded Answers With Citations — AI Engineering: LLM Apps, RAG & Agents
- Function Calling — AI Engineering: LLM Apps, RAG & Agents
- Build An MCP Server — AI Engineering: LLM Apps, RAG & Agents
- Connect An Agent To MCP — AI Engineering: LLM Apps, RAG & Agents
- Eval-Driven Development — AI Engineering: LLM Apps, RAG & Agents
- Evaluating RAG And Agents — AI Engineering: LLM Apps, RAG & Agents
- Tracing And Monitoring — AI Engineering: LLM Apps, RAG & Agents
- Images, Audio And Speech — AI Engineering: LLM Apps, RAG & Agents
References
- Anthropic: Messages API reference (temperature, top_k, top_p, stop_sequences, stop_reason)
- Anthropic: Errors (request id)