Anthropic Messages API

Use the native Anthropic Messages API format to interact with Claude series models

POST/v1/messages
  • Compatible with the native Anthropic Messages API format
  • Supports direct integration with the official Anthropic SDKs (Python / JavaScript) by changing only base_url
  • Supports streaming output (SSE)
  • Supports multi-turn conversations, system prompts, visual input, and tool calls

Note: If you are already using the OpenAI SDK, we recommend using the OpenAI-compatible endpoint. If you are using the Anthropic SDK or Claude Code, we recommend using this endpoint.

Authorizations

Authorizationstring

Bearer Token authentication for direct HTTP calls

Authorization: Bearer YOUR_API_KEY
x-api-keystring

API Key authentication compatible with the Anthropic SDK

x-api-key: YOUR_API_KEY
anthropic-versionstringDefault 2023-06-01

Anthropic API version, automatically included when using the Anthropic SDK

Recommended value: 2023-06-01

Body

modelstringRequired

Model name

Supports all Claude series models, for example:

  • claude-opus-4-6
  • claude-sonnet-4-6
  • claude-haiku-4-5
messagesobject[]Required

List of conversation messages in chronological order. Only the user and assistant roles are supported. Use the top-level system field for system prompts

Show messages[n]Hide messages[n]
rolestringRequired

Message role. Possible values: user, assistant

contentstring | object[]Required

Message content as a string or an array of content blocks

Show Content blockHide Content block
typestringRequired

Content type: text or image

textstring

Text content. Required when type is text

sourceobject

Image source. Required when type is image

Show sourceHide source
typestringRequired

Image source type: base64 or url

media_typestring

MIME type. Required when type is base64, for example, image/jpeg or image/png

datastring

Base64-encoded image data. Required when type is base64

urlstring

Image URL. Required when type is url

max_tokensintegerRequired

Maximum number of tokens to generate

  • Claude Sonnet 4-6 supports up to 64000
  • Claude Opus 4-6 supports up to 32000
systemstring | object[]

System prompt configured at the top level rather than inside messages

Supports either a string or an array of content blocks

streambooleanDefault false

Whether to enable streaming output (Server-Sent Events)

  • true: Returns tokens incrementally using an event format that follows the Anthropic SSE specification
  • false: Waits for the complete response and returns it all at once
temperaturenumberDefault 1

Sampling temperature that controls output randomness

Range: 0 to 1

top_pnumber

Probability threshold for nucleus sampling

Range: 0 to 1. It is recommended not to set both temperature and top_p

stop_sequencesstring[]

Stop sequences. Generation stops when any specified string is encountered

Response

idstring

Unique identifier for this request, in the format msg_*

typestring

Object type, always message

rolestring

Response role, always assistant

contentobject[]

List of generated content blocks

  • content[].type: Content type, usually text
    • content[].text: Generated text content
modelstring

Name of the model actually used

stop_reasonstring

Reason for stopping

  • end_turn: The model finished normally
  • max_tokens: The max_tokens limit was reached
  • stop_sequence: A stop sequence was triggered
usageobject

Token usage statistics for this request

  • usage.input_tokens: Number of input tokens
  • usage.output_tokens: Number of output tokens