Setup guide - Documented by Qwen
Use Qwen in Claude Code
Alibaba Cloud Model Studio publishes a dedicated Claude Code guide. Claude Code talks to Model Studio's Anthropic-compatible endpoint (/apps/anthropic) via ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, exported in the shell or set in ~/.claude/settings.json, with Qwen model ids mapped to the Haiku/Sonnet/Opus roles. Works with Pay-as-you-go, Coding Plan, and Token Plan keys.
Last verified 6 steps3 official sources
Steps
- Step 1.
Skip Anthropic login: edit or create ~/.claude.json (Windows: C:\Users\<username>\.claude.json) and set hasCompletedOnboarding to true.
JSON{ "hasCompletedOnboarding": true } - Step 2.
Pay-as-you-go: open or create ~/.claude/settings.json (Windows: C:\Users\<username>\.claude\settings.json). Replace YOUR_API_KEY with your Model Studio API key and {WorkspaceId} with your Workspace ID. The example uses Singapore.
JSON{ "env": { "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_BASE_URL": "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", "ANTHROPIC_MODEL": "qwen3.7-max", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash", "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.7-max", "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.7-max", "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.7-max" } } - Step 3.
Coding Plan alternative: use the Coding Plan API key (format sk-sp-xxxxx) and the Coding Plan Anthropic endpoint.
JSON{ "env": { "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_BASE_URL": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic", "ANTHROPIC_MODEL": "qwen3.7-plus", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.7-plus", "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.7-plus", "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.7-plus", "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.7-plus" } } - Step 4.
Token Plan (Personal or Team Edition) alternative: use the Token Plan API key with the Token Plan Anthropic endpoint.
JSON{ "env": { "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_BASE_URL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", "ANTHROPIC_MODEL": "auto", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash", "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-flash", "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-max", "CLAUDE_CODE_SUBAGENT_MODEL": "auto", "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616" } } - Step 5.
Optional 1M context: add CLAUDE_CODE_MAX_CONTEXT_TOKENS to env, or append [1m] to a model name that supports a 1M window (for example qwen3.7-plus[1m]).
JSON"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1000000" - Step 6.
Verify. If Claude Code connects to api.anthropic.com instead, run /status inside Claude Code and check that ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN point to the Model Studio address.
Terminalclaude -p "Hello"
Caveats
- Replace {WorkspaceId} with your actual Workspace ID. The page's 401 invalid_api_key FAQ lists https://dashscope-intl.aliyuncs.com/apps/anthropic as the pay-as-you-go base URL and says the API key type must match ANTHROPIC_BASE_URL.
- Coding Plan (sk-sp-...) and Token Plan keys are not interchangeable with the general Model Studio key (sk-...); mixing them causes 401s or unexpected pay-as-you-go charges.
- Coding Plan Pro supports only qwen3.7-plus, qwen3.6-plus, qwen3.5-plus, kimi-k2.5, glm-5 and MiniMax-M2.5, and forbids use from scripts or app backends.
- If the connection still fails, the Alibaba FAQ suggests updating Claude Code with npm install -g @anthropic-ai/claude-code@latest.
- Claude Code uses a 200K context window by default per the Alibaba guide; the 1M options only work on models that support that length.
More setup guides
Same tool, other providers
Related reading
- Qwen4-Max: Pricing, Benchmarks and What to TestQwen4-Max is live on QwenCloud at $1.50 input and $4.50 output per million tokens, down from $2 and $6 for Qwen3.8-Max. What is vendor-reported, what is missing, and a test plan.
- GVS5H: Can Qwen3.8-27B Match Fable 5 on Coding?GVS5H claims five Qwen3.8-27B instances match Fable 5 on LiveCodeBench Hard. What the harness does, why Hacker News doubts the benchmark, and what to copy.
- Run Qwen3.8-Flash-Next on a Gaming PC With StrataRun Qwen3.8-Flash-Next locally with Strata on a 12 GB GPU: hardware needs, speeds by quant, the license catch, and when the hosted API is the better call.
- Terminal-Universe Turns Agent Traces Into Training EnvironmentsTerminal-Universe, Qwen's paper on rebuilding terminal-agent trajectories into reusable environments, and why agent teams should keep replayable workspaces.
- Qwen3.8-27B vs Opus 4.6 Max: Local Agentic Coding BenchmarksQwen3.8-27B is a 27B dense Apache-2.0 model that beats Opus 4.6 Max on SWE-bench Pro (61.7 vs 53.4). Benchmarks, hardware, cost and when to run it.
- Qwen 3.8 Max Ships: 2.4T MoE, 1M Context, $2/$6 per MTok, Open Weights Next WeekQwen 3.8 Max is a 2.4T-parameter MoE with 95B active, a 1M context window and $2/$6 per million tokens on QwenCloud, with open weights promised next week.
FAQ
How do I use Qwen in Claude Code?
Alibaba Cloud Model Studio publishes a dedicated Claude Code guide. Claude Code talks to Model Studio's Anthropic-compatible endpoint (/apps/anthropic) via ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, exported in the shell or set in ~/.claude/settings.json, with Qwen model ids mapped to the Haiku/Sonnet/Opus roles. Works with Pay-as-you-go, Coding Plan, and Token Plan keys.
Which Qwen model ids work in Claude Code?
The official docs read for this guide list qwen3.7-max, qwen3.6-flash, qwen3.7-plus, qwen3.8-max, qwen3.8-flash and auto. Requests go to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic.
Is this an official Qwen and Claude Code setup?
Qwen documents this setup in its own docs. It was last checked against 3 official pages on November 8, 2026.
Sources
Last verified against 3 official pages.
- alibabacloud.comhttps://www.alibabacloud.com/help/en/model-studio/claude-code
- alibabacloud.comhttps://www.alibabacloud.com/help/en/model-studio/coding-plan
- alibabacloud.comhttps://www.alibabacloud.com/help/en/model-studio/more-tools
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.