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 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 7 steps3 official sources
Steps
- Step 1.
Install Claude Code (Node.js v18.0 or later), then verify the install.
Terminalnpm install -g @anthropic-ai/claude-code claude --version - Step 2.
Skip Anthropic login: edit or create ~/.claude.json (Windows: C:\Users\<username>\.claude.json) and set hasCompletedOnboarding to true.
JSON{ "hasCompletedOnboarding": true } - Step 3.
Pay-as-you-go: create ~/.claude/settings.json. Replace YOUR_API_KEY with your Model Studio API key and {WorkspaceId} with your Workspace ID. Region base URLs: Beijing
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic, Singaporehttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic, US (Virginia)https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/apps/anthropic. The API key must match the region.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 4.
Coding Plan alternative: use the Coding Plan dedicated 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 5.
Token Plan (Personal or Team Edition) alternative: use the Token Plan dedicated 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 6.
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 7.
Verify: open a new terminal and run claude "hello". Then run /status inside Claude Code and check that ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN point to the Model Studio address.
Terminalclaude "hello"
Caveats
- Pay-as-you-go base URLs are workspace-scoped: replace {WorkspaceId} with your actual Workspace ID, and the API key must belong to the same region.
- 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.
- The install command (npm install -g @anthropic-ai/claude-code) is copied from the Alibaba page; Anthropic's own docs may recommend a different installer.
- 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
- 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.
- Qwen-UI-Agent Points at the Next GUI Agent RuntimeQwen-UI-Agent, Alibaba's GUI agent report, reads best as a product spec: mobile, desktop, browser, CLI and DeepSearch combined in one stateful agent runtime.
- $500 RL Fine-Tune of a 9B Open Model Beat GPT-5.6 Sol and Claude Opus 4.8 on Catalog ReviewA $500 GRPO fine-tune of Qwen 3.5 9B beat GPT-5.6 Sol and Opus 4.8 on catalog review, hitting 97% accuracy at a fraction of the cost per listing.
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 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 October 17, 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.