v1

latestOpenAPI 3.0.32026-07-132681171.6 KB

Create message

Send a message to an Anthropic-compatible model and receive a response

post/v1/messages

Headers

x-api-keystring required

Your Requesty API key

anthropic-versionstring
Example:2023-06-01

The version of the Anthropic API to use

Request body

modelstring required

The model to use for the completion

max_tokensinteger required

The maximum number of tokens to generate before stopping

systemstring

System prompt to be used for the completion

temperaturenumber

Amount of randomness injected into the response

top_pnumber

Use nucleus sampling

top_kinteger

Only sample from the top K options for each subsequent token

streamboolean

Whether to incrementally stream the response using server-sent events

stop_sequencesstring[]

Custom text sequences that will cause the model to stop generating

Response

Message response

idstring required

Unique object identifier

type'message' required

Object type

role'assistant' required

Conversational role of the generated message

modelstring required

The model that handled the request

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

The reason that we stopped

stop_sequencestring

Which custom stop sequence was generated