Migrate your Anthropic application to Model Studio by changing three settings. This topic covers the request and response parameters with code examples.
api_key: Replace with the Model Studio API key.base_url: Replace with a Model Studio endpoint listed below.model: Replace with a supported model name, such asqwen3.7-plus.
- China (Beijing)
- Singapore
- US (Virginia)
- Germany (Frankfurt)
- Japan (Tokyo)
base_url:https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropicHTTP request URL:POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1/messages{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) |
|
Authentication |
|
Model names |
|
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 ( |
Extended parameters |
|
Request Bodymodelstring (Required)Model name. Supported models:
Supported Models Qwen-Max: qwen4-max, qwen3.8-max, qwen3.8-max-0902, 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)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 type string (Required)Fixed value: text.text string (Required)The system prompt text.cache_control object (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.
Properties (Qwen4) Supported only by qwen4-max. Qwen4 content block cache markers also support ttl: 5m or 1h, default 5m. See Explicit cache (Qwen4).type string (Required)ephemeralttl string (Optional)Cache TTL. Supports 5m and 1h; defaults to 5m.array (Required)
messages array element role string (Required)The message role. Valid values: user, assistant, 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 reasoning summary and encrypted signature. Replay the complete thinking block unchanged in subsequent requests.
Properties type string (Required)Fixed value: text.text string (Required)The text content.cache_control object (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.
Properties (Qwen4) Supported only by qwen4-max. Qwen4 content block cache markers also support ttl: 5m or 1h, default 5m. See Explicit cache (Qwen4).type string (Required)ephemeralttl string (Optional)Cache TTL. Supports 5m and 1h; defaults to 5m.
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 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.
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 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.
Properties type string (Required)Fixed value: document.source object (Required)The PDF document source contains the following fields:
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)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.
Properties (Qwen4) Supported only by qwen4-max. Qwen4 content block cache markers also support ttl: 5m or 1h, default 5m. See Explicit cache (Qwen4).type string (Required)ephemeralttl string (Optional)Cache TTL. Supports 5m and 1h; defaults to 5m.
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)Content returned by the tool.cache_control object (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.
Properties (Qwen4) Supported only by qwen4-max. Qwen4 content block cache markers also support ttl: 5m or 1h, default 5m. See Explicit cache (Qwen4).type string (Required)ephemeralttl string (Optional)Cache TTL. Supports 5m and 1h; defaults to 5m.object (Optional)Supported only by qwen4-max. Enables automatic caching at the request root; manual breakpoints can also be set on content blocks. type is fixed to ephemeral. Pass non-standard top-level parameters through extra_body in the Python SDK, or directly in the Node.js SDK and curl. See Explicit cache (Qwen4).
Properties type string (Required)ephemeralttl string (Optional)Cache TTL. Supports 5m and 1h; defaults to 5m.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.This range is different from the official Anthropic range of [0.0, 1.0]. When migrating from Anthropic, verify the value of this parameter. number (Optional)Nucleus sampling probability threshold that controls the diversity of generated text.Bothtop_k integer (Optional)Candidate set size during sampling.stop_sequences array (Optional)Text sequences that stop generation. The model stops outputting before the matched sequence, and the sequence itself is not included.After a match, the stop_reason in the response is stop_sequence, and the matched sequence is returned in the response's stop_sequence field.object (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, 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.
Properties type string (Required)Valid values: enabled (enable thinking mode), disabled (disable thinking mode).budget_tokens integer (Optional, to be deprecated)
This parameter will be deprecated and will gradually stop being supported in subsequent models. For new integrations, we recommend using 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.display string (optional)qwen4-max: "summarized". Thinking summary and encryption.Full thinking is returned by default. When enabled, raw thinking is no longer returned in plaintext: the model returns a summary for display and the encrypted full thinking for restoring reasoning history.array (Optional)Tool definitions for function calling.
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.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 type string (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.name string (Required)Fixed to web_search.max_uses integer (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
Supported models: 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.qwen4-max: web_search, web_fetch.Add the Anthropic server-side web fetch tool (name set to web_fetch) to the tools parameter to enable the web extractor. You must also add the web search tool (name set to web_search) in the same request. The endpoint is https://{WorkspaceId}.{region}.maas.aliyuncs.com/apps/anthropic.
web_fetch (qwen4-max) type string (Required)The tool type, such as web_fetch_20250910 with a date suffix. The date suffix does not need to be fixed; keep it consistent with the value sent by the client.name string (Required)Fixed to web_fetch.max_uses integerMaximum fetch calls per request.object (Optional)Tool selection strategy. Supported values:
object (Optional)Output parameter settings.
Properties effort string (Optional)qwen4-maxSupported values: low, high (default), and xhigh.medium maps to high; max maps to xhigh.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).
object (Optional)Structured output configuration. When enabled, the model returns a JSON string. Behavior varies by model:
Properties type string (Required)Fixed value: json_schema.schema object (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).
Properties (Qwen4) See Explicit cache (Qwen4).input_tokens integerOnly input tokens that are neither read from nor written to the cache. Total input is the sum of this field, cache reads, and cache writes.output_tokens integerOutput tokens.cache_creation_input_tokens integerTokens consumed for cache creation.cache_read_input_tokens integerTokens consumed from cache reads.server_tool_use object (Optional)Server-side tool usage statistics. Returned only when the request used a server-side tool (such as web search).
Properties web_search_requests integerThe number of web search requests.web_fetch_requests integerNumber of web fetch requests.objectCache write details grouped by TTL. The sum of tokens for both TTLs equals the total tokens written to the cache in this request.
Properties ephemeral_5m_input_tokens integerTokens written to a 5-minute cache.ephemeral_1h_input_tokens integerTokens written to a 1-hour cache.objectCache read details. cached_tokens equals cache_read_input_tokens; do not add the two values together.
Properties cached_tokens integerInput tokens read from the cache. |
Python |
Non-streaming ResponseidstringUnique message identifier.type stringFixed value: message.role stringFixed value: assistant.model stringThe model used for generation.content arrayThe content array.
content array element types Text
Properties type stringFixed value: text.text stringThe text response generated by the model.
Properties type stringFixed value: thinking.thinking stringThe model's reasoning before the final response.signature stringqwen4-max, thinking.display="summarized": An Anthropic Messages thinking block contains a thinking summary and an encrypted signature. Streaming emits thinking_delta first, then a complete signature_delta; text or tool calls follow after the thinking block closes. The signature may be empty if encryption fails or no thinking is generated.thinking.display != "summarized": Currently fixed as an empty string.
Properties type stringFixed value: tool_use.id stringUnique tool call identifier, used to match the tool_result.name stringThe name of the called tool.input objectThe input parameters of the tool call.
Properties type stringFixed to server_tool_use.id stringUnique identifier of the server-side tool call.name stringThe tool name, such as web_search.input objectThe input, containing a queries array (search queries generated by the model).caller object (Optional)Caller information. A type of direct indicates the tool was invoked directly by the model.
Properties type stringFixed to web_search_tool_result.tool_use_id stringCorresponds to the id in server_tool_use.content arrayThe search result array. Each element is a web_search_result object.
web_search_result properties type stringFixed to web_search_result.title stringThe page title.url stringThe page URL.encrypted_content stringEncrypted page content.page_age string or nullThe page age. Can be null.object (Optional)Caller information. A type of direct indicates the tool was invoked directly by the model.web_fetch_tool_result)
Web fetch result
stringReason generation stopped. Valid values: end_turn (normal completion), max_tokens (token limit reached), tool_use (tool call).stop_sequence stringAlways null.usage objectToken usage statistics.In 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_tokens integerInput tokens.output_tokens integerOutput tokens.cache_creation_input_tokens integerTokens consumed for cache creation.cache_read_input_tokens integerTokens consumed from cache reads.server_tool_use object (Optional)Server-side tool usage statistics. Returned only when the request used a server-side tool (such as web search).
Properties web_search_requests integerThe number of web search requests.web_fetch_requests integerNumber of web fetch requests. |
The following response example uses qwen3.8-max to illustrate the response fields. |
Streaming Responsemessage_startFirst stream event, marks message start.
Properties type stringFixed value: message_start.message objectThe initial message object. content is an empty array, and usage contains only input_tokens and output_tokens.
Properties type stringFixed value: content_block_start.index integer0-based index corresponding to position in the content array.content_block objectThe initial object of the content block. The type value is text, thinking, tool_use, server_tool_use, or web_search_tool_result / web_fetch_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.
Properties type stringFixed value: content_block_delta.index integerThe index of the associated content block.delta objectDelta object. type values:
Properties type stringFixed value: content_block_stop.index integerThe index of the ended content block.
Properties type stringFixed value: message_delta.delta objectContains stop_reason and stop_sequence. For valid values, see the Non-streaming Response table above.usage objectComplete token usage statistics, including input_tokens, output_tokens, cache_creation_input_tokens, and cache_read_input_tokens.
Properties type stringFixed value: message_stop.In addition, streaming responses periodically send ping events ({"type":"ping"}) to keep the connection alive. Clients can ignore them. | Streaming response exampleThe following response example uses qwen3.8-max to illustrate the response fields. |
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) usehttps://dashscope.aliyuncs.com/apps/anthropic; see the endpoint information above for other regions). If you mistakenly enter.../apps/anthropic/v1/, the client appends/v1/modelsand 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.