Skip to main content
POST
Create Message
This endpoint is compatible with the Anthropic Claude Messages protocol for creating conversation messages.

Features

  • Supports both streaming (SSE) and non-streaming response modes
  • Supports multimodal content (text, images, etc.)
  • Supports tool use
  • Supports thinking/reasoning mode configuration
  • Supports cache control optimization

Use cases

Suitable for scenarios requiring interaction with Claude models, including:
  • Single-turn or multi-turn conversations
  • Structured output (JSON Schema)
  • Tool calling and function execution
  • Code execution and container reuse

Authentication

Include the Authorization header in the format Bearer YOUR_API_KEY.
The Claude format endpoint also requires the anthropic-version header, e.g. 2023-06-01.

Quick example

Headers

anthropic-version
string
required
Example:

"2023-06-01"

X-Api-Key
string
required
Example:

"YOUR_API_KEY"

Body

application/json
max_tokens
integer
required

Maximum number of output tokens (required)

model
string
required

Model name, e.g. claude-sonnet-4-0, claude-opus-4-0, etc.

messages
object[]
required

List of messages

top_p
number

Nucleus sampling, 0-1

top_k
integer

Top-K sampling

stop_sequences
string[]

Stop sequences

tool_choice
object

Tool choice configuration, can be a String or ClaudeToolChoice object

cache_control
object

Top-level cache control configuration Automatically applies a cache_control marker to the last cacheable block in the request

inference_geo
string

Inference geographic region Specifies the geographic region for inference processing. If not specified, uses the workspace's default_inference_geo

output_config
object

Output configuration Configures model output format options, such as effort level and structured output format

service_tier
string

Service tier Determines whether to use priority capacity (if available) or standard capacity Possible values: "auto" / "standard_only"

system
object

System instruction, can be a String or List

temperature
number

Sampling temperature, 0.0-1.0

stream
boolean

Whether to enable streaming output

thinking
object

Thinking/reasoning mode configuration

tools
object[]

List of tool definitions

metadata
object

Metadata

container
string

Container identifier, used for cross-request container reuse (code execution tool)

Response

200 - application/json

Claude Messages API non-streaming response Reference: https://platform.claude.com/docs/en/api/messages/create

stop_reason
string

Stop reason: end_turn / max_tokens / stop_sequence / tool_use / pause_turn / refusal Always output in the message_start event (even when null)

stop_sequence
string

Stop sequence that was matched (can be null) Always output in the message_start event (even when null)

stop_details
object

Refusal stop details Structured information returned when the model refuses due to safety policy

id
string

Message ID (msg_ prefix)

type
string

Object type, always "message"

role
string

Role, always "assistant"

content
object[]

List of response content blocks

model
string

Model name (the actual model that completed the task)

container
object

Container information Container identifier for the code execution tool, used for cross-request reuse

usage
object

Usage statistics