Skip to main content
POST

Authorizations

Authorization
string
header
required

Bearer token used for request authentication. Alternatively, you can send the API key in the x-api-key header. Note: A payment method is required to use the API.

Headers

anthropic-version
string

Anthropic protocol version, e.g. 2023-06-01. Sent automatically by the Anthropic SDK. Defaults to 2023-06-01 if omitted.

Body

application/json

Request body for the Messages API. Some parameters apply only to certain models; unsupported parameters are ignored.

model
enum<string>
required

The model to use. Anthropic models also accept their native ids (e.g. claude-opus-4-8), which map to anthropic/claude-opus-4.8.

Available options:
openai/gpt-5.6-sol,
openai/gpt-5.6-terra,
openai/gpt-5.6-luna,
openai/gpt-5.5-pro,
openai/gpt-5.5,
openai/gpt-5.4,
anthropic/claude-fable-5,
anthropic/claude-opus-5,
anthropic/claude-opus-4.8,
anthropic/claude-opus-4.6,
anthropic/claude-sonnet-5,
anthropic/claude-sonnet-4.6,
anthropic/claude-haiku-4.5,
google/gemini-3.5-flash,
google/gemini-3.1-pro-preview,
google/gemini-3.1-flash-lite,
google/gemini-3-flash-preview,
moonshotai/kimi-k3,
moonshotai/kimi-k2.6,
moonshotai/kimi-k2.5,
minimax/minimax-m2.5,
qwen/qwen3.6-plus,
deepseek/deepseek-v4-pro,
deepseek/deepseek-v4-flash
max_tokens
integer
required

Maximum number of tokens to generate, including thinking and visible output tokens.

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

The conversation so far, in chronological order.

system

System prompt. A plain string or an array of text blocks supporting cache_control.

tools
object[]

A tool definition. One of a custom tool, the built-in octen_broad_search tool, or the octen_search tool.

tool_choice
object

Controls whether and how the model calls tools.

stream
boolean
default:false

Whether to enable streaming output.

temperature
number
default:1

Controls randomness.

Required range: 0 <= x <= 1
top_p
number

Nucleus sampling. If unset, no nucleus truncation is applied. Set only one of temperature and top_p.

Required range: x <= 1
top_k
integer

Sample only from the top K tokens. If unset, top-k filtering is disabled.

Required range: x >= 0
stop_sequences
string[]

Stop sequences.

thinking
object

Thinking options for reasoning models.

metadata
object

Request metadata.

output_config
object

Controls how the model produces its output.

cache_control
object

Top-level prompt caching marker. Sets a cache breakpoint on the last cacheable content block in the request, equivalent to setting cache_control on that block directly.

Response

Successful message response. When stream=false, returns a single message object. When stream=true, returns an Anthropic SSE event stream.

A non-streaming response. Returned when stream=false.

id
string
required

The unique identifier for this request.

type
enum<string>
required

The response type. message on success.

Available options:
message,
error
role
enum<string>
required

Always assistant.

Available options:
assistant
model
string
required

The model used for this response.

content
object[]
required

The response content, as a list of content blocks.

stop_reason
enum<string>
required

Why the model stopped.

Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use,
pause_turn,
refusal
usage
object
required

Token usage information.

stop_details
object

Additional detail about why the model stopped. Returned only when stop_reason is refusal.

stop_sequence
string | null

The stop sequence that was hit, or null.