Skip to main content
POST
  • Fully compatible with the Claude Messages API format
  • Supports multi-turn conversations and one-shot queries
  • Supports multimodal content including text and images

Authorizations

string
required
API key used for authentication.Visit the API Key management page to obtain your API Key.Add it to the request header:
string
required
API version.Specifies which Claude API version to use.Example: 2023-06-01

Body

string
required
Model name.
  • claude-opus-4.6 — Claude 4.6 Opus, latest flagship
  • claude-sonnet-4.6 — Claude 4.6 Sonnet, latest version
  • claude-opus-4.5 — Claude 4.5 Opus flagship
  • claude-sonnet-4.5 — Claude 4.5 Sonnet, balanced
  • claude-haiku-4.5 — Claude 4.5 Haiku, fast response
array
required
Message list with alternating user and assistant roles.
integer
required
Maximum tokens to generate.Maximum number of tokens before generation stops. The model may stop earlier.Maximum value varies by model — refer to the model documentation.Minimum: 1
string | array
System prompt.The system prompt defines Claude’s role, personality, goals, and instructions.String format:
Structured format:
number
Temperature, range 0–1.Controls output randomness:
  • Low values (e.g., 0.2): more deterministic, more conservative
  • High values (e.g., 0.8): more random, more creative
Default: 1.0
number
Nucleus sampling parameter, range 0–1.Uses nucleus sampling. We recommend using either temperature or top_p, not both.Default: 1.0
integer
Top-K sampling.Sample only from the top K highest-probability options to remove “long-tail” low-probability responses.Recommended only for advanced use cases.
boolean
Whether to enable streaming output.
  • true: Stream the response progressively via Server-Sent Events (SSE).
  • false: Return the full response in one go.
Default: false
array
Stop sequences.Custom text sequences that stop generation when encountered. Up to 4 sequences, each up to 32 tokens long.
object
Metadata.An object used to track or identify the request.

Response

string
Unique identifier of the message.
string
Object type, always message.
string
Role, always assistant.
array
Array of message content.
string
Name of the model that actually served the request.
string
Reason generation stopped.Possible values:
  • end_turn — Natural completion
  • max_tokens — Reached max token limit
  • stop_sequence — Stop sequence encountered
  • tool_use — Tool use
string
The triggering stop sequence (if any).
object
Token usage statistics.

Examples

Single turn

Multi-turn conversation

Using a system prompt

Prefilling the response