Skip to main content
POST
Anthropic Messages

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
string
required

ID of the chat model to use. See Models for the current model list, pricing, and endpoint support.

Example:

"claude-opus-4-5-20251101"

messages
object[]
required

Input messages. Alternating user / assistant turns.

max_tokens
integer
required

The maximum number of tokens to generate before stopping. Required.

Example:

1024

system
string

A system prompt providing context and instructions, set at the top level.

Example:

"You are a helpful assistant."

stream
boolean
default:false

If true, the response is streamed as Server-Sent Events.

stop_sequences
string[]

Custom text sequences that will cause the model to stop generating. The generated text will not contain the stop sequence.

tools
object[]

Optional Anthropic-compatible tool definitions. Support can vary by selected model and provider.

tool_choice

Controls tool use. Support can vary by selected model and provider.

thinking
object

Optional thinking/reasoning controls for models that support them. Support can vary by selected model and provider.

Response

Message result. When stream is true, the body is an SSE stream instead.

id
string
Example:

"msg_abc123"

type
string
Example:

"message"

role
string
Example:

"assistant"

model
string
Example:

"claude-opus-4-7"

content
object[]
stop_reason
enum<string>
Available options:
end_turn,
max_tokens,
stop_sequence
Example:

"end_turn"

stop_sequence
string | null
usage
object