Skip to main content

Anthropic-compatible Messages

Call models through the Anthropic-format-compatible Messages API, and view input and output parameter descriptions and calling examples.

By modifying the following configurations, you can migrate your existing Anthropic applications to Alibaba Cloud Model Studio:
  • api_key: Replace it with your Model Studio API Key.
  • base_url: Replace it with the compatible endpoint address of Model Studio (see the access information below).
  • model: Replace it with a model name supported by Model Studio (for example, qwen3.7-plus).
Alibaba Cloud Model Studio provides dedicated workspace domains for the China (Beijing), Singapore, and China (Hong Kong) regions, which deliver superior performance and higher stability for inference requests. We recommend that you migrate to the new domains:
  • China (Beijing) region: migrate from https://dashscope.aliyuncs.com to https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • Singapore region: migrate from https://dashscope-intl.aliyuncs.com to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
  • China (Hong Kong) region: migrate from https://cn-hongkong.dashscope.aliyuncs.com to https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com
{WorkspaceId} refers to your workspace ID, which you can view on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domains remain available.
  • Singapore
  • China (Beijing)
  • United States (Virginia)
  • Germany (Frankfurt)
  • Japan (Tokyo)
base_url for SDK calls: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropicHTTP request URL: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages
When making calls, replace {WorkspaceId} with your actual workspace ID. Authentication: pass in your Model Studio API Key through the x-api-key request header or the Authorization: Bearer request header. Either one is sufficient.

Major differences from the official Anthropic API

The following differences are summarized from this document. Pay close attention to them when migrating from the official Anthropic API:

Difference

Description

Endpoint (Base URL)

base_url must be replaced with the Model Studio compatible endpoint (e.g. https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic; see the access information above for endpoints in other regions), where {WorkspaceId} must be replaced with your actual Workspace ID.

Authentication Method

api_key must be replaced with a Model Studio API Key; it can be passed in via the x-api-key or Authorization: Bearer request header—either one is sufficient.

Model

model must be replaced with a model name supported by Model Studio (e.g. qwen3.7-plus); see the model parameter description below for the complete list.

temperature value range

Model Studio uses the range [0, 2), which differs from the official Anthropic range of [0.0, 1.0]; verify this parameter value when migrating.

API scope

Only the Messages API (/v1/messages) is provided; the model list API (/v1/models) is not. Client model discovery requests return 404; see the FAQ below for how to handle this.

Extension parameters

output_config (structured output and thinking effort 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 output" example on the right); thinking.budget_tokens is being deprecated—for new integrations, use output_config.effort to control the thinking effort.

Request body

model string (required)Model name. The supported models are as follows.
Qwen Max: qwen4-max, qwen3.8-max series, qwen3.7-max, qwen3.7-max-2026-05-20, qwen3.7-max-2026-06-08Qwen Plus: qwen3.7-plus, qwen3.7-plus-2026-05-26, 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-latestQwen Flash: qwen3.8-flash, qwen3.7-flash, qwen3.7-flash-2026-07-15, qwen3.6-flash, qwen3.6-flash-2026-04-16, qwen3.5-flash, qwen3.5-flash-2026-02-23, qwen-flash, qwen-flash-2025-07-28Qwen Coder: qwen3-coder-flashQwen VL: qwen3-vl-plusQwen open-source models: qwen3.6-27b, qwen3.5-397b-a17b, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b, qwen3.8-2.4t-a95b, qwen3.8-27bThird-party modelsdeepseek-v4.1-flash、deepseek-v4-pro、deepseek-v4-pro-0813、deepseek-v4-flash-0731、kimi-k3.1-pro、kimi-k3、kimi-k2.7-code、kimi-k2.6、kimi-k2.5、glm-5.3、glm-5.2、glm-5.1、glm-5、MiniMax-M2.5、deepseek-v4.1-flash-1017
max_tokens integer (required)
  • qwen4-max, deepseek-v4.1-flash, deepseek-v4-pro, deepseek-v4-pro-0813, deepseek-v4-flash-0731, qwen3.8-max series, qwen3.8-flash: the maximum total number of tokens for the model response plus chain-of-thought content; generation stops early if the output exceeds this value, with stop_reason set to max_tokens.
    max_tokens limits the length of the model response plus thinking process. When deep thinking is enabled, max_tokens > thinking.budget_tokens
  • glm-5.3: max_tokens is the maximum total number of tokens for the model response plus chain-of-thought content; generation stops early if the output exceeds this value, with stop_reason set to 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 number of tokens for the model response plus chain-of-thought content; generation stops early if the output exceeds this value, with stop_reason set to max_tokens. When the thinking.budget_tokens parameter is passed, max_tokens is only the maximum number of tokens for the model response, while the token count for the thinking portion is controlled separately by thinking.budget_tokens.
  • Other models: the maximum number of tokens for the model response. If the generated content exceeds this value, generation stops early, with stop_reason set to max_tokens.
    max_tokens does not limit the length of the thinking process. When deep thinking is enabled, the token count for the thinking portion is controlled separately by thinking.budget_tokens.
system string or array (optional)The 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 an explicit cache breakpoint for the system prompt (see the "Explicit Cache" example on the right), you must pass an array.
type string (required)Fixed to text.text string (required)The system prompt text.cache_control object (optional)Marks an explicit cache breakpoint on this content block (see the "Explicit Cache" example on the right). After a cache hit, the second and subsequent requests are billed as cache reads. It only contains the field type, whose value is fixed to ephemeral.
Only qwen4-max is supported. The content block cache marker for Qwen4 also supports ttl, with optional values 5m and 1h, defaulting to 5m. For more information, see Explicit Cache (Qwen4).type string (required)ephemeralttl string (optional)Cache validity period. Supports 5m and 1h, defaulting to 5m.
messages array (required)
role string (required)The message role. Valid values: user, assistant, and system.content string 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.
type stringthinkingthinking stringsignature stringThe thinking summary and signature ciphertext. Pass the complete thinking block back verbatim in subsequent requests.
Text Information
type string (required)Fixed to text.text string (required)The text content.cache_control object (optional)Marks an explicit cache breakpoint on this text block (see the "Explicit Cache" example on the right). It only contains the field type, whose value is fixed to ephemeral.
Only qwen4-max is supported. The content block cache marker for Qwen4 also supports ttl, with optional values 5m and 1h, defaulting to 5m. For more information, see Explicit Cache (Qwen4).type string (required)ephemeralttl string (optional)Cache validity period. Supports 5m and 1h, defaulting to 5m.
Image Information (requires a vision model)
type string (required)Fixed to image.source object (required)The image data source.
type string (required)Valid values: url (public image URL) and base64 (Base64 encoding).url stringThe public URL of the image. Required when type is url.media_type stringThe MIME type of the image, such as image/jpeg. Required when type is base64.data stringThe Base64-encoded image data. Required when type is base64.
Video information (requires a vision model)
type string (required)Fixed to video.source object (required)The source of the video data.
type string (required)Valid values: url (public video URL) and base64 (Base64 encoding).url stringThe public URL of the video. Required when type is url.media_type stringThe MIME type of the video, such as video/mp4. Required when type is base64.data stringThe Base64-encoded video data. Required when type is base64.
PDF document information
type string (required)Fixed to document.source object (required)The data source of the PDF document, which contains the following fields:
  • type (string): Required. The value is url or base64.
  • url (string): Required when source.type is url. Specifies the URL of the PDF file.
  • media_type (string): Required when source.type is base64. Set to application/pdf.
  • data (string): Required when source.type is base64. The Base64-encoded PDF data, without the Data URI prefix.
PDF understandingTool calling information (assistant role; tool calling instructions returned by the model)
type string (required)Fixed to tool_use.id string (required)The unique identifier of the tool call, used to correlate results in subsequent tool_result.name string (required)The name of the tool being called.input object (required)The input parameters of the tool call, whose structure is determined by the input_schema of the corresponding tool in tools.cache_control object (optional)Marks an explicit cache breakpoint on this block (see the "Explicit Cache" example on the right). Only contains the type field, fixed to ephemeral. The tool call content itself is included in the cache prefix.
Only qwen4-max is supported. The content block cache marker for Qwen4 also supports ttl, with optional values 5m and 1h, defaulting to 5m. For more information, see Explicit Cache (Qwen4).type string (required)ephemeralttl string (optional)Cache validity period. Supports 5m and 1h, defaulting to 5m.
Tool result information (user role; tool execution results returned to the model)
type string (required)Fixed to tool_result.tool_use_id string (required)Corresponds to the id in the tool_use information.content string (required)The content returned by tool execution.cache_control object (optional)Marks an explicit cache breakpoint on this tool result block (see the "Explicit Cache" example on the right). Only contains the type field, fixed to ephemeral.
Only qwen4-max is supported. The content block cache marker for Qwen4 also supports ttl, with optional values 5m and 1h, defaulting to 5m. For more information, see Explicit Cache (Qwen4).type string (required)ephemeralttl string (optional)Cache validity period. Supports 5m and 1h, defaulting to 5m.
cache_control object (optional)Only supported for qwen4-max. Enables automatic caching at the top level of the request, or you can set manual breakpoints on content blocks. type is fixed to ephemeral. The Python SDK passes top-level non-standard parameters via extra_body; the Node.js SDK and curl pass them directly. For more information, see Explicit Cache (Qwen4).
type string (required)ephemeralttl string (optional)Cache validity period. Supports 5m and 1h, defaulting to 5m.
stream boolean (optional)Whether to enable streaming output. The default is false.temperature number (optional)Controls the diversity of the generated text. The value range is [0, 2). Larger values lead to more random generation results.
This range differs from Anthropic's official [0.0, 1.0]. If you are migrating from Anthropic, confirm this parameter value.
top_p number (optional)The probability threshold for nucleus sampling, which controls the diversity of the generated text.
temperature and top_p both control the diversity of the generated text. We recommend setting only one of them. For more information, see Overview.
top_k integer (optional)The size of the sampling candidate set during generation.stop_sequences array (optional)Text sequences that stop generation. The model stops generating before this sequence, and the sequence itself is not included in the output.
When matched, the response's stop_reason is stop_sequence, and the matched sequence is returned in the response's stop_sequence field.
thinking object (optional)Deep thinking configuration. When enabled, the model performs reasoning before generating a reply to improve answer accuracy. When enabled, the response contains content blocks of the thinking type.When this parameter is not specified, whether to think is determined by the model's default behavior: qwen4-max, qwen3.8-max series, qwen3.8-flash, deepseek-v4 series, glm series, and kimi-k3.1-pro have thinking enabled by default; kimi-k2.6 and kimi-k2.5 have thinking disabled by default; kimi-k2.7-code and MiniMax-M2.5 support only thinking mode (it cannot be disabled). For each model's support for thinking mode and default settings, see Deep Thinking.
type string (required)Optional values: enabled (enables thinking mode) and disabled (disables thinking mode).budget_tokens integer (optional, to be deprecated)
This parameter is about to be deprecated and will gradually stop being supported in future models. For new integrations, we recommend using effort to control the model's thinking intensity.
The maximum number of tokens the thinking process can use. Its relationship with max_tokens varies by model. For more information, see the max_tokens parameter description. A larger budget results in more thorough analysis on complex problems. Takes effect when type is enabled.display string (optional)qwen4-max: "summarized". Chain-of-thought summary and encryption.The full chain of thought is returned by default. After this feature is enabled, the original chain of thought is no longer returned in plaintext; instead, a summary and the complete ciphertext are returned. The summary is for display, and the ciphertext is used to restore historical thinking.
tools array (optional)An array of tool definitions for Function Call scenarios.
name string (required)Tool name.description string (optional)The description of the tool's functionality.input_schema object (Required)The JSON Schema definition of the tool input parameters.
In addition to the custom tools above, tools also supports the Model Studio server-side web search tool. Declare it in tools to enable it—no client-side retrieval is required.
type string (required)The tool type, in the form of a value with a date suffix such as web_search_20250305. The date suffix does not need to be fixed; it just needs to match the value sent by the client.name string (required)Fixed as web_search.max_uses integer (Optional)The maximum number of retrievals per request.
When calling directly with the Anthropic SDK or HTTP, you must pass the client identifier x-anthropic-billing-header: cc_entrypoint=cli; in system; otherwise, web search does not take effect. For Anthropic official clients such as Claude Code, no additional configuration is required. For more information, see Web search.
The following models are supported: qwen4-max; Qwen3.8 Max, Flash, and open-source series (excluding Omni); Qwen3.7 Max, Plus, and Flash series; Qwen3.6-Plus and Qwen3.6-Flash series; Qwen3.5-Plus and 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 the same as the agent strategy. For more information, see Billing Details.
kimi-k3.1-pro (deployed on Alibaba Cloud Model Studio) supports web_search and web_fetch in Beijing, Singapore, the United States (Virginia), Germany (Frankfurt), Japan (Tokyo), and Hong Kong, China.deepseek-v4.1-flash-1017 also supports the web fetch tool web_fetch. For Anthropic-compatible request requirements and examples, see web fetch.qwen4-max: web_search, web_fetch.Add the Anthropic server-side web fetch tool (with name set to web_fetch) to the tools parameter to enable web fetch, and you must also add the web search tool (with name set to web_search) at the same time. The request URL is https://{WorkspaceId}.{region}.maas.aliyuncs.com/apps/anthropic.
type string (required)The tool type, in the form of a value with a date suffix such as web_fetch_20250910. The date suffix does not need to be fixed; it just needs to match the value sent by the client.name string (required)Fixed as web_fetch.max_uses integerThe maximum number of fetches per request.
tool_choice object (Optional)The tool selection strategy. The following values are supported:
  • {"type": "auto"}: The model decides on its own whether to call a tool (default).
  • {"type": "any"}: Forces the model to call any one tool.
  • {"type": "none"}: Prohibits the model from calling any tool.
  • {"type": "tool", "name": "tool_name"}: Forces the model to call a specified tool.
output_config object (Optional)Output parameter settings.
effort string (Optional)qwen4-maxValid values: low, high (default), and xhigh.medium maps to high, and max maps to xhigh.Controls the model's reasoning effort.The default value of kimi-k3.1-pro (deployed on Alibaba Cloud Model Studio) is max. It supports max (deep reasoning), high (enhanced reasoning), medium (medium reasoning), and low (light reasoning).
  • glm-5.3 (default value is max): Valid values:
    • low: low-effort reasoning
    • high: high-effort reasoning
    • max: maximum-effort reasoning
    Passing in other values returns an error.
  • glm-5.2, deepseek-v4-pro (default value is max): Valid values:
    • high: high-effort reasoning
    • max: maximum-effort reasoning
    low and medium are mapped to high, and xhigh is mapped to max.
  • qwen3.8-max series, qwen3.8-flash (default value is xhigh): Valid values:
    • xhigh: high-effort reasoning
    • medium: medium-effort reasoning
    • low: low-effort reasoning
    max and high are mapped to xhigh.
format object (Optional)Structured output configuration. When enabled, the model will output a JSON string. Different models provide different levels of support:
  • Strict structured output: Applicable to qwen3.8 series, qwen3.7 series, deepseek series (excluding deepseek-v4-flash-0731 and deepseek-v4-pro-0813), and glm series models. The model outputs strictly under the strong constraints of the passed-in JSON Schema, ensuring that field types and hierarchy are exactly consistent.
  • Standard structured output: Applicable to models other than those above. The specific field constraints in the Schema do not take effect by default, and the API automatically converts it to standard JSON mode (only guaranteeing that the output is a valid JSON string). To trigger standard JSON mode, the request must meet both of the following constraints: 1. explicitly pass in the output_config parameter; 2. the content of system or messages must contain the case-insensitive "JSON" keyword. If the prompt does not contain the "JSON" keyword, the API will throw an exception: 'messages' must contain the word 'json' in some form.
type string (required)The value is fixed to json_schema.schema object (Required)A JSON Schema object that follows the standard JSON Schema specification. It must include fields such as type (data type), properties (field definitions), required (array of required field names), and additionalProperties (must be set to false).
For more information, see Explicit Cache (Qwen4).input_tokens integerOnly counts input tokens that were neither read from the cache nor used for cache creation; the total input is the sum of this field and the cache read and cache creation token counts.output_tokens integerThe number of output tokens.cache_creation_input_tokens integerThe number of input tokens consumed for cache creation.cache_read_input_tokens integerThe number of input tokens consumed for cache reads.server_tool_use object (Optional)Server-side tool usage statistics. Returned only when server-side tools (such as web search) are used in the request.
web_search_requests integerThe number of web search retrievals.web_fetch_requests integerThe number of web page crawls.
cache_creation objectCache creation details broken down by TTL. The sum of token counts for the two TTLs equals the number of tokens used for this cache creation.
ephemeral_5m_input_tokens integerThe number of tokens used to create the 5-minute cache.ephemeral_1h_input_tokens integerThe number of tokens used to create the 1-hour cache.
prompt_tokens_details objectCache read details. cached_tokens is the same as cache_read_input_tokens; do not double-count them in usage statistics.
cached_tokens integerThe number of input tokens read from the cache.
  • Basic invocation
  • Streaming output
  • Deep thinking
  • Image Understanding
  • Video Understanding
  • Function Call
  • Explicit Cache
  • Structured output
Python
import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # Replace {WorkspaceId} with your actual workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

message = client.messages.create(
    model="qwen4-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)

Non-streaming response

id stringThe unique identifier of the message.type stringFixed as message.role stringFixed as assistant.model stringThe name of the model used.content arrayThe content array.
Text Information
type stringFixed to text.text stringThe text response generated by the model.
Thinking information (returned when deep thinking is enabled)
type stringFixed as thinking.thinking stringThe model's thinking process before generating the final response.signature stringqwen4-max, thinking.display="summarized": The thinking block of Anthropic Messages contains a thinking summary and a signature ciphertext. In streaming mode, thinking_delta is returned first, followed by the complete signature_delta; after the thinking block is closed, the body text or tool call is returned. If no thinking was generated or encryption fails, the signature may be an empty string.thinking.display != "summarized": Currently fixed as an empty string.
Tool call information (Function Call scenarios)
type stringFixed to tool_use.id stringThe unique identifier of the tool call, used to correlate results in subsequent tool_result.name stringThe name of the tool being called.input objectThe input parameters of the tool call.
Server-side tool call information (web search scenarios; the server-side retrieval request returned by the model)
type stringFixed as server_tool_use.id stringThe unique identifier of the server-side tool call.name stringThe tool name, such as web_search.input objectInput parameters, containing the queries array (the retrieval queries generated by the model).caller object (Optional)Caller information; type being direct indicates that the call was initiated directly by the model.
Web search result information (web search scenarios; the retrieval results returned by the server)
type stringFixed as web_search_tool_result.tool_use_id stringCorresponds to the id in server_tool_use.content arrayThe retrieval result array, whose elements are web_search_result objects.
type stringFixed as web_search_result.title stringThe page title.url stringThe page URL.encrypted_content stringThe encrypted page content.page_age string or nullThe page freshness, which can be null.
caller object (Optional)Caller information; type being direct indicates that the call was initiated directly by the model.
Web fetch result (web_fetch_tool_result)
FieldTypeDescription
typestringweb_fetch_tool_result
tool_use_idstringCorresponds to server_tool_use.id.
contentobjectFetch result.
content.typestringweb_fetch_result
content.urlstringThe page URL.
content.retrieved_atstringFetch time.
content.contentobjectThe page document.
content.content.typestringdocument
content.content.titlestringThe page title.
content.content.sourceobjectDocument content.
content.content.source.typestringtext
content.content.source.media_typestringtext/plain
content.content.source.datastringDocument content.
callerobjectCaller information.
caller.typestringdirect
stop_reason stringThe stop reason. Optional values: end_turn (normal completion), max_tokens (Token limit reached), tool_use (tool calling).stop_sequence stringFixed to null.usage objectToken usage statistics.
In streaming calls, the usage of the message_start event only contains input_tokens and output_tokens; the complete fields (including cache_creation_input_tokens, cache_read_input_tokens, and server_tool_use) are returned in the message_delta event.
input_tokens integerThe number of input tokens.output_tokens integerThe number of output tokens.cache_creation_input_tokens integerThe number of input tokens consumed for cache creation.cache_read_input_tokens integerThe number of input tokens consumed for cache reads.server_tool_use object (Optional)Server-side tool usage statistics. Returned only when server-side tools (such as web search) are used in the request.
web_search_requests integerThe number of web search retrievals.web_fetch_requests integerThe number of web page crawls.
  • Basic response
  • Web search response
The following is a response example of qwen3.8-max, used to illustrate response fields.
{
  "id": "msg_e2898f19-fc0e-4cb3-bd9b-5b7dc4ea3bc9",
  "type": "message",
  "role": "assistant",
  "model": "qwen3.8-max",
  "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
  }
}

Streaming response

message_startThe first event of the stream, marking the start of the message.
type stringFixed to message_start.message objectThe initial message object, with content as an empty array and usage containing only input_tokens and output_tokens.
content_block_startSent when each content block starts, marking the index and type of the new content block.
type stringFixed to content_block_start.index integerThe content block index, starting from 0, corresponding to the position in the content array of the message.content_block objectThe initial object of the content block. type values are text, thinking, tool_use, server_tool_use, or web_search_tool_result / web_fetch_tool_result. For the tool_use type, input is an empty object in this event, and the complete input parameters are incrementally assembled by subsequent content_block_delta events. web_search_tool_result carries the complete content array in this event, not incrementally assembled.
content_block_deltaThe incremental update event of a content block. Multiple such events are sent for the same content block.
type stringFixed to content_block_delta.index integerThe index of the content block it belongs to.delta objectThe incremental object, with type values:
  • text_delta: Text increment, containing the text field.
  • thinking_delta: Thinking increment, containing the thinking field.
  • signature_delta (signature): qwen4-max, thinking.display="summarized": The thinking block of Anthropic Messages contains a thinking summary and a signature ciphertext. In streaming, thinking_delta is returned first, then the complete signature_delta; after the thinking block is closed, the body text or tool call is returned; if no thinking is generated or encryption fails, signature may be an empty string. thinking.display != "summarized": signature="".
  • input_json_delta: Tool call input parameter increment, containing the partial_json field.
content_block_stopThe content block end event.
type stringFixed to content_block_stop.index integerThe index of the content block that ended.
message_deltaA message-level update event sent after all content blocks end, containing the stop reason and the complete token usage statistics.
type stringFixed as message_delta.delta objectContains stop_reason and stop_sequence; for the values, see the non-streaming response table above.usage objectThe complete token usage statistics, including input_tokens, output_tokens, cache_creation_input_tokens, and cache_read_input_tokens.
message_stopThe last event in the stream, marking the end of the message.
type stringFixed as message_stop.In addition, the streaming response periodically sends a ping event ({"type":"ping"}) to keep the connection alive, which clients can ignore.
Streaming response exampleThe following is a response example of qwen3.8-max, used to illustrate response fields.
{"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 in Claude Desktop or Claude Code, the connection test reports the errorModel discovery — Gateway /v1/models returned HTTP 404, or the request URL contains/v1/v1/models. How do I resolve this? The model discovery feature of clients such as Claude Desktop and Claude Code automatically appends /v1/models to the configured base URL. Troubleshoot based on the following two points:
  • The base URL should not use/v1/as a suffix: Enter the URL up to /apps/anthropic (for example, for China (Beijing) enter https://dashscope.aliyuncs.com/apps/anthropic; for addresses of other regions, see "Access information" above). If it is mistakenly entered as .../apps/anthropic/v1/, after the client appends /v1/models, the duplicated path /v1/v1/models is formed, resulting in HTTP 404. Therefore, when a 404 occurs, first check whether the actual request URL contains the duplicated /v1/v1/; if so, remove the /v1/ at the end of the base URL.
  • Manually add models to skip automatic discovery: The Model Studio Anthropic-compatible endpoint only provides the Messages API (/v1/messages) and does not provide a model list API (/v1/models), so the model discovery request itself also returns 404. Manually add the model (for example, qwen3.7-plus) in the client's Models to skip automatic discovery.