v4

latestOpenAPI 3.1.02026-08-0143190206.8 KB
v1

Create a messages response. This endpoint is compatible with the Anthropic API.

post/v1/messages

Request body

max_tokensinteger

The maximum number of tokens to generate before stopping. The model may stop before the max_tokens when it reaches the stop sequence.

modelstring

Model name for the model to use.

stop_sequencesstring[] nullable

(Not supported by reasoning models) Up to 4 sequences where the API will stop generating further tokens.

streamboolean nullable

If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.

temperaturenumber float nullable

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. It may not work well with reasoning models.

top_kinteger nullable

(Unsupported) When generating next tokens, randomly selecting the next token from the k most likely options.

top_pnumber float nullable

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. It is generally recommended to alter this or temperature but not both.

Response

Success

idstring required

Unique object identifier.

modelstring required

Model name that handled the request.

rolestring required

Role of the generated message. Always "assistant"

stop_reasonstring nullable

Reason to stop. "stop_sequence" means the inference has reached a model-defined or user-supplied stop sequence in stop. "max_tokens" means the inference result has reached models' maximum allowed token length or user defined value in max_tokens. "end_turn" or null in streaming mode when the chunk is not the last. "tool_use" means the model has called a tool and is waiting for the tool response.

stop_sequencestring nullable

Custom stop sequence used to stop the generation.

typestring required

Object type. This is always "message" for message types.

Example response

{
  "model": "latest",
  "type": "message"
}