Create Claude message
Create message responses using the Anthropic Claude Messages native API format, with tool calling and extended thinking support
Models you can use
| Model ID | Notes |
|---|---|
claude-3-opus-20240229 | Claude 3 flagship — top reasoning and comprehension |
claude-3-5-sonnet-20241022 | Claude 3.5 Sonnet — balanced performance |
claude-3-5-haiku-20241022 | Claude 3.5 Haiku — fast and lightweight |
GET /v1/models for the full list.
Version header
Every request must includeanthropic-version: 2023-06-01 (or a newer
version).
System prompt
Thesystem field can be a plain text string or an array of content
blocks with cache-control directives for fine-grained prompt caching.
Tool calling
Define tools intools using a JSON Schema input_schema. The model
returns tool_use blocks in content; feed back the tool result as a
tool_result block in the next turn.
Extended thinking
Setthinking.type: enabled and specify thinking.budget_tokens to
enable extended thinking mode. The model returns thinking content
blocks alongside the final answer.
Streaming
Setstream: true for SSE streaming. Event types include
message_start, content_block_delta, and message_stop.Authorizations
Headers
Anthropic API version. Recommended value is 2023-06-01.
"2023-06-01"
Anthropic API key (optional). You can use this header or the standard
Authorization: Bearer YOUR_KEY header — either works.
Body
Anthropic Claude Messages API request body.
Model ID, e.g. claude-3-opus-20240229. See GET /v1/models for the full list.
"claude-3-opus-20240229"
Conversation messages. role must alternate between user and assistant.
Maximum number of tokens the model may generate. Required.
x >= 1System prompt — either a plain text string or an array of content blocks with cache-control directives.
Sampling temperature between 0 and 1, controlling output randomness.
0 <= x <= 1Nucleus sampling threshold. Tune this or temperature, not both.
Top-K sampling — only the K most probable tokens are considered.
Whether to stream the response as Server-Sent Events.
Stop sequences — generation halts when any of these is produced.
Tools the model may call. Each tool requires name, description, and input_schema.
Tool calling strategy. auto lets the model decide, any forces at least
one tool call, tool forces a specific tool (also set name).
Extended thinking configuration, only effective for models that support it.
Additional request metadata.
Response
Successful response
Anthropic Claude Messages API response body.
Unique identifier for this message.
Object type, value is message.
"message"
Response role, value is assistant.
"assistant"
List of response content blocks — may include text, tool_use, or thinking blocks.
The model that actually processed the request.
The reason generation stopped.
end_turn, max_tokens, stop_sequence, tool_use Token usage statistics.