Skip to content
English

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.

First set this site’s key environment variable ONEZHE_API_KEY, then run:

bash
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": "什么是域名解析?"}]
}'
FieldTypeUsage
modelstringRequired, selects the Claude model available to the key
max_tokensintegerRequired, output upper limit; set in combination with the selected model’s limits
messagesarrayRequired, sends user and assistant messages in chronological order
systemstring or array of content blocksOptional, system instructions are placed at the top level, not as a role: system message
streambooleanOptional, streams content block increments
toolsarrayOptional, 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.

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:

python
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_reasonHow the application should handle it
end_turnThis turn’s answer has ended
max_tokensOutput was truncated by the upper limit and cannot be treated as a complete answer
tool_useCheck tool requests, execute permitted tools, and send back results
Other valuesKeep 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.

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.