Appearance
Anthropic-compatible Messages
Call models via the Anthropic-compatible Messages API. View input/output parameter descriptions and call examples. By modifying the following settings, you can migrate your existing Anthropic application to Alibaba Cloud Model Studio:
api_key: Replace with the Model Studio API key.base_url: Replace with the compatible endpoint address of Model Studio (see the access information below).model: Replace with a model name supported by Model Studio (for example,qwen3.6-plus).
Singapore
SDK base_url:https://dashscope-intl.aliyuncs.com/apps/anthropic
HTTP request URL:POST https://dashscope-intl.aliyuncs.com/apps/anthropic/v1/messages
China (Beijing)
SDK base_url:https://dashscope.aliyuncs.com/apps/anthropic
HTTP request URL:POST https://dashscope.aliyuncs.com/apps/anthropic/v1/messages
US (Virginia)
SDK base_url:https://dashscope-us.aliyuncs.com/apps/anthropic
HTTP request URL:POST https://dashscope-us.aliyuncs.com/apps/anthropic/v1/messages
Germany (Frankfurt)
SDK base_url:https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/apps/anthropic
HTTP request URL:POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/apps/anthropic/v1/messages
Replace {WorkspaceId} with your actual Workspace ID.
Authentication: Pass the Model Studio API key through the x-api-key request header or the Authorization: Bearer request header. You only need to use one of them.
## Request Body
## Basic Call
## Python
python
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/apps/anthropic",
)
message = client.messages.create(
model="qwen3.6-plus",
max_tokens=1024,
system="You are a helpful assistant",
messages=\[
{
"role": "user",
"content": "Who are you?"
}
\],
thinking={"type": "disabled"},
)
print(message.content\[0\].text)## TypeScript
typescript
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/apps/anthropic",
});
async function main() {
const message = await anthropic.messages.create({
model: "qwen3.6-plus",
max_tokens: 1024,
system: "You are a helpful assistant",
messages: \[{
role: "user",
content: "Who are you?"
}\],
thinking: { type: "disabled" },
});
console.log(message.content\[0\].text);
}
main().catch(console.error);## curl
curl
curl -X POST "https://dashscope-intl.aliyuncs.com/apps/anthropic/v1/messages" \\
-H "Content-Type: application/json" \\
-H "x-api-key: $DASHSCOPE_API_KEY" \\
-d '{
"model": "qwen3.6-plus",
"max_tokens": 1024,
"system": "You are a helpful assistant",
"messages": \[
{
"role": "user",
"content": "Who are you?"
}
\],
"thinking": {"type": "disabled"}
}'## Streaming
## Python
python
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/apps/anthropic",
)
stream = client.messages.create(
model="qwen3.6-plus",
max_tokens=1024,
stream=True,
messages=\[
{
"role": "user",
"content": "Give a brief introduction to artificial intelligence."
}
\],
thinking={"type": "disabled"},
)
for chunk in stream:
if chunk.type == "content_block_delta":
if hasattr(chunk.delta, 'text'):
print(chunk.delta.text, end="", flush=True)## TypeScript
typescript
import Anthropic from "@anthropic-ai/sdk";
async function main() {
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/apps/anthropic",
});
const stream = await anthropic.messages.create({
model: "qwen3.6-plus",
max_tokens: 1024,
stream: true,
messages: \[{
role: "user",
content: "Give a brief introduction to artificial intelligence."
}\],
thinking: { type: "disabled" },
});
for await (const chunk of stream) {
if (chunk.type === "content_block_delta" \&\& 'text' in chunk.delta) {
process.stdout.write(chunk.delta.text);
}
}
}
main().catch(console.error);## curl
curl
curl -X POST "https://dashscope-intl.aliyuncs.com/apps/anthropic/v1/messages" \\
-H "Content-Type: application/json" \\
-H "x-api-key: $DASHSCOPE_API_KEY" \\
--no-buffer \\
-d '{
"model": "qwen3.6-plus",
"max_tokens": 1024,
"stream": true,
"messages": \[
{
"role": "user",
"content": "Give a brief introduction to artificial intelligence."
}
\],
"thinking": {"type": "disabled"}
}'## Extended Thinking
## Python
python
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/apps/anthropic",
)
stream = client.messages.create(
model="qwen3.6-plus",
max_tokens=2048,
stream=True,
thinking={
"type": "enabled",
"budget_tokens": 1024
},
messages=\[
{
"role": "user",
"content": "Analyze the future prospects of quantum computing."
}
\]
)
for chunk in stream:
if chunk.type == "content_block_delta":
if hasattr(chunk.delta, 'thinking'):
print(chunk.delta.thinking, end="", flush=True)
elif hasattr(chunk.delta, 'text'):
print(chunk.delta.text, end="", flush=True)## TypeScript
typescript
import Anthropic from "@anthropic-ai/sdk";
async function main() {
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/apps/anthropic",
});
const stream = await anthropic.messages.create({
model: "qwen3.6-plus",
max_tokens: 2048,
stream: true,
thinking: { type: "enabled", budget_tokens: 1024 },
messages: \[{
role: "user",
content: "Analyze the future prospects of quantum computing."
}\]
});
for await (const chunk of stream) {
if (chunk.type === "content_block_delta") {
if ('thinking' in chunk.delta) {
process.stdout.write(chunk.delta.thinking);
} else if ('text' in chunk.delta) {
process.stdout.write(chunk.delta.text);
}
}
}
}
main().catch(console.error);## curl
curl
curl -X POST "https://dashscope-intl.aliyuncs.com/apps/anthropic/v1/messages" \\
-H "Content-Type: application/json" \\
-H "x-api-key: $DASHSCOPE_API_KEY" \\
-d '{
"model": "qwen3.6-plus",
"max_tokens": 2048,
"stream": true,
"thinking": {
"type": "enabled",
"budget_tokens": 1024
},
"messages": \[
{
"role": "user",
"content": "Analyze the future prospects of quantum computing."
}
\]
}'## Image Understanding
## Python
python
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/apps/anthropic",
)
stream = client.messages.create(
model="qwen3.6-plus",
max_tokens=1024,
stream=True,
messages=\[
{
"role": "user",
"content": \[
{
"type": "image",
"source": {
"type": "url",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250414/mqqmiy/animal_01.jpg",
},
},
{
"type": "text",
"text": "Describe the content of this image."
},
\],
}
\],
thinking={"type": "disabled"},
)
for chunk in stream:
if chunk.type == "content_block_delta":
if hasattr(chunk.delta, 'text'):
print(chunk.delta.text, end="", flush=True)## TypeScript
typescript
import Anthropic from "@anthropic-ai/sdk";
async function main() {
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/apps/anthropic",
});
const stream = await anthropic.messages.create({
model: "qwen3.6-plus",
max_tokens: 1024,
stream: true,
messages: \[{
role: "user",
content: \[
{
type: "image",
source: {
type: "url",
url: "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250414/mqqmiy/animal_01.jpg",
},
},
{ type: "text", text: "Describe the content of this image." },
\],
}\],
thinking: { type: "disabled" },
});
for await (const chunk of stream) {
if (chunk.type === "content_block_delta" \&\& 'text' in chunk.delta) {
process.stdout.write(chunk.delta.text);
}
}
}
main().catch(console.error);## curl
curl
curl -X POST "https://dashscope-intl.aliyuncs.com/apps/anthropic/v1/messages" \\
-H "Content-Type: application/json" \\
-H "x-api-key: $DASHSCOPE_API_KEY" \\
-d '{
"model": "qwen3.6-plus",
"max_tokens": 1024,
"stream": true,
"messages": \[
{
"role": "user",
"content": \[
{
"type": "image",
"source": {
"type": "url",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250414/mqqmiy/animal_01.jpg"
}
},
{
"type": "text",
"text": "Describe the content of this image."
}
\]
}
\],
"thinking": {"type": "disabled"}
}'## Video Understanding
## Python
python
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/apps/anthropic",
)
stream = client.messages.create(
model="qwen3.6-plus",
max_tokens=1024,
stream=True,
messages=\[
{
"role": "user",
"content": \[
{
"type": "video",
"source": {
"type": "url",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251208/zpupby/3e81ef38-98f0-4d55-bbb6-259334ca18d0.mp4",
},
},
{
"type": "text",
"text": "Describe the content of this video."
},
\],
}
\],
thinking={"type": "disabled"},
)
for chunk in stream:
if chunk.type == "content_block_delta":
if hasattr(chunk.delta, 'text'):
print(chunk.delta.text, end="", flush=True)## TypeScript
typescript
import Anthropic from "@anthropic-ai/sdk";
async function main() {
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/apps/anthropic",
});
const stream = await anthropic.messages.create({
model: "qwen3.6-plus",
max_tokens: 1024,
stream: true,
messages: \[{
role: "user",
content: \[
{
type: "video",
source: {
type: "url",
url: "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251208/zpupby/3e81ef38-98f0-4d55-bbb6-259334ca18d0.mp4",
},
},
{ type: "text", text: "Describe the content of this video." },
\],
}\],
thinking: { type: "disabled" },
});
for await (const chunk of stream) {
if (chunk.type === "content_block_delta" \&\& 'text' in chunk.delta) {
process.stdout.write(chunk.delta.text);
}
}
}
main().catch(console.error);## curl
curl
curl -X POST "https://dashscope-intl.aliyuncs.com/apps/anthropic/v1/messages" \\
-H "Content-Type: application/json" \\
-H "x-api-key: $DASHSCOPE_API_KEY" \\
-d '{
"model": "qwen3.6-plus",
"max_tokens": 1024,
"stream": true,
"messages": \[
{
"role": "user",
"content": \[
{
"type": "video",
"source": {
"type": "url",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251208/zpupby/3e81ef38-98f0-4d55-bbb6-259334ca18d0.mp4"
}
},
{
"type": "text",
"text": "Describe the content of this video."
}
\]
}
\],
"thinking": {"type": "disabled"}
}'## Function calling
## Python
python
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/apps/anthropic",
)
tools = \[
{
"name": "get_weather",
"description": "Get weather information for a specified city",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name"
}
},
"required": \["city"\]
}
}
\]
message = client.messages.create(
model="qwen3.6-plus",
max_tokens=1024,
tools=tools,
messages=\[
{
"role": "user",
"content": "What's the weather like in Hangzhou today?"
}
\]
)
print(message.content)## TypeScript
typescript
import Anthropic from "@anthropic-ai/sdk";
async function main() {
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/apps/anthropic",
});
const message = await anthropic.messages.create({
model: "qwen3.6-plus",
max_tokens: 1024,
tools: \[
{
name: "get_weather",
description: "Get weather information for a specified city",
input_schema: {
type: "object",
properties: {
city: { type: "string", description: "City name" }
},
required: \["city"\],
},
},
\],
messages: \[{
role: "user",
content: "What's the weather like in Hangzhou today?"
}\],
});
console.log(JSON.stringify(message.content, null, 2));
}
main().catch(console.error);## curl
curl
curl -X POST "https://dashscope-intl.aliyuncs.com/apps/anthropic/v1/messages" \\
-H "Content-Type: application/json" \\
-H "x-api-key: $DASHSCOPE_API_KEY" \\
-d '{
"model": "qwen3.6-plus",
"max_tokens": 1024,
"tools": \[
{
"name": "get_weather",
"description": "Get weather information for a specified city",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name"
}
},
"required": \["city"\]
}
}
\],
"messages": \[
{
"role": "user",
"content": "What's the weather like in Hangzhou today?"
}
\]
}'## Prompt Caching
## Python
python
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/apps/anthropic",
)
long_text_content = "<Your Code Here>" * 400
def get_completion(user_input):
response = client.messages.create(
# Choose a model that supports prompt caching
model="qwen3.6-plus",
max_tokens=1024,
system=\[
{
"type": "text",
"text": long_text_content,
# Add cache_control on a text block to mark a cache breakpoint. Can also be placed on content blocks in the messages array
"cache_control": {"type": "ephemeral"},
}
\],
messages=\[
{"role": "user", "content": user_input},
\],
)
return response
# First request: Create cache
first = get_completion("What does this code do?")
print(f"Cache creation tokens: {first.usage.cache_creation_input_tokens}")
print(f"Cache read tokens: {first.usage.cache_read_input_tokens}")
print("=" * 20)
# Second request: Same long content, different question -\> Cache hit
second = get_completion("How can this code be optimized?")
print(f"Cache creation tokens: {second.usage.cache_creation_input_tokens}")
print(f"Cache read tokens: {second.usage.cache_read_input_tokens}")## TypeScript
typescript
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/apps/anthropic",
});
// Simulate code repository content. Must reach minimum cacheable length (1024 tokens)
const longTextContent = "<Your Code Here>".repeat(400);
async function getCompletion(userInput) {
return client.messages.create({
// Choose a model that supports prompt caching
model: "qwen3.6-plus",
max_tokens: 1024,
system: \[
{
type: "text",
text: longTextContent,
// Add cache_control on a text block to mark a cache breakpoint. Can also be placed on content blocks in the messages array
cache_control: { type: "ephemeral" },
},
\],
messages: \[{ role: "user", content: userInput }\],
});
}
// First request: Create cache
const first = await getCompletion("What does this code do?");
console.log(\`Cache creation tokens: ${first.usage.cache_creation_input_tokens}\`);
console.log(\`Cache read tokens: ${first.usage.cache_read_input_tokens}\`);
console.log("=".repeat(20));
// Second request: Same long content, different question -\> Cache hit
const second = await getCompletion("How can this code be optimized?");
console.log(\`Cache creation tokens: ${second.usage.cache_creation_input_tokens}\`);
console.log(\`Cache read tokens: ${second.usage.cache_read_input_tokens}\`);## curl
curl
curl -X POST "https://dashscope-intl.aliyuncs.com/apps/anthropic/v1/messages" \\
-H "Content-Type: application/json" \\
-H "x-api-key: $DASHSCOPE_API_KEY" \\
-d '{
"model": "qwen3.6-plus",
"max_tokens": 1024,
"system": \[
{
"type": "text",
"text": "\",
"cache_control": {"type": "ephemeral"}
}
\],
"messages": \[
{"role": "user", "content": "What does this code do?"}
\]
}'model *string* (Required) Model name. The following models are supported: Supported Models
Qwen-Max: qwen3.6-max-preview, qwen3-max, qwen3-max-2026-01-23, qwen3-max-preview
Qwen-Plus: qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.5-plus, qwen3.5-plus-2026-04-20, qwen3.5-plus-2026-02-15, qwen-plus, qwen-plus-latest, qwen-plus-2025-09-11
Qwen-Flash: qwen3.6-flash, qwen3.6-flash-2026-04-16, qwen3.5-flash, qwen3.5-flash-2026-02-23, qwen-flash, qwen-flash-2025-07-28
Qwen-Turbo: qwen-turbo, qwen-turbo-latest
Qwen-Coder: qwen3-coder-next, qwen3-coder-plus, qwen3-coder-plus-2025-09-23, qwen3-coder-flash
Qwen-VL: qwen3-vl-plus, qwen3-vl-flash, qwen-vl-max, qwen-vl-plus
Qwen Open-Source Models: qwen3.6-27b, qwen3.5-397b-a17b, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b
Third-Party Models deepseek-v4-pro, deepseek-v4-flash, kimi-k2.5, kimi-k2-thinking, glm-5.1, glm-5, glm-4.7, glm-4.6, MiniMax-M2.5, MiniMax-M2.1
max_tokens *integer* (Required) The maximum number of tokens to generate.
system *string or array* (Optional) The system prompt, used to define the role or behavior of the model. system is passed as a top-level parameter. The messages array does not accept a system role. Passing a string is equivalent to a single type="text" content block. When you need to mark a prompt caching breakpoint for the system prompt (see the "Prompt Caching" example on the right), you must pass it as an array. Properties
type *string* (Required) Fixed value: text.
text *string* (Required) The system prompt text.
cache_control *object* (Optional) Mark a prompt caching breakpoint on this content block (see the "Prompt Caching" example on the right). Once the cache is hit, the second and subsequent requests are billed at the cache read rate. Contains only the type field, with a fixed value of ephemeral.
messages *array* (Required) The message array, arranged in alternating user/assistant turns. messages array element
role *string* (Required) The message role. Valid values: user, assistant.
content *string or array* (Required) The message content. Can be a plain text string or a structured content array. When content is a string, it is equivalent to a single type="text" content block. content array element types
TextProperties
type *string* (Required) Fixed value: text.
text *string* (Required) The text content.
cache_control *object* (Optional) Mark a prompt caching breakpoint on this text block (see the "Prompt Caching" example on the right). Contains only the type field, with a fixed value of ephemeral.
Image (requires vision model) Properties
type *string* (Required) Fixed value: image.
source *object* (Required) The source of the image data. Properties
type *string* (Required) Valid values: url (public image URL), base64 (Base64-encoded).
url *string* The public URL of the image. Required when type is url.
media_type *string* The MIME type of the image, such as image/jpeg. Required when type is base64.
data *string* The Base64-encoded image data. Required when type is base64.
Video (requires vision model) Properties
type *string* (Required) Fixed value: video.
source *object* (Required) The source of the video data. Properties
type *string* (Required) Valid values: url (public video URL), base64 (Base64-encoded).
url *string* The public URL of the video. Required when type is url.
media_type *string* The MIME type of the video, such as video/mp4. Required when type is base64.
data *string* The Base64-encoded video data. Required when type is base64.
Tool use (assistant role; tool call instruction returned by the model) Properties
type *string* (Required) Fixed value: tool_use.
id *string* (Required) The unique identifier of the tool call, used to associate the result in a subsequent tool_result.
name *string* (Required) The name of the called tool.
input *object* (Required) The input parameters of the tool call. The structure is determined by the input_schema of the corresponding tool in tools.
cache_control *object* (Optional) Mark a prompt caching breakpoint on this block (see the "Prompt Caching" example on the right). Contains only the type field, with a fixed value of ephemeral. The tool call content itself participates in the cache prefix.
Tool result (user role; execution result of a tool sent back to the model) Properties
type *string* (Required) Fixed value: tool_result.
tool_use_id *string* (Required) Corresponds to the id in the tool_use block.
content *string* (Required) The content returned by the tool execution.
cache_control *object* (Optional) Mark a prompt caching breakpoint on this tool result block (see the "Prompt Caching" example on the right). Contains only the type field, with a fixed value of ephemeral.
stream *boolean* (Optional) Whether to enable streaming. Default value: false.
temperature *number* (Optional) Controls the diversity of generated text. Value range: [0, 2). Higher values produce more random results.
**
**Note ** This range is different from the official Anthropic range of [0.0, 1.0]. When migrating from Anthropic, verify the value of this parameter.
top_p *number* (Optional) The probability threshold for nucleus sampling. Controls the diversity of generated text. ** Both temperature and top_p can control the diversity of generated text. We recommend setting only one of them. For more information, see Overview.
<b>top_k** *integer* (Optional) The size of the candidate set during sampling.
stop_sequences *array* (Optional) Specifies text sequences that stop generation. The model stops output before the sequence and does not include the sequence itself.
**
**Note ** After a match, the stop_reason in the response is still end_turn, and the response does not include the matched sequence.
thinking *object* (Optional) Extended thinking configuration. When enabled, the model performs reasoning before generating a response to improve accuracy. When enabled, the response includes content blocks of the thinking type. Some models do not support thinking mode. Properties
type *string* (Required) Valid values: enabled (enable thinking mode), disabled (disable thinking mode).
budget_tokens *integer* (Optional) The maximum number of tokens the thinking process can use. A larger budget allows more thorough analysis on complex problems. Takes effect when type is enabled.
reasoning_effort *string* (Optional) Controls the reasoning intensity of the model. Valid values: high, max. Default value: max. Supported models: deepseek-v4-pro, deepseek-v4-flash.
**
**Note ** When set to low or medium, it is mapped to high. When set to xhigh, it is mapped to max.
tools *array* (Optional) Array of tool definitions, used for the function call scenario. tools array element
name *string* (Required) The tool name.
description *string* (Optional) The description of the tool function.
input_schema *object* (Required) The JSON Schema definition of the tool input parameters.
tool_choice *object* (Optional) The tool selection strategy. The following values are supported:
{"type": "auto"}: The model decides whether to call a tool (default).{"type": "any"}: Force the model to call any tool.{"type": "none"}: Prohibit the model from calling tools.{"type": "tool", "name": "tool_name"}: Force the model to call a specified tool.
## Non-streaming Response
Response Example
json
{
"id": "msg_e2898f19-fc0e-4cb3-bd9b-5b7dc4ea3bc9",
"type": "message",
"role": "assistant",
"model": "qwen3.6-plus",
"content": \[
{
"type": "thinking",
"thinking": "Let me analyze this problem...",
"signature": ""
},
{
"type": "text",
"text": "Hello! I am Qwen..."
}
\],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 22,
"output_tokens": 223,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}id *string* The unique identifier of the message.
type *string* Fixed value: message.
role *string* Fixed value: assistant.
model *string* The name of the model used.
content *array* The content array. content array element types
TextProperties
type *string* Fixed value: text.
text *string* The text response generated by the model.
Thinking (returned when Extended Thinking is enabled) Properties
type *string* Fixed value: thinking.
thinking *string* The thinking process of the model before generating the final response.
signature *string* Currently fixed as an empty string.
Tool use (function call scenario) Properties
type *string* Fixed value: tool_use.
id *string* The unique identifier of the tool call, used to associate the result in a subsequent tool_result.
name *string* The name of the called tool.
input *object* The input parameters of the tool call.
stop_reason *string* The reason for stopping. Valid values: end_turn (normal completion), max_tokens (token limit reached), tool_use (tool call).
stop_sequence *string* Always null.
usage *object* Token usage statistics.
**
**Note ** In streaming calls, the usage field of the message_start event contains only input_tokens and output_tokens. The full four fields are returned in the message_delta event.
Properties
input_tokens *integer* The number of input tokens.
output_tokens *integer* The number of output tokens.
cache_creation_input_tokens *integer* The number of input tokens consumed for cache creation.
cache_read_input_tokens *integer* The number of input tokens consumed for cache reads.
## Streaming Response
Streaming response example
json
{"type":"message_start","message":{"id":"msg_xxx","type":"message","role":"assistant","model":"qwen3.6-plus","content":\[\],"usage":{"input_tokens":15,"output_tokens":0}}}
{"type":"content_block_start","index":0,"content_block":{"type":"thinking","thinking":"","signature":""}}
{"type":"content_block_delta","index":0,"delta":{"type":"thinking_delta","thinking":"Here's a thinking process:\\n\\n1. **Analyze User Input:**\\n - **Topic:** Artificial Intelligence (AI)\\n - **Request:** Give a brief introduction to artificial intelligence."}}
{"type":"content_block_delta","index":0,"delta":{"type":"signature_delta","signature":""}}
{"type":"content_block_stop","index":0}
{"type":"content_block_start","index":1,"content_block":{"type":"text","text":""}}
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"Artificial intelligence (AI) is an important branch of computer science..."}}
{"type":"content_block_stop","index":1}
{"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":15,"output_tokens":1078,"cache_creation_input_tokens":0,"cache_read_input_tokens":0}}
{"type":"message_stop"}message_start The first event in the stream, marking the start of a message. Properties
type *string* Fixed value: message_start.
message *object* The initial message object. content is an empty array, and usage contains only input_tokens and output_tokens.
content_block_start Sent when each content block starts, marking the index and type of the new content block. Properties
type *string* Fixed value: content_block_start.
index *integer* The content block index, starting from 0, corresponding to the position in the content array of the message.
content_block *object* The initial object of the content block. The type value is text, thinking, or tool_use. For the tool_use type, the input field is an empty object in this event, and the complete input parameters are assembled from subsequent content_block_delta deltas.
content_block_delta The incremental update event for a content block. Multiple events of this type are sent for the same content block. Properties
type *string* Fixed value: content_block_delta.
index *integer* The index of the associated content block.
delta *object* The delta object. The type field can have the following values:
text_delta: Text delta, containing thetextfield.thinking_delta: Thinking delta, containing thethinkingfield.signature_delta: Signature delta, containing thesignaturefield (currently fixed as an empty string).input_json_delta: Tool call input parameter delta, containing thepartial_jsonfield.
content_block_stop The content block end event. Properties
type *string* Fixed value: content_block_stop.
index *integer* The index of the ended content block.
message_delta The message-level update event, sent after all content blocks end. Contains the stop reason and complete token usage statistics. Properties
type *string* Fixed value: message_delta.
delta *object* Contains stop_reason and stop_sequence. For valid values, see the Non-streaming Response table above.
usage *object* Complete token usage statistics, including input_tokens, output_tokens, cache_creation_input_tokens, and cache_read_input_tokens.
message_stop The last event in the stream, marking the end of the message. Properties
type *string* Fixed value: message_stop. In addition, streaming responses periodically send ping events ({"type":"ping"}) to keep the connection alive. Clients can ignore them.