Skip to main content
Watch: I Built an AI App Without Leaving Databricks

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

  1. Step 1.

    Install Claude Code (Node.js v18.0 or later), then verify the install.

    Terminal
    npm install -g @anthropic-ai/claude-code
    claude --version
  2. Step 2.

    Skip Anthropic login: edit or create ~/.claude.json (Windows: C:\Users\<username>\.claude.json) and set hasCompletedOnboarding to true.

    JSON
    {
      "hasCompletedOnboarding": true
    }
  3. 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, Singapore https://{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"
        }
    }
  4. 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"
        }
    }
  5. 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"
        }
    }
  6. 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"
  7. 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.

    Terminal
    claude "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.

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.

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.