Study FAQ
What must a Claude Messages API request contain?
Also asked as 2
- How do I send an authenticated Claude Messages request with a model, instructions, and history?
- Where do system instructions, message roles, and version headers go in a Claude API call?
Answer
For a first-party text generation call, send JSON to POST https://api.anthropic.com/v1/messages with a supported model, a suitable positive max_tokens, and ordered messages. Use the top-level system field for instructions that apply from the start of the conversation. Represent ordinary dialogue with user and assistant turns. Content can be a string for a single text part or an ordered array of typed blocks.
For direct HTTP, set content-type: application/json, a supported anthropic-version such as 2026-10-21, and the documented credential header. A first-party API key can use Authorization: Bearer <key> or the supported x-api-key header. An all-workspaces key also needs the target anthropic-workspace-id. A supported client SDK sets the basic HTTP headers from configuration. Keep long-lived credentials in server-side secret storage, and prevent them from appearing in diagnostics.
Enable a documented beta only with its exact supported header value or the associated SDK option. Record the selected model and version in reviewed configuration. API version, model, provider, and beta access affect which fields work. For example, the 2026-10-21 API version rejects the legacy sampling parameters temperature, top_p, and top_k. A cloud provider can use a different endpoint, IAM method, model identifier, and feature contract.
Exercise the adapter with harmless input. Confirm the returned Message parses and record its stop reason, usage, and request ID where available.
Official references
Full explanation
Claude Messages API and SDK Integration Foundations
Study guide · CCDV-F
Read the full explanation