Skip to main content
Watch: Anthropic Just Hit the Brakes on Its Next AI Model

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

  1. Step 1.

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

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

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

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.

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.