Skip to main content
POST

Authorizations

string
required
API key used for authentication (Anthropic SDK standard method)Get API Key:Visit the API Key management page to obtain your API key
Bearer Token format is also supported:

Body

string
required
Model Name
  • claude-haiku-4-5-20251001 — Lightweight and fast, suitable for high-frequency simple tasks
  • claude-sonnet-4-5-20250929 — Balanced performance and cost, generally recommended
  • claude-sonnet-4-6 — New version of Sonnet, stronger performance
  • claude-opus-4-5-20251101 — Flagship inference model, suitable for complex analysis
  • claude-opus-4-6 — New version of Opus, most powerful
For the full list of models, please refer to: GET /api/v1/models
array
required
Message ListAn array of messages. The model will generate the next reply based on these messages. Each message contains two fields: role and content.Quick Fill (Try it area):
  1. Click ”+ Add an item” to add a message
  2. Enter role: user (user message) or assistant (AI reply, for multi-turn conversations)
  3. Enter content: what you want to say
Single User Message Example:
Multi-turn Conversation Example:
Pre-filled Assistant Reply:
integer
required
Maximum Output Token CountControls the maximum number of tokens the model can generate. The model may end naturally before reaching this limit. Minimum value: 1.Different models have different context window limits; please refer to the model documentation.
string | array
System PromptSets the model’s role, instructions, and background information.String Format (recommended):
Structured Format (supports cache_control):
boolean
Enable Streamed OutputSet to true to return streamed output through SSE (Server-Sent Events) in real time. Default is true. To receive a non-streamed response, explicitly pass "stream": false.Stream event sequence: pingmessage_startcontent_block_startcontent_block_delta × N → content_block_stopmessage_deltamessage_stop
number
Temperature, range 0–1
  • Low values (e.g. 0.2): output is more certain and conservative
  • High values (e.g. 0.8): output is more random and creative
Default is 1.0. Not recommended to use with top_p simultaneously.
number
Nucleus Sampling Parameter, range 0–1Sampling from the smallest token set whose cumulative probability exceeds top_p. Default is 1.0. Not recommended to use with temperature simultaneously.
integer
Top-K SamplingSamples only from the top K tokens with highest probability, filtering out low-probability long tails. Suitable for advanced tuning.

Response

string
Unique identifier of the messageExample: "msg_01XFDUDYJgAACzvnptvVoYEL"
string
Object type, fixed as "message"
string
Role, fixed as "assistant"
array
Array of content blocksText content:
Content type: text (text)
string
The model name that actually processed the request
string
Stop reason
  • end_turn — natural end
  • max_tokens — reached the max_tokens limit
  • stop_sequence — triggered a custom stop sequence
string | null
If stopped due to a stop sequence, returns the triggered sequence content; otherwise null
object
Token usage statistics

Usage Examples

Basic Conversation

System Prompt + Multi-turn Conversation

Streaming Response

Visual Understanding

Streaming Response Event Format

Notes

  1. Authentication Methods: Supports two methods, the x-api-key request header or Authorization: Bearer; the official Anthropic SDK defaults to the former.
  2. Insufficient Credits: Returns HTTP 402 when balance is insufficient; please recharge and try again.
  3. Streaming Reconnection: Clients should implement an SSE reconnection mechanism and, upon disconnection, decide whether to resend the request based on the received content.
  4. Model Selection Recommendations:
    • Haiku — High-frequency simple Q&A, lowest cost
    • Sonnet — Code generation, document processing, generally recommended
    • Opus — Complex reasoning, long-text analysis, strongest capability