Skip to main content
POST
Create a Message

Authorizations

Authorization
string
header
required

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

Body

application/json
model
enum<string>
required

The model that will complete your prompt.

Available options:
claude-sonnet-5,
claude-sonnet-4-6,
claude-sonnet-4-5-20250929,
claude-sonnet-4-20250514,
claude-opus-4-6,
claude-opus-4-5-20251101,
claude-opus-4-1-20250805,
claude-opus-4-20250514,
claude-haiku-4-5-20251001,
claude-3-7-sonnet-20250219,
claude-3-5-sonnet-20241022
Example:

"claude-sonnet-5"

messages
object[]
required

Input messages. Each message has a role and content.

Minimum array length: 1
Example:
max_tokens
integer
required

The maximum number of tokens to generate before stopping.

Required range: x >= 1
Example:

1024

system

System prompt. Provides context and instructions to Claude.

metadata
object

An object describing metadata about the request.

stop_sequences
string[]

Custom text sequences that will cause the model to stop generating.

temperature
number
default:1

Amount of randomness injected into the response. Ranges from 0.0 to 1.0.

Required range: 0 <= x <= 1
Example:

1

top_p
number

Use nucleus sampling. Recommended to use either temperature or top_p, but not both.

Required range: 0 <= x <= 1
top_k
integer

Only sample from the top K options for each subsequent token.

Required range: x >= 0
stream
boolean
default:false

Whether to incrementally stream the response using server-sent events.

tools
object[]

Definitions of tools that the model may use.

tool_choice
object

How the model should use the provided tools.

output_config
object

Output controls for models that support adaptive thinking effort.

thinking
object

Thinking configuration. For Claude Sonnet 5, use adaptive thinking or disable thinking; manual extended thinking with budget_tokens is not supported.

Response

Message created successfully

id
string
required
Example:

"msg_01XFDUDYJgAACzvnptvVoYEL"

type
string
required
Example:

"message"

role
string
required
Example:

"assistant"

content
object[]
required
Example:
model
string
required
Example:

"claude-sonnet-5"

stop_reason
enum<string>
required

Includes refusal when a request is declined.

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