Migrate your Anthropic application to Model Studio by changing three settings. This topic covers the request and response parameters with code examples.
To migrate an existing Anthropic application to Model Studio, change these settings:
base_url: Replace with a Model Studio endpoint listed below.
model: Replace with a supported model name, such as qwen3.7-plus.
ImportantAlibaba Cloud Model Studio has released workspace-specific domains for the China (Beijing), Singapore, and China (Hong Kong) regions. The new dedicated domains deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
China (Beijing): from https://dashscope.aliyuncs.com to https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
Singapore: from https://dashscope-intl.aliyuncs.com to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
{WorkspaceId} is your workspace ID, which can be found on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domain remains fully functional.
Replace {WorkspaceId} with your actual workspace ID.
Authentication: Pass your Model Studio API key in either the x-api-key header or the Authorization: Bearer header.
Key differences from the official Anthropic API
The following differences are summarized from this topic. Pay close attention to them when migrating from official Anthropic:
Item
Description
Endpoint (Base URL)
base_url must be replaced with the Model Studio compatible endpoint (such as https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic; see the endpoint information above for other regions), where {WorkspaceId} must be replaced with your actual workspace ID.
Authentication
api_key must be replaced with a Model Studio API key; pass it in either the x-api-key or Authorization: Bearer request header.
Model names
model must be replaced with a supported model name (for example, qwen3.7-plus); see the model parameter below for the full list.
temperature range
The Model Studio range is [0, 2), which differs from the official Anthropic range of [0.0, 1.0]. Verify this parameter when migrating.
API scope
Only the Messages API (/v1/messages) is provided; no model list endpoint (/v1/models) is provided, so client model discovery requests return 404. See the FAQ below for how to handle this.
Extended parameters
output_config (structured outputs and the thinking intensity effort) is a Model Studio platform extension parameter that is not included in the official SDK type definitions and must be passed through in the request body (see the "Structured Outputs" example on the right); thinking.budget_tokens will be deprecated soon. For new integrations, use output_config.effort to control the thinking intensity.
Request Body
modelstring(Required)
Model name. Supported models:
Supported Models
Qwen-Max: qwen4-max-preview (Token Plan only), qwen3.8-max, qwen3.8-max-0902, qwen3.7-max, qwen3.7-max-2026-05-20, qwen3.7-max-2026-06-08
qwen4-max-preview, deepseek-v4.1-flash, deepseek-v4-pro, deepseek-v4-pro-0813, deepseek-v4-flash-0731, qwen3.8-max, qwen3.8-flash: max_tokens is the maximum total token count for both the reply content and the chain-of-thought content. Generation stops early when the model output exceeds this value, and stop_reason is max_tokens.
max_tokens limits the combined length of reply content and the thinking process. When extended thinking is enabled, max_tokens > thinking.budget_tokens
glm-5.3: max_tokens is the maximum total token count for both the reply content and the chain-of-thought content. Generation stops early when the model output exceeds this value, and stop_reason is max_tokens. glm-5.3 ignores the thinking.budget_tokens parameter.
glm-5.2: When the thinking.budget_tokens parameter is not passed, max_tokens is the maximum total token count for both the reply content and the chain-of-thought content. Generation stops early when the model output exceeds this value, and stop_reason is max_tokens. When the thinking.budget_tokens parameter is passed, max_tokens is only the maximum number of tokens for the reply content, and the thinking tokens are controlled separately by thinking.budget_tokens.
Other models: Maximum number of tokens for the reply content. If the generated content exceeds this value, generation stops early and stop_reason is max_tokens.
max_tokens does not limit the length of the thinking process. When extended thinking is enabled, the thinking tokens are controlled separately by thinking.budget_tokens.
systemstring or array (Optional)
System prompt used to define the model's role or behavior.
Passing a string is equivalent to a single type="text" content block. When you need to mark explicit caching breakpoints on the system prompt (see the "Prompt Caching" example on the right), you must pass an array.
Properties
typestring(Required)
Fixed value: text.
textstring(Required)
The system prompt text.
cache_controlobject (Optional)
Marks an explicit caching breakpoint on this content block (see the "Prompt Caching" example on the right). After a cache hit, the second and subsequent requests are billed at the cache read rate. Contains only the type field, fixed to ephemeral.
messagesarray(Required)
messages array element
rolestring(Required)
The message role. Valid values: user, assistant, system.
contentstring or array(Required)
The message content. It 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
Text
Properties
typestring(Required)
Fixed value: text.
textstring(Required)
The text content.
cache_controlobject (Optional)
Marks an explicit caching breakpoint on this text block (see the "Prompt Caching" example on the right). Contains only the type field, fixed to ephemeral.
The public URL of the image. Required when type is url.
media_typestring
The MIME type of the image, such as image/jpeg. Required when type is base64.
datastring
The Base64-encoded image data. Required when type is base64.
Video (requires vision model)
Properties
typestring(Required)
Fixed value: video.
sourceobject(Required)
The source of the video data.
Properties
typestring(Required)
Valid values: url (public video URL), base64 (Base64-encoded).
urlstring
The public URL of the video. Required when type is url.
media_typestring
The MIME type of the video, such as video/mp4. Required when type is base64.
datastring
The Base64-encoded video data. Required when type is base64.
Tool use (assistant role; tool call instruction returned by the model)
Properties
typestring(Required)
Fixed value: tool_use.
idstring(Required)
The unique identifier of the tool call, used to associate the result in a subsequent tool_result.
namestring(Required)
The name of the called tool.
inputobject(Required)
The input parameters of the tool call. The structure is determined by the input_schema of the corresponding tool in tools.
cache_controlobject (Optional)
Marks an explicit caching breakpoint on this block (see the "Prompt Caching" example on the right). Contains only the type field, fixed to 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
typestring(Required)
Fixed value: tool_result.
tool_use_idstring(Required)
Corresponds to the id in the tool_use block.
contentstring(Required)
Content returned by the tool.
cache_controlobject (Optional)
Marks an explicit caching breakpoint on this tool result block (see the "Prompt Caching" example on the right). Contains only the type field, fixed to ephemeral.
streamboolean (Optional)
Whether to enable streaming. Default value: false.
temperaturenumber (Optional)
Controls the diversity of generated text. Value range: [0, 2). Higher values produce more random results.
NoteThis range is different from the official Anthropic range of [0.0, 1.0]. When migrating from Anthropic, verify the value of this parameter.
top_pnumber (Optional)
Nucleus sampling probability threshold that 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.
top_kinteger (Optional)
Candidate set size during sampling.
stop_sequencesarray (Optional)
Text sequences that stop generation. The model stops outputting before the matched sequence, and the sequence itself is not included.
NoteAfter a match, the stop_reason in the response is stop_sequence, and the matched sequence is returned in the response's stop_sequence field.
thinkingobject (Optional)
Extended thinking configuration. When enabled, the model reasons before generating the response to improve answer accuracy, and the response includes thinking-type content blocks.
When this parameter is not passed, whether thinking occurs is determined by the model's default behavior: qwen4-max-preview, qwen3.8-max, qwen3.8-flash, the deepseek-v4 series, the glm series, and kimi-k3.1-pro enable thinking by default; kimi-k2.6 and kimi-k2.5 disable thinking by default; kimi-k2.7-code and MiniMax-M2.5 support thinking mode only (it cannot be disabled). For the thinking mode support and default settings of each model, see Deep Thinking.
This parameter will be deprecated and will gradually stop being supported in subsequent models. For new integrations, we recommend using effort to control the thinking intensity of the model.
Maximum tokens for the thinking process. How it relates to max_tokens depends on the model; see the max_tokens description. A larger budget allows more thorough analysis on complex questions. Takes effect when type is enabled.
toolsarray (Optional)
Tool definitions for function calling.
tools array element
namestring(Required)
The tool name.
descriptionstring (Optional)
The description of the tool function.
input_schemaobject(Required)
The JSON Schema definition of the tool input parameters.
In addition to custom tools, tools supports the Model Studio server-side web search tool. Declare it in tools to enable; no client-side retrieval is needed.
Web search tool
typestring(Required)
The tool type, such as web_search_20250305 with a date suffix. The date suffix does not need to be fixed; keep it consistent with the value sent by the client.
namestring(Required)
Fixed to web_search.
max_usesinteger (Optional)
The maximum number of searches per request.
When calling the API directly with the Anthropic SDK or over HTTP, you must pass the client identifier x-anthropic-billing-header: cc_entrypoint=cli; in system. Otherwise web search does not take effect. No extra configuration is needed for Anthropic official clients such as Claude Code. See Web search.
Supported models: the Qwen4-Max series; Qwen3.8 Max, Flash, and open-source series (excluding Omni); Qwen3.7 Max, Plus, Flash series; Qwen3.6-Plus, Qwen3.6-Flash series; Qwen3.5-Plus, Qwen3.5-Flash series; deepseek-v4-pro, deepseek-v4-pro-0813, deepseek-v4-flash-0731, deepseek-v4.1-flash-1017; glm-5.2; kimi-k3; kimi-k3.1-pro. Web search is billed at the same rate as the agent policy. See billing.
kimi-k3.1-pro (deployed on Alibaba Cloud Model Studio) supports web_search and web_fetch in Beijing, Singapore, the US (Virginia), Germany (Frankfurt), Japan (Tokyo), and China (Hong Kong).
deepseek-v4.1-flash-1017 also supports the web_fetch tool. For Anthropic-compatible request requirements and examples, see Web extractor.
tool_choiceobject (Optional)
Tool selection strategy. Supported values:
{"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.
output_configobject (Optional)
Output parameter settings.
Properties
effortstring (Optional)
Controls the inference intensity of the model.
For kimi-k3.1-pro (deployed by Alibaba Cloud Model Studio), the default is max. Supported values are max (deep reasoning), high (enhanced reasoning), medium (moderate reasoning), and low (light reasoning).
glm-5.3 (default value: max):
Valid values:
low: Low-intensity inference
high: High-intensity inference
max: Maximum-intensity inference
Passing any other value returns an error.
glm-5.2, deepseek-v4-pro (directly supplied by Alibaba Cloud) (default value: max):
Valid values:
high: High-intensity inference
max: Maximum-intensity inference
low and medium are mapped to high, and xhigh is mapped to max.
Structured output configuration. When enabled, the model returns a JSON string. Behavior varies by model:
deepseek-v4.1-flash and deepseek-v4.1-flash-1017 do not support this parameter and return a 400 error if it is specified.
Strict structured outputs: Available for qwen4-max-preview, qwen3.8, qwen3.7, deepseek (excluding deepseek-v4.1-flash, deepseek-v4.1-flash-1017, deepseek-v4-flash-0731, and deepseek-v4-pro-0813), and glm series models. The model strictly follows the provided JSON Schema, guaranteeing the same field types and hierarchy.
Regular structured outputs: For all other models, schema field constraints are not enforced — the API automatically falls back to a plain JSON mode (only guaranteeing that the output is a valid JSON string). In this fallback mode, the request must satisfy both of the following: (1) the output_config parameter is explicitly provided; (2) the system or messages content contains the keyword "JSON" (case-insensitive). If the keyword "JSON" is missing, the API throws: 'messages' must contain the word 'json' in some form.
Properties
typestring(Required)
Fixed value: json_schema.
schemaobject(Required)
JSON Schema object that follows the standard JSON Schema specification. Should include type (data type), properties (field definitions), required (array of required field names), and additionalProperties (must be set to false).
Basic Call
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic",
)
message = client.messages.create(
model="qwen3.8-max",
max_tokens=1024,
system="You are a helpful assistant",
messages=[
{
"role": "user",
"content": "Who are you?"
}
],
thinking={"type": "disabled"},
)
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic",
});
async function main() {
const message = await anthropic.messages.create({
model: "qwen3.8-max",
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 -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1/messages" \
-H "Content-Type: application/json" \
-H "x-api-key: $DASHSCOPE_API_KEY" \
-d '{
"model": "qwen3.8-max",
"max_tokens": 1024,
"system": "You are a helpful assistant",
"messages": [
{
"role": "user",
"content": "Who are you?"
}
],
"thinking": {"type": "disabled"}
}'
Streaming
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic",
)
stream = client.messages.create(
model="qwen3.8-max",
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)
import Anthropic from "@anthropic-ai/sdk";
async function main() {
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic",
});
const stream = await anthropic.messages.create({
model: "qwen3.8-max",
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);
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic",
)
# Simulate code repository content. Must reach minimum cacheable length (1024 tokens)
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.8-max",
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}")
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.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.8-max",
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 -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1/messages" \
-H "Content-Type: application/json" \
-H "x-api-key: $DASHSCOPE_API_KEY" \
-d '{
"model": "qwen3.8-max",
"max_tokens": 1024,
"system": [
{
"type": "text",
"text": "<Place cacheable content here with at least 1024 tokens>",
"cache_control": {"type": "ephemeral"}
}
],
"messages": [
{"role": "user", "content": "What does this code do?"}
]
}'
Structured Outputs
import anthropic
import os
client = anthropic.Anthropic(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic",
)
message = client.messages.create(
model="deepseek-v4-pro",
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Extract key info from this email: John Smith (john@example.com) is interested in the Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."
}
],
extra_body={
"output_config": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"email": {"type": "string"},
"plan_interest": {"type": "string"},
"demo_requested": {"type": "boolean"}
},
"required": ["name", "email", "plan_interest", "demo_requested"],
"additionalProperties": False
}
}
}
},
)
# deepseek-v4-pro returns a thinking block; find the text content block
text_block = next(block for block in message.content if block.type == "text")
print(text_block.text)
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic",
});
async function main() {
// output_config is a Model Studio platform extension parameter that is not included
// in the SDK type definitions. Extend the official parameter type with an intersection
// type to pass it through, avoiding unsafe type assertions
type MessageCreateParamsWithOutputConfig =
Anthropic.MessageCreateParamsNonStreaming & {
output_config: {
format: {
type: "json_schema";
schema: Record<string, unknown>;
};
};
};
const params: MessageCreateParamsWithOutputConfig = {
model: "deepseek-v4-pro",
max_tokens: 1024,
messages: [{
role: "user",
content: "Extract key info from this email: John Smith (john@example.com) is interested in the Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."
}],
output_config: {
format: {
type: "json_schema",
schema: {
type: "object",
properties: {
name: { type: "string" },
email: { type: "string" },
plan_interest: { type: "string" },
demo_requested: { type: "boolean" }
},
required: ["name", "email", "plan_interest", "demo_requested"],
additionalProperties: false
}
}
}
};
const message = await anthropic.messages.create(params);
// deepseek-v4-pro returns a thinking block; find the content block with type='text'
const textBlock = message.content.find(
(block): block is Anthropic.TextBlock => block.type === "text"
);
console.log(textBlock?.text);
}
main().catch(console.error);
curl -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1/messages" \
-H "Content-Type: application/json" \
-H "x-api-key: $DASHSCOPE_API_KEY" \
-d '{
"model": "deepseek-v4-pro",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Extract key info from this email: John Smith (john@example.com) is interested in the Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."
}
],
"output_config": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"email": {"type": "string"},
"plan_interest": {"type": "string"},
"demo_requested": {"type": "boolean"}
},
"required": ["name", "email", "plan_interest", "demo_requested"],
"additionalProperties": false
}
}
}
}'
Non-streaming Response
idstring
Unique message identifier.
typestring
Fixed value: message.
rolestring
Fixed value: assistant.
modelstring
The model used for generation.
contentarray
The content array.
content array element types
Text
Properties
typestring
Fixed value: text.
textstring
The text response generated by the model.
Thinking (returned when Extended Thinking is enabled)
Properties
typestring
Fixed value: thinking.
thinkingstring
The model's reasoning before the final response.
signaturestring
Currently fixed as an empty string.
Tool use (function call scenario)
Properties
typestring
Fixed value: tool_use.
idstring
Unique tool call identifier, used to match the tool_result.
namestring
The name of the called tool.
inputobject
The input parameters of the tool call.
Server tool use (web search scenario; the model's server-side search request)
Properties
typestring
Fixed to server_tool_use.
idstring
Unique identifier of the server-side tool call.
namestring
The tool name, such as web_search.
inputobject
The input, containing a queries array (search queries generated by the model).
callerobject (Optional)
Caller information. A type of direct indicates the tool was invoked directly by the model.
Web search result (web search scenario; the search results returned by the server)
Properties
typestring
Fixed to web_search_tool_result.
tool_use_idstring
Corresponds to the id in server_tool_use.
contentarray
The search result array. Each element is a web_search_result object.
web_search_result properties
typestring
Fixed to web_search_result.
titlestring
The page title.
urlstring
The page URL.
encrypted_contentstring
Encrypted page content.
page_agestring or null
The page age. Can be null.
callerobject (Optional)
Caller information. A type of direct indicates the tool was invoked directly by the model.
NoteIn streaming calls, the usage field of the message_start event contains only input_tokens and output_tokens. The full fields (including cache_creation_input_tokens, cache_read_input_tokens, and server_tool_use) are returned in the message_delta event.
Properties
input_tokensinteger
Input tokens.
output_tokensinteger
Output tokens.
cache_creation_input_tokensinteger
Tokens consumed for cache creation.
cache_read_input_tokensinteger
Tokens consumed from cache reads.
server_tool_useobject (Optional)
Server-side tool usage statistics. Returned only when the request used a server-side tool (such as web search).
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
typestring
Fixed value: content_block_start.
indexinteger
0-based index corresponding to position in the content array.
content_blockobject
The initial object of the content block. The type value is text, thinking, tool_use, server_tool_use, or web_search_tool_result. 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. The web_search_tool_result carries the full content array in this event, not assembled from deltas.
content_block_delta
Incremental content block update. Multiple deltas sent per block.
Properties
typestring
Fixed value: content_block_delta.
indexinteger
The index of the associated content block.
deltaobject
Delta object. type values:
text_delta: Text delta, containing the text field.
thinking_delta: Thinking delta, containing the thinking field.
signature_delta: Signature delta, containing the signature field (currently fixed as an empty string).
input_json_delta: Tool call input parameter delta, containing the partial_json field.
content_block_stop
Marks the end of a content block.
Properties
typestring
Fixed value: content_block_stop.
indexinteger
The index of the ended content block.
message_delta
Message-level update event, sent after all content blocks end, containing the stop reason and the complete token usage statistics.
Properties
typestring
Fixed value: message_delta.
deltaobject
Contains stop_reason and stop_sequence. For valid values, see the Non-streaming Response table above.
usageobject
Complete token usage statistics, including input_tokens, output_tokens, cache_creation_input_tokens, and cache_read_input_tokens.
message_stop
Final event, marks message end.
Properties
typestring
Fixed value: message_stop.
In addition, streaming responses periodically send ping events ({"type":"ping"}) to keep the connection alive. Clients can ignore them.
Streaming response example
{"type":"message_start","message":{"id":"msg_xxx","type":"message","role":"assistant","model":"qwen3.8-max","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"}
FAQ
After configuring Claude Desktop or Claude Code, the connection test fails withModel discovery — Gateway /v1/models returned HTTP 404, or the request URL contains/v1/v1/models. How do I fix it?
The model discovery feature of clients such as Claude Desktop and Claude Code automatically appends /v1/models to the configured base URL. Check the following two points:
Do not end the base URL with/v1/as a suffix: it should end at /apps/anthropic (for example, for China (Beijing) use https://dashscope.aliyuncs.com/apps/anthropic; see the endpoint information above for other regions). If you mistakenly enter .../apps/anthropic/v1/, the client appends /v1/models and produces the duplicated path /v1/v1/models, which returns HTTP 404. Therefore, when you get a 404, first check whether the actual request URL contains a duplicated /v1/v1/; if so, remove the trailing /v1/ from the base URL.
Add models manually to skip discovery: the Model Studio Anthropic-compatible endpoint provides only the Messages API (/v1/messages) and does not provide a model list endpoint (/v1/models), so the model discovery request returns 404 as well. Manually add models (for example, qwen3.7-plus) under Models in the client to skip automatic discovery.