Skip to main content
POST
Claude Messages API

Authorizations

Authorization
string
header
required

Pass Authorization: Bearer <token> in the request header.

Headers

anthropic-version
string
default:2023-06-01

API version header Specifies the Claude API version to use.

anthropic-beta
string

Optional Claude beta feature header. The platform forwards it when provided.

Body

application/json
model
enum<string>
required

Model name.

Available options:
glm-5-turbo,
glm-5,
glm-5.1,
glm-5.2,
glm-4.7,
glm-4.7-flash,
glm-4.5-air,
MiniMax-M2.5,
MiniMax-M2.7,
MiniMax-M2.5-highspeed,
MiniMax-M2.7-highspeed,
MiniMax-M3,
qwen3-max,
qwen3.5-flash,
qwen3.6-plus,
qwen3-coder-plus,
deepseek-v3-2-251201,
deepseek-v4-flash,
deepseek-v4-pro,
seed-1-6-250915,
seed-1-8-251228,
seed-2-0-lite-260228,
seed-2-0-mini-260215,
seed-2-0-pro-260328
messages
object[]
required

Message list The model uses these messages to generate the next reply. Each message contains role and content fields.

max_tokens
integer
required

Maximum generated tokens The maximum number of tokens to generate before stopping. The model may stop before it reaches this limit. Different models have different maximum values; refer to the model documentation. max_tokens does not limit the length of the thinking process. When extended thinking is enabled, thinking tokens are controlled separately by thinking.budget_tokens.

Required range: x >= 1
system

System prompt used to set the model role or behavior. Pass system as a top-level parameter; the messages array does not accept a system role. Passing a string is equivalent to one type="text" content block. Use the array form when you need explicit cache breakpoints in the system prompt.

temperature
number

Temperature parameter, range [0, 2). Controls output randomness. Higher values make generation more random. This differs from Anthropic's official [0.0, 1.0] range; confirm the value when migrating from Anthropic.

top_p
number

Nucleus sampling probability threshold. It controls output diversity. Both temperature and top_p affect diversity; set only one of them when possible.

stop_sequences
string[]

Stop sequences Custom text sequences that stop generation when encountered. After a match, the response stop_reason remains end_turn, and the matched sequence is not returned in the response.

top_k
integer

Size of the candidate set used during sampling.

thinking
object

Extended thinking configuration. When enabled, the model reasons before generating the reply to improve answer quality. Some models do not support thinking mode.

reasoning_effort
enum<string>

Controls the model reasoning effort. The default is max. Supported models: deepseek-v4-pro and deepseek-v4-flash. low or medium maps to high; xhigh maps to max.

Available options:
high,
max
tools
object[]

Tool definition array for Function Call scenarios.

tool_choice
Mode selection · object

Tool choice strategy: auto (default, the model decides), any (force a tool call), none (disallow tool calls), or tool (force a specific tool).

output_config
object

Structured output configuration. When enabled, the model outputs a JSON string that conforms to the JSON Schema. The deepseek/glm series supports strict structured output with schema constraints. Other models use normal JSON mode, which requires the word 'JSON' in system or messages.

stream
boolean
default:false

Whether to enable streaming output.

Response

Claude-compatible response.

Claude-compatible message response.

id
string
required

Unique message ID.

type
enum<string>
required

Fixed to message.

Available options:
message
role
enum<string>
required

Fixed to assistant.

Available options:
assistant
model
string
required

Model name used for generation.

content
(Text · object | Thinking process · object | Tool call · object)[]
required

Content array.

stop_reason
enum<string>
required

Stop reason: end_turn for normal completion, max_tokens when the token limit is reached, or tool_use for a tool call.

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

Fixed to null.

usage
object
required

Token usage statistics. In streaming calls, the usage in the message_start event only includes input_tokens and output_tokens; all four fields are returned in the message_delta event.