Skip to main content
POST
Create a message
Related guide: Anthropic Messages API. See the Anthropic Messages API guide for the authentication headers, the supported providers, and the cache_control breakpoints.

Authorizations

Authorization
string
header
required

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

Body

application/json
max_tokens
integer<int64>
required

Maximum number of tokens to generate. Set to 0 to warm the prompt cache and return the message id.

Required range: x >= 0
messages
object[]
required

Conversation so far, oldest turn first.

model
string
required

Model to run, in provider/model format (for example anthropic/claude-sonnet-4-5). Anthropic model IDs alone resolve against the workspace catalog.

cache_control
object

Applies a cache_control marker to the last cacheable block in the request.

context_management
object

Anthropic context management edits.

metadata
object

Request metadata.

output_config
object

Output shaping for the request: an effort level, a JSON schema format, or a task budget.

plugins
object[] | null

Request-scoped transforms the gateway applies in addition to the Anthropic protocol, such as pii_redaction.

service_tier
enum<string>

Anthropic service tier.

Available options:
auto,
standard_only
stop_sequences
string[] | null

Custom text sequences that stop generation.

stream
boolean

If true, returns a stream of server-sent events instead of one message object.

system

System prompt: a string, or an array of text blocks that can each carry cache_control.

temperature
number<double>

Sampling temperature between 0 and 1.

Required range: 0 <= x <= 1
thinking
Manual budget · object

Extended thinking configuration.

tool_choice
Auto · object

Tool selection policy.

tools
(Custom tool · object | Server tool · object)[]

Tools the model may call: custom tools with an input_schema, or Anthropic server tools such as web_search.

A tool the caller executes.

top_k
integer<int64>

Sample from the top K options at each step. Anthropic models only.

top_p
number<double>

Nucleus sampling cutoff.

Response

Returns a message object, or a stream of server-sent events.

content
(Text · object | Thinking · object | Redacted thinking · object | Tool use · object | Server tool use · object | Web search tool result · object | Tool search tool result · object | Compaction · object | Provider block · object)[]
required

Output blocks, in the order the model produced them.

Output block. The type field selects the block.

id
string
required

Message ID, taken from the provider when it returns one.

model
string
required

Model that produced the message.

role
enum<string>
required

Author of the message.

Available options:
assistant
stop_reason
string | null
required

Why generation stopped: end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal, or model_context_window_exceeded. The provider's own value is echoed when captured.

stop_sequence
string | null
required

The stop sequence that matched, when stop_reason is stop_sequence.

type
enum<string>
required

Object type.

Available options:
message
usage
object
required

Token usage. Carries input_tokens and output_tokens, plus cache_creation_input_tokens, cache_read_input_tokens, service_tier, thinking_tokens, and server tool counters when the provider reports them.

context_management
any

Context management edits reported by the provider.

safeguard_results
any

Safeguard results reported by the provider.