All Products
Search
Document Center

Alibaba Cloud Model Studio:Claude Code

Last Updated:Mar 03, 2026

Claude Code works with Qwen models through Alibaba Cloud Model Studio's Anthropic API-compatible interface.

Important

This document applies only to the international mode (Singapore region). Only use Model Studio API keys created in the Singapore region.

Getting started

If you are already familiar with Claude Code, these commands get you started quickly:

Important

This document applies only to pay-as-you-go mode. Coding Plan users must use your exclusive base URL and API key instead. For details, see Coding Plan for Claude Code.

export ANTHROPIC_BASE_URL=https://dashscope-intl.aliyuncs.com/apps/anthropic
export ANTHROPIC_API_KEY=YOUR_DASHSCOPE_API_KEY
export ANTHROPIC_MODEL=qwen3.5-plus # Replace with other models listed in this document

claude

For detailed configuration instructions, see Detailed steps.

Model availability

Supported models

Model Studio's Anthropic API-compatible service supports:

Series

Supported model name (model)

Qwen-Max

(Some models support thinking mode)

qwen3-max, qwen3-max-2026-01-23 (supports thinking mode), qwen3-max-preview (supports thinking mode) See more

Qwen-Plus

qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen-plus, qwen-plus-latest, qwen-plus-2025-09-11 See more

Qwen-Flash

qwen3.5-flash, qwen3.5-flash-2026-02-23, qwen-flash, qwen-flash-2025-07-28 See more

Qwen-Turbo

qwen-turbo, qwen-turbo-latest See more

Qwen-Coder

(Does not support thinking mode)

qwen3-coder-next, qwen3-coder-plus, qwen3-coder-plus-2025-09-23, qwen3-coder-flash See more

Qwen-VL

(Does not support thinking mode)

qwen3-vl-plus, qwen3-vl-flash, qwen-vl-max, qwen-vl-plus See more

Open-source Qwen

qwen3.5-397b-a17b, qwen3.5-120b-a10b, qwen3.5-27b, qwen3.5-35b-a3b

For model parameters and billing rules, see the Model list.

Recommendations

Recommended models by task type:

  • Complex inference tasks (such as designing application architectures, implementing complex algorithms): Qwen-Plus series (upgraded to Qwen3.5), Qwen-Max series, qwen3-coder-next (combines coding capabilities with response speed), and qwen3-coder-plus.

  • Simple coding tasks (such as writing functions, generating code comments): Qwen-Flash series and qwen3-coder-next.

Detailed steps

1. Activate Model Studio

  1. Create an account: If you do not have an Alibaba Cloud account, first create one.

    If you encounter issues, see Create an Alibaba Cloud account.
  2. Activate Model Studio: Use your Alibaba Cloud account to go to the Model Studio console. After you read and agree to the terms, Model Studio automatically activates. If the Terms of Service do not appear, the service is already activated.

    If a message "You have not completed identity verification" appears, first complete identity verification.
First-time users can get a free quota (valid for 90 days). For details, see the Free quota for new users page.
Note

Exceeding the quota or validity period will incur fees. Use the Free quota only feature to prevent fees in this situation. Actual costs are based on the console's real-time quotes and final bills.

2. Install Claude Code

macOS

  1. Install Node.js v18.0 or later.

  2. Install Claude Code from the terminal:

    npm install -g @anthropic-ai/claude-code
  3. Verify the installation:

    claude --version

Windows

Claude Code on Windows requires WSL or Git for Windows. Install it from WSL or Git Bash:

npm install -g @anthropic-ai/claude-code
For details, see the Windows installation tutorial in the Claude Code documentation.

3. Configure base URL, API key, and model

Configure these environment variables to connect Claude Code to Model Studio:

  1. Set ANTHROPIC_BASE_URL to https://dashscope-intl.aliyuncs.com/apps/anthropic.

  2. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN to your Model Studio API key.

    ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN can be used for access authentication. Set only one. The examples below use ANTHROPIC_API_KEY as an example.
  3. Set ANTHROPIC_MODEL to a supported model from the Model list.

Important

This document applies only to pay-as-you-go mode. Coding Plan users must use your exclusive base URL and API key instead. For details, see Coding Plan for Claude Code.

macOS

  1. Check your default shell type:

    echo $SHELL
  2. Set the environment variables for your shell:

    Zsh

    # Replace YOUR_DASHSCOPE_API_KEY with your Model Studio API key
    echo 'export ANTHROPIC_BASE_URL="https://dashscope-intl.aliyuncs.com/apps/anthropic"' >> ~/.zshrc
    echo 'export ANTHROPIC_API_KEY="YOUR_DASHSCOPE_API_KEY"' >> ~/.zshrc
    echo 'export ANTHROPIC_MODEL="qwen3.5-plus"' >> ~/.zshrc

    Bash

    # Replace YOUR_DASHSCOPE_API_KEY with your Model Studio API key
    echo 'export ANTHROPIC_BASE_URL="https://dashscope-intl.aliyuncs.com/apps/anthropic"' >> ~/.bash_profile
    echo 'export ANTHROPIC_API_KEY="YOUR_DASHSCOPE_API_KEY"' >> ~/.bash_profile
    echo 'export ANTHROPIC_MODEL="qwen3.5-plus"' >> ~/.bash_profile
  3. Apply the changes:

    Zsh

    source ~/.zshrc

    Bash

    source ~/.bash_profile
  4. Verify the environment variables:

    echo $ANTHROPIC_BASE_URL
    echo $ANTHROPIC_API_KEY
    echo $ANTHROPIC_MODEL

Windows

  1. Set the Model Studio Base URL and API key as environment variables using CMD or PowerShell.

    CMD

    1. Set the environment variables in CMD:

      REM Replace YOUR_DASHSCOPE_API_KEY with your Model Studio API key
      setx ANTHROPIC_API_KEY "YOUR_DASHSCOPE_API_KEY"
      setx ANTHROPIC_BASE_URL "https://dashscope-intl.aliyuncs.com/apps/anthropic"
      setx ANTHROPIC_MODEL "qwen3.5-plus"
    2. Open a new CMD window and verify:

      echo %ANTHROPIC_API_KEY%
      echo %ANTHROPIC_BASE_URL%
      echo %ANTHROPIC_MODEL%

    PowerShell

    1. Set the environment variables in PowerShell:

      # Replace YOUR_DASHSCOPE_API_KEY with your Model Studio API key
      [Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "YOUR_DASHSCOPE_API_KEY", [EnvironmentVariableTarget]::User)
      [Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://dashscope-intl.aliyuncs.com/apps/anthropic", [EnvironmentVariableTarget]::User)
      [Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "qwen3.5-plus", [EnvironmentVariableTarget]::User)
    2. Open a new PowerShell window and verify:

      echo $env:ANTHROPIC_API_KEY
      echo $env:ANTHROPIC_BASE_URL
      echo $env:ANTHROPIC_MODEL 

4. Run Claude Code

Navigate to your project directory and run claude:

claude

On first launch, Claude Code may prompt you to log in to an Anthropic account. Skip this step as follows:

image

  1. Open the .claude.json file in your home directory:

    • macOS / Linux: ~/.claude.json

    • Windows: C:\Users\%USERNAME%\.claude.json

  2. Set the value of the hasCompletedOnboarding field to true.

    {
      "hasCompletedOnboarding": true
    }
  3. Save the file, then rerun claude in a new terminal.

(Optional) Additional model configuration methods

Claude Code supports several ways to configure models, listed from highest to lowest priority:

  1. During a conversation: Use /model <model_name> to switch models. This is useful for temporary changes.

    /model qwen3.5-plus
  2. When starting Claude Code: Use claude --model <model_name> to specify a model for a single session.

    claude --model qwen3.5-plus
  3. Set environment variables: Assign different models to tasks of varying complexity. Claude Code automatically selects the appropriate model. This applies globally.

    export ANTHROPIC_DEFAULT_OPUS_MODEL="qwen3.5-plus"
    export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen3.5-plus"
    export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3-coder-next"

    where:

    • ANTHROPIC_DEFAULT_OPUS_MODEL: For difficult tasks, such as complex inference and architecture design.

    • ANTHROPIC_DEFAULT_SONNET_MODEL: For daily tasks, such as writing code and implementing features.

    • ANTHROPIC_DEFAULT_HAIKU_MODEL: For simple tasks, such as syntax checks and file searches.

  4. Set permanently in settings.json: Create a settings.json file in the project root or user home directory with the model configuration. This creates a permanent setting.

    {
      "env": {
        "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.5-plus",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.5-plus",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3-coder-next"
      }
    }

Error codes

HTTP status code

Error type

Description

400

invalid_request_error

The request format or content is invalid. Common causes include missing required request parameters or incorrect data types for parameter values.

400

Arrearage

Your account has an overdue payment. Service is paused. Recharge your account and try again.

403

authentication_error

The API key is invalid. Common causes include missing the API key in the request header or providing an incorrect API key.

404

not_found_error

The requested resource was not found. Common causes include a typo in the compatible endpoint or a model name that does not exist in the request header.

429

rate_limit_error

Your account has reached its rate limit. Reduce your request frequency.

500

api_error

A general internal server error occurred. Try again later.

529

overloaded_error

The API server is overloaded and cannot process new requests at this time.

FAQ

Question 1: After starting Claude Code, the interface shows “Unable to connect to Anthropic services.” What should I do?

image

Reconfigure the environment variables, then run claude again.

Question 2: Tokens are consumed too quickly. How to save tokens?

Claude Code scans your project directory, reads code files, and maintains conversation history, consuming significantly more tokens than standard chat. These methods help reduce token usage:

  1. Remove unrelated files: Start Claude Code from your specific project directory with only essential files. Scanning irrelevant files wastes tokens.

  2. Summarize the conversation: Claude Code includes past messages as context. At 95% of the context window, it automatically summarizes the history. To summarize manually, type /compact.

  3. Use precise instructions: Vague requests trigger unnecessary file scans. Ask clear, specific questions to minimize token waste.

  4. Break tasks into smaller steps: For complex tasks, split them into several simple jobs.

  5. Reset the context: Before starting a new task, type /clear to reset the context and avoid wasting tokens on irrelevant history.

For more token-saving tips, see the official Claude Code documentation. For token usage and expense details, see Bill query and cost management.