Skip to main content
POST
cURL
Beta FeatureThe Messages API is currently in beta. It provides Anthropic Messages API compatibility for clients like Claude Code. For production use, we recommend using the Responses API instead.

Overview

The Messages API provides compatibility with the Anthropic Messages API format. It’s designed primarily for clients that expect Anthropic’s API structure, such as Claude Code and other tools built for Claude’s API.

Body

application/json
messages
object[]
required
Minimum array length: 1
max_tokens
integer
required
Required range: 0 < x <= 9007199254740991
model
string

Model identifier. Use /v1/models to list all available models. Supports canonical names (e.g. gpt-5.2, claude-opus-4-6), aliases, and provider-prefixed formats (e.g. openai/gpt-5.2). Use "auto" for automatic model selection.

provider
string

One of 4616 allowed values.

cache_control
object | null

Cache control settings for explicit prompt caching of this content.

metadata
object | null

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

output_config
object | null
stream
boolean | null
system
temperature
number | null
Required range: 0 <= x <= 1
thinking
Enabled · object
tool_choice
Auto · object
tools
(Custom Tool · object | Web Search Tool · object)[]
top_p
number | null
Required range: 0 <= x <= 1
container
string | null
inference_geo
string | null
service_tier
string | null
stop_sequences
string[] | null
top_k
integer | null
Required range: 0 < x <= 9007199254740991
routing
object | null

Concentrate routing configuration controlling how requests are routed across models and providers. Learn more about routing.

Response

Default Response

id
string
required
type
enum<string>
required
Available options:
message
role
enum<string>
required
Available options:
assistant
model
string
required
content
(Text · object | Image · object | Document · object | Thinking · object | Redacted Thinking · object | Tool Use · object | Tool Result · object | Server Tool Use · object | Web Search Tool Result · object)[]
required
usage
object
required
cost
object
required
stop_reason
enum<string> | null
Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use,
pause_turn,
refusal
stop_sequence
string | null
redact
object | null