Skip to main content
POST
Create a Message

Body

application/json
model
enum<string>
required

Model ID.

Available options:
claude-sonnet-5
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. Claude Sonnet 5 supports up to 128K output tokens.

Required range: 1 <= x <= 128000
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. On Claude Sonnet 5, non-default values return a 400 error.

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

1

top_p
number

Use nucleus sampling. On Claude Sonnet 5, non-default values return a 400 error.

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

Only sample from the top K options for each subsequent token. On Claude Sonnet 5, non-default values return a 400 error.

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

Adaptive thinking configuration. Claude Sonnet 5 uses adaptive thinking by default; use output_config.effort to control depth. Manual extended thinking 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 for requests that the model declines.

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