Use Anthropic SDKs
Call Qwen models through Anthropic-compatible APIs. To migrate from Anthropic, update these parameters:
Supported Qwen models:
For model parameters and billing, see Models.
- ANTHROPIC_API_KEY (or ANTHROPIC_AUTH_TOKEN): Your API key.
-
ANTHROPIC_BASE_URL:
https://dashscope-intl.aliyuncs.com/apps/anthropic. -
Model name (model): A supported Qwen model such as
qwen3.6-plus. See Supported models.
Quick integration
Supported models
Supported Qwen models:
| Series | Model name (model) |
|---|---|
| Qwen-Max (some support thinking) | qwen3-max, qwen3-max-2026-01-23 (supports thinking mode), qwen3-max-preview (supports thinking mode) |
| Qwen-Plus | qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen-plus, qwen-plus-latest, qwen-plus-2025-09-11 |
| Qwen-Flash | qwen-flash, qwen-flash-2025-07-28 |
| Qwen-Turbo | qwen-turbo, qwen-turbo-latest |
| Qwen-Coder (thinking not supported) | qwen3-coder-next, qwen3-coder-plus, qwen3-coder-plus-2025-09-23, qwen3-coder-flash |
| Qwen-VL (thinking not supported) | qwen3-vl-plus, qwen3-vl-flash, qwen-vl-max, qwen-vl-plus |
Configure environment variables
- Sign in to Qwen Cloud.
-
Set these environment variables:
ANTHROPIC_BASE_URL:https://dashscope-intl.aliyuncs.com/apps/anthropic.ANTHROPIC_API_KEYorANTHROPIC_AUTH_TOKEN: Your Qwen Cloud API key.
Either
ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN works -- set one. This guide uses ANTHROPIC_API_KEY.- macOS
- Windows
- Check your default shell type.
- Set environment variables for your shell:
- Apply the environment variables.
- Open a new terminal and verify the environment variables.
Call the API
- curl
- Python
- TypeScript
Compatibility details
HTTP header
| Field | Supported |
|---|---|
| x-api-key | Supported |
| Authorization Bearer | Supported |
| anthropic-beta/anthropic-version | Not supported |
Basic fields
| Field | Supported | Description | Example |
|---|---|---|---|
| model | Supported | Model name. See Supported models. | qwen-plus |
| max_tokens | Supported | Maximum tokens to generate. | 1024 |
| container | Not supported | - | - |
| mcp_servers | Not supported | - | - |
| metadata | Not supported | - | - |
| service_tier | Not supported | - | - |
| stop_sequences | Supported | Custom stop sequences for generation. | ["}"] |
| stream | Supported | Streaming output. | True |
| system | Supported | System prompt. | You are a helpful assistant |
| temperature | Supported | Controls text diversity. | 1.0 |
| thinking | Supported | Enables reasoning before responding. Supported by some models only (see Supported models). | {"type": "enabled", "budget_tokens": 1024} |
| top_k | Supported | Sampling candidate set size. | 10 |
| top_p | Supported | Nucleus sampling probability threshold. Controls text diversity. | 0.1 |
Set only one of temperature or top_p. Both control text diversity. See Text generation model overview.
Tool fields
tools
| Field | Supported |
|---|---|
| name | Supported |
| input_schema | Supported |
| description | Supported |
| cache_control | Supported |
tool_choice
| Value | Supported |
|---|---|
| none | Supported |
| auto | Supported |
| any | Supported |
| tool | Supported |
Message fields
| Field | Type | Subfield | Supported | Description |
|---|---|---|---|---|
| content | string | - | Supported | Text content. |
| array, type="text" | text | Supported | Text block content. | |
| cache_control | Supported | Cache control for this text block. | ||
| citations | Not supported | - | ||
| array, type="image" | source | Supported | Image source (base64 or URL). | |
| array, type="video" | - | Not supported | - | |
| array, type="document" | - | Not supported | - | |
| array, type="search_result" | - | Not supported | - | |
| array, type="thinking" | - | Not supported | - | |
| array, type="redacted_thinking" | - | Not supported | - | |
| array, type="tool_use" | id | Supported | Tool call identifier. | |
| input | Supported | Tool parameters. | ||
| name | Supported | Tool name. | ||
| cache_control | Supported | Cache control for this tool call. | ||
| array, type="tool_result" | tool_use_id | Supported | Corresponding tool_use ID. | |
| content | Supported | Tool result (string or JSON string). | ||
| cache_control | Supported | Cache control for this tool result. | ||
| is_error | Not supported | - | ||
| array, type="server_tool_use" | - | Not supported | - | |
| array, type="web_search_tool_result" | - | Not supported | - | |
| array, type="code_execution_tool_result" | - | Not supported | - | |
| array, type="mcp_tool_use" | - | Not supported | - | |
| array, type="mcp_tool_result" | - | Not supported | - | |
| array, type="container_upload" | - | Not supported | - |