Call models through the Anthropic-format-compatible Messages API, and view input and output parameter descriptions and calling examples.
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).
- 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{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) |
|
Authentication Method |
|
Model |
|
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 ( |
Extension parameters |
|
Request bodymodelstring (required)Model name. The supported models are as follows.
List of supported models 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 integer (required)
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.
Attributes 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.
Attributes (Qwen4) 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.array (required)
messages array elements 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.
content array element types
thinking (qwen4-max) type stringthinkingthinking stringsignature stringThe thinking summary and signature ciphertext. Pass the complete thinking block back verbatim in subsequent requests.
Attributes 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.
Attributes (Qwen4) 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.
Attributes type string (required)Fixed to image.source object (required)The image data source.
Attributes 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.
Attributes type string (required)Fixed to video.source object (required)The source of the video data.
Attributes 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.
Attributes type string (required)Fixed to document.source object (required)The data source of the PDF document, which contains the following fields:
Attributes 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.
Attributes (Qwen4) 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.
Attributes 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.
Attributes (Qwen4) 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.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).
Attributes type string (required)ephemeralttl string (optional)Cache validity period. Supports 5m and 1h, defaulting to 5m.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. number (optional)The probability threshold for nucleus sampling, which controls the diversity of the generated text.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.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.
Attributes 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 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.array (optional)An array of tool definitions for Function Call scenarios.
tools array element 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.tools also supports the Model Studio server-side web search tool. Declare it in tools to enable it—no client-side retrieval is required.
Web search tool 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
The following models are supported: 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.
web_fetch (qwen4-max) 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.object (Optional)The tool selection strategy. The following values are supported:
object (Optional)Output parameter settings.
Attributes 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).
object (Optional)Structured output configuration. When enabled, the model will output a JSON string. Different models provide different levels of support:
Attributes 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).
Attributes (Qwen4) 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.
Attributes web_search_requests integerThe number of web search retrievals.web_fetch_requests integerThe number of web page crawls.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.
Attributes 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.objectCache read details. cached_tokens is the same as cache_read_input_tokens; do not double-count them in usage statistics.
Attributes cached_tokens integerThe number of input tokens read from the cache. |
Python |
Non-streaming responseidstringThe unique identifier of the message.type stringFixed as message.role stringFixed as assistant.model stringThe name of the model used.content arrayThe content array.
content array element types Text Information
Attributes type stringFixed to text.text stringThe text response generated by the model.
Attributes 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.
Attributes 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.
Attributes 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.
Attributes 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.
web_search_result properties 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.object (Optional)Caller information; type being direct indicates that the call was initiated directly by the model.web_fetch_tool_result)
Web fetch result
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.
Attributes 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.
Attributes web_search_requests integerThe number of web search retrievals.web_fetch_requests integerThe number of web page crawls. |
The following is a response example of qwen3.8-max, used to illustrate response fields. |
Streaming responsemessage_startThe first event of the stream, marking the start of the message.
Attributes 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.
Attributes 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.
Attributes type stringFixed to content_block_delta.index integerThe index of the content block it belongs to.delta objectThe incremental object, with type values:
Attributes type stringFixed to content_block_stop.index integerThe index of the content block that ended.
Attributes 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.
Attributes 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. |
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) enterhttps://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/modelsis 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.