v1

latestOpenAPI 3.1.02026-07-26157321426.3 KB
Messages

Create a message

Creates a response message for the provided conversation. Compatible with the Anthropic Messages API, so the Anthropic SDK works against this endpoint by changing base_url and overriding the default x-api-key header with Authorization. Support is in beta; behavior may change before general availability.

post/v1/messages

Request body

modelstring required

The model slug to use. Find available models at Model APIs.

max_tokensinteger required

The maximum number of tokens to generate in the response. Required by the Messages API. The response may be shorter if it finishes naturally or hits a stop sequence.

temperaturenumber

Controls randomness. Lower values are more deterministic. Range: 0 to 1.

top_pnumber

Nucleus sampling: only consider tokens with cumulative probability up to this value.

top_kinteger

Limits token selection to the top K most probable tokens at each step.

stop_sequencesstring[]

Custom text sequences that will stop generation. When a stop sequence is hit, stop_reason is stop_sequence and stop_sequence contains the matched string.

streamboolean

If true, the response is streamed as server-sent events. Each event has a type such as message_start, content_block_delta, or message_stop.

Response

Successful response

idstring required

A unique identifier for this message, such as msg_abc123.

type'message' required

The object type, always message.

role'assistant' required

The role of the generated message, always assistant.

modelstring required

The model slug that produced the response.

stop_reason'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' required

Why the model stopped generating: end_turn (natural stop), max_tokens (hit the max_tokens limit), stop_sequence (matched a stop_sequences entry), or tool_use (model invoked a tool).

stop_sequencestring nullable

The stop sequence that was matched, if stop_reason is stop_sequence. Otherwise null.