Skip to main content
POST
Messages
Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
Server-side tools are not supported in the Messages API. In tools, only custom/client function tools are used; non-custom tool types are ignored.
This API is currently in Beta. While we strive to provide a stable and reliable experience, this feature is still under active development. As a result, you may encounter unexpected behavior or limitations. We encourage you to provide feedback to help us improve the feature before its official release.

Body

application/json
messages
MessagesInputMessage · object[]
required

A list of conversation messages ordered from oldest to newest. Must contain at least one item.

Minimum array length: 1
Example:
max_tokens
integer | null

Maximum number of tokens to generate for the assistant response. Must be greater than 0 when provided.

Required range: x >= 1
model
string | null

Routes the request to a specific adapter.

Example:

"(adapter-route)"

system

Payload format for the top-level system instruction.

stream
boolean
default:false

Whether to stream the response. When set to true, events are sent as server-sent events once generated.

temperature
number | null

Sampling temperature. Lower values make outputs more deterministic; higher values increase diversity.

top_p
number | null

Nucleus sampling parameter. The model samples from the smallest token set whose cumulative probability reaches top_p.

top_k
integer | null

Limits sampling to the k most likely tokens at each decoding step.

stop_sequences
string[] | null

Stop strings that terminate generation when matched in output. The matched value is returned in stop_sequence when applicable.

tools
MessagesToolDefinition · object[] | null

Tool definitions available to the model. Use this to allow tool calls with structured arguments.

tool_choice
MessagesToolChoice · object | null

Controls tool-calling behavior (auto, any, tool, none) and optional parallel-call behavior.

thinking
MessagesThinkingConfig · object | null

Controls reasoning behavior with mode (enabled, disabled, adaptive). enabled requires budget_tokens; disabled and adaptive must not include it.

output_config
MessagesOutputConfig · object | null

Output generation options including effort level and structured output format settings.

cache_control
Cache Control · object | null

Compatibility field accepted for request portability. Parsed but not used for generation.

container
Container · object | null

Compatibility field accepted for request portability. Parsed but not used for generation.

context_manager
Context Manager · object | null

Compatibility field accepted for request portability. Parsed but not used for generation.

inference_geo
Inference Geo · object | null

Compatibility field accepted for request portability. Parsed but not used for generation.

metadata
Metadata · object | null

Compatibility field accepted for request portability. Parsed but not used for generation.

service_tier

Compatibility field accepted for request portability. Parsed but not used for generation.

Response

Messages-style response, or an SSE stream when stream is true.

id
string
required

Unique identifier for this message response.

type
string
required

Response object type (message).

Allowed value: "message"
role
string
required

Role of the output message author (assistant).

Allowed value: "assistant"
content
(Thinking · object | Text · object | Tool Use · object)[]
required

Assistant output blocks in generation order.

usage
MessagesUsage · object
required

Token usage details for this response.

stop_reason
enum<string> | null

Why generation stopped (end_turn, max_tokens, tool_use, stop_sequence).

Available options:
end_turn,
max_tokens,
tool_use,
stop_sequence
stop_sequence
string | null

Matched stop string when stop_reason is stop_sequence; otherwise null.

model
string | null

Model used to generate the response.

Last modified on June 9, 2026