In short.
Using the Messages API is Anthropic's practical guide for developers building Claude applications, but copying examples without matching their model and API version can cause request errors. It covers basic requests, conversation history, image inputs and response formatting across several programming languages. The documented 2026-10-21 API version rejects sampling parameters, while assistant prefills work only with eligible older models. Pricing, licensing, runtime compatibility and measured performance are not established.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete documentation page at [https://platform.claude.com/docs/en/build-with-claude/working-with-messages.md], including metadata, request and response examples, conversation handling, system messages, prefill restrictions, vision and availability notices. Linked pages are excluded. Model availability, platform differences, dependency compatibility, retention arrangements and runtime behavior were not independently verified. Nothing was executed.
The overview
Identity
This is Anthropic's documentation page titled Using the Messages API, available at [https://platform.claude.com/docs/en/build-with-claude/working-with-messages.md]. Its human-facing address is [https://platform.claude.com/docs/en/build-with-claude/working-with-messages].
The resource is a practical guide to direct Claude model requests through the Messages API. It is documentation rather than an SDK, model or managed agent service, and it directs readers elsewhere for the complete API specification.
Assessment
The guide is useful for understanding how a Claude application constructs requests and handles successive conversation turns. Parallel examples in cURL, the ant CLI, Python, TypeScript, C#, Go, Java, PHP and Ruby help developers translate the same request into their preferred environment.
Its compatibility notices are especially useful: they explain why familiar sampling controls or assistant prefills can fail. The page supplies examples and documented behavior, but does not establish application reliability, response quality or production performance.
Users
Beginners who understand basic JSON and API credentials can use the page to follow a first request and see how chat history is represented. It does not provide a complete introduction to programming, credential provisioning or SDK installation.
Experienced developers building custom agent loops, conversational applications or image-description features will find relevant request patterns. Developers seeking an infrastructure-managed harness for long-running work are directed toward Claude Managed Agents instead.
Capabilities
The page demonstrates single requests, multi-turn conversations, synthetic assistant history and response prefilling where supported. It also explains model-dependent mid-conversation system instructions and alternatives for requesting specific output formats.
Image requests can combine image and text blocks. Documented image sources are base64 data, a URL or a file uploaded through the Files API; listed media types are JPEG, PNG, GIF and WebP. Detailed image limits and Files API procedures are not supplied here.
Tool use, computer use, browser use, structured outputs and task budgets appear as onward links. Their complete implementation requirements are outside this page.
Using it
Requirements
The direct HTTP examples require an Anthropic API key and access to [https://api.anthropic.com/v1/messages]. Requests specify a model, max_tokens and a messages array. Image requests additionally need an accessible image, encoded image data or an uploaded file reference.
SDK and CLI installation commands, package versions and minimum language runtimes are not provided. Some snippets assume imports or client setup. The Python vision example imports httpx2 without installation guidance, so that dependency's availability and compatibility are unknown.
The page lists support across the Claude API, Amazon Bedrock, Claude Platform on AWS, Google Cloud offerings and Microsoft Foundry. Its examples do not establish authentication or setup procedures for each platform.
Mechanism
Ordinary Messages API requests are stateless: the application sends the conversation history with each request, including relevant user and assistant turns. Optional beta message threads let subsequent requests send only new messages. The page says a thread expires five minutes after its last request and is deleted no more than one hour after its last use.
Responses contain content blocks, a stop_reason and token-usage fields. A text block can follow a thinking block, so response handling should account for block types. The guide also states that refusal responses include stop_details identifying the policy category.
On listed supporting models, including Claude Opus 5.5, a mid-conversation system message must immediately follow a user turn and cannot be the first messages entry. The page describes it as having the same authority as the top-level system field while preserving an earlier cached prefix. Initial instructions belong in the top-level system field.
Setup
The documented HTTP pattern sends JSON to [https://api.anthropic.com/v1/messages] with x-api-key, anthropic-version and content-type headers. The examples use anthropic-version 2026-10-21 and application/json.
A starting integration needs a supported model identifier, an output-token limit and a user message. Omit temperature, top_p and top_k with the shown API version. For additional turns without message threads, retain the conversation in the application and include it in the next request.
Example
The basic example uses model claude-opus-5-5, max_tokens 1024 and one user message containing Hello, Claude. Its published response contains a text block saying Hello!, stop_reason end_turn and separate input_tokens and output_tokens counts.
The conversation example then sends the original user greeting, an assistant reply and a new user question together. This illustrates the history the application supplies rather than memory automatically retained by ordinary API calls. These are documentation examples; no request was executed.
Assessment & evidence
Limitations
With API version 2026-10-21, including temperature, top_p or top_k with any value produces a 400 error on any model. The page also describes earlier restrictions on non-default values for Claude 4.7 and later models and Claude Mythos Preview.
Assistant prefills are accepted only on Claude 4.5 and earlier models that have not been retired on the chosen platform. Other models return a 400 error. On compatible models, trailing whitespace or combining a prefill with output_config.format also causes a 400 error. Combining a prefill with thinking.type enabled instead treats thinking as off.
A prefill response contains only the continuation, requiring application-side joining if the complete text is needed. By contrast, a system prompt requesting a particular opening does not guarantee that opening. Context limits, image limits, throughput, latency and error-recovery behavior are not established by this page.
Fit and tradeoffs
The guide's documented patterns suit applications whose developers want control over conversation history, instructions and individual model calls. That control brings responsibility for maintaining history, interpreting response blocks and handling stopping conditions.
For a new integration using a model without prefill support, the documented approach is to end messages with a user turn. Use structured outputs for schema-constrained JSON, or the system field to request another format or a direct answer. The latter still requires checking the returned text.
Alternatives
The page contrasts direct Messages API prompting with Claude Managed Agents, described as a configurable harness running in managed infrastructure for long-running and asynchronous work. It links to [https://platform.claude.com/docs/en/managed-agents/overview]. No comparative costs or performance results are supplied.
For complete parameter definitions, the guide points to the Messages API reference at [https://platform.claude.com/docs/en/api/messages/create]. Neither linked resource's full contents are included here, so their detailed capabilities are not assessed.
Evidence
The evidence consists of Anthropic's complete documentation page at [https://platform.claude.com/docs/en/build-with-claude/working-with-messages.md], including its metadata, examples, compatibility notices and availability statements.
The response objects and image description are published illustrations. No code, API request, SDK, CLI command or image input was executed. There are no independent benchmarks or observed application results. Linked reference, migration, deprecation and feature pages are outside the evidence.
Access & freshness
Costs
API prices, free allowances, platform charges and expected monthly costs are not stated. The example token counts do not establish a monetary cost.
For usage planning, the page exposes input_tokens and output_tokens and explains max_tokens. On models with thinking enabled by default, thinking tokens also count toward max_tokens. A suitable token limit or budget for a particular workload remains unknown.
Rights and data handling
The page supplies no documentation or example-code redistribution licence, commercial-use terms or generated-output ownership terms. Those rights are unknown from this evidence.
Standard Messages API calls are described as eligible for zero data retention, excluding Covered Models, and for HIPAA readiness. Eligibility does not establish the retention arrangements or contractual conditions for a particular deployment. The linked data-handling details are outside this page, and the beta thread expiry schedule does not establish broader data-retention terms.
Freshness
The page was captured on 25 November 2026 and uses API version 2026-10-21 in its HTTP examples. No publication or last-updated date is supplied. Its metadata marks the Messages API stable, while the conversation section identifies message threads as beta.
The guide says Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated on Anthropic-operated platforms and that recommended replacements do not accept prefills. Retirement dates are not included, and partner-operated platforms set their own schedules. These differences matter when reusing the older prefill example.
Next actions
Before implementing an example, confirm the chosen platform's model availability, API version and SDK requirements. Begin with the basic user-message pattern, omit unsupported sampling fields and handle content blocks and stop_reason explicitly.
Decide whether to manage conversation history in the application or investigate the beta thread feature. For newer models, use the documented alternatives to assistant prefills. Obtain current pricing, usage terms and model-specific data-handling conditions separately; this page does not settle them.
