Create a Message.
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. The Messages API can be used for for either single queries or stateless multi-turn conversations.
Authorizations
API key to authorize requests.
Body
The model that will complete your prompt.
Input messages.
"[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]"
The maximum number of tokens to generate before stopping.
A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role.
An object describing metadata about the request.
Custom text sequences that will cause the model to stop generating.
Whether to incrementally stream the response using server-sent events.
Amount of randomness injected into the response.
Use nucleus sampling.
Only sample from the top K options for each subsequent token.
Response
Unique object identifier.
For Messages, this is always "message".
This will always be "assistant".
An array of content blocks, each of which has a type. Currently, only type in responses is "text".
"[{\"type\": \"text\", \"text\": \"Hi, I'm Claude.\"}]"
The model that handled the request.
The reason that the model stopped. In non-streaming mode this value is always non-null. In streaming mode, it is null in the message_start event and non-null otherwise.
end_turn
, max_tokens
, stop_sequence
This value will be a non-null string if one of your custom stop sequences was generated. Else null.
Billing and rate-limit usage.