Skip to main content
POST
Messages
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 either single queries or stateless multi-turn conversations.

Authenticate

Use an API key in the Authorization header.

Request body

string
required
Anthropic model ID to use. See available models for the full list.
integer
required
The maximum number of tokens to generate before stopping.
array
required
Conversation turns as an array of { role, content } objects.
content may be a string or an array of content blocks (e.g. { "type": "text", "text": "..." }).
boolean
default:"false"
Enable Server-Sent Events streaming for the response.
string | array
System prompt.
number
Sampling temperature.
array
Custom stop sequences.
array
List of tools the model may call.
object
Controls tool calling behavior.

Examples


Response

Returns an Anthropic-compatible message object. If stream=true, the response is an SSE stream (text/event-stream).