Messages Native Conversation Interface
Claude Messages request headers, differences between system and messages, content blocks, and stop reasons.
Claude Code, the Anthropic SDK, and applications that want to preserve Claude’s native content blocks use POST https://1zheai.com/v1/messages. Fill in the SDK Base URL with https://1zheai.com.
Minimal Request
Section titled “Minimal Request”First set this site’s key environment variable ONEZHE_API_KEY, then run:
curl --fail-with-body --connect-timeout 10 --max-time 120 \ https://1zheai.com/v1/messages \ -H "x-api-key: $ONEZHE_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-5-5", "max_tokens": 256, "system": "请用简短的中文回答。", "messages": [{"role": "user", "content": "什么是域名解析?"}] }'Request Structure
Section titled “Request Structure”| Field | Type | Usage |
|---|---|---|
model | string | Required, selects the Claude model available to the key |
max_tokens | integer | Required, output upper limit; set in combination with the selected model’s limits |
messages | array | Required, sends user and assistant messages in chronological order |
system | string or array of content blocks | Optional, system instructions are placed at the top level, not as a role: system message |
stream | boolean | Optional, streams content block increments |
tools | array | Optional, declares tool names, purposes, and input Schemas |
thinking, cache control, and beta parameters depend on the specific model and upstream support. Verify plain text first, then add as needed; do not treat all models as having the same set of parameters.
Reading Content Blocks
Section titled “Reading Content Blocks”The returned content is an array and may contain text, tool requests, or other content blocks at the same time. Do not unconditionally read content[0].text. For example, using the Anthropic Python SDK:
for block in message.content: if block.type == "text": print(block.text)Here message comes from client.messages.create(...) in the Anthropic SDK Tutorial .
stop_reason | How the application should handle it |
|---|---|
end_turn | This turn’s answer has ended |
max_tokens | Output was truncated by the upper limit and cannot be treated as a complete answer |
tool_use | Check tool requests, execute permitted tools, and send back results |
| Other values | Keep the response and handle it according to the selected model’s protocol; do not assume it is necessarily a text completion |
In a tool call loop, first add the complete assistant content block to history, then send it back with tool_result in the user content; tool_use_id must correspond to the original request. Do not convert tool requests directly into a single plain text passage.
Multi-turn and Streaming
Section titled “Multi-turn and Streaming”Send the history that needs to be retained each time; the interface itself does not store conversations for the application. Streaming uses message_stop to indicate the end of a message; receiving partial text does not mean the request has completed. See Streaming Output for details.
For protocol details, refer to Anthropic Messages Usage Notes . Whether this site’s extended parameters are available is determined by the model catalog and actual responses.
