All Products
Search
Document Center

Alibaba Cloud Model Studio:Claude Code

Last Updated:Feb 06, 2026

The Qwen series models in Alibaba Cloud Model Studio are compatible with the Anthropic API. You can use them in Claude Code.

Important
  1. This document applies only to the international edition (Singapore region). Use only API keys created in the Singapore region.

  2. This document applies only to the pay-as-you-go mode. Coding Plan users must use dedicated base URLs and API keys. For details, see the Coding Plan documentation.

Getting started

If you are already familiar with Claude Code, quickly integrate with Model Studio:

export ANTHROPIC_BASE_URL=https://dashscope-intl.aliyuncs.com/apps/anthropic
export ANTHROPIC_API_KEY=YOUR_DASHSCOPE_API_KEY   # Replace YOUR_DASHSCOPE_API_KEY with your Model Studio API key
export ANTHROPIC_MODEL=qwen3-coder-plus # Replace with another supported model as needed.
claude

For detailed instructions, see Detailed steps.

Model configuration

Supported models

The Model Studio Anthropic API-compatible service supports the following Qwen models:

Series

Model

Qwen-Max

(Some models support thinking mode)

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

Qwen-Plus

qwen-plus, qwen-plus-latest, qwen-plus-2025-09-11 View more

Qwen-Flash

qwen-flash, qwen-flash-2025-07-28 View more

Qwen-Turbo

qwen-turbo, qwen-turbo-latest View more

Qwen-Coder

(Does not support thinking mode)

qwen3-coder-plus, qwen3-coder-plus-2025-09-23, qwen3-coder-flash View more

Qwen-VL

(Does not support thinking mode)

qwen-vl-max, qwen-vl-plus

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

Model recommendations

Use the following models for different task types:

  • Complex reasoning tasks, such as designing application architecture or implementing complex algorithms: Use Qwen-Max series models or qwen3-coder-plus.

  • Simple coding tasks, such as writing functions or generating code comments: Use Qwen-Flash series models or qwen3-coder-flash.

Detailed steps

1. Activate Model Studio

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

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

    If a message indicates that you have not completed identity verification, complete identity verification first.
After you activate Model Studio for the first time, you receive a free quota for model inference valid for 90 days. For more information, see the Free quota for new users.
Note

Charges apply if the quota is used up or expires. To avoid these charges, use the Free quota only feature. Actual fees depend on the prices shown in the console and your final bill.

2. Install Claude Code

macOS

  1. Install or update Node.js to version 18.0 or later.

  2. In the terminal, install Claude Code:

    npm install -g @anthropic-ai/claude-code
  3. Verify the installation: If a version number appears, the installation succeeded.

    claude --version

Windows

To use Claude Code on Windows, install WSL or Git for Windows. Then, in WSL or Git Bash, install Claude Code:

npm install -g @anthropic-ai/claude-code
For more information, see the official Claude Code Windows installation tutorial.

3. Configure the base URL, API key, and model

To access the model service in Model Studio using an Anthropic API-compatible method, configure the following environment variables.

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

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

    You need to set only one of ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN. This topic uses ANTHROPIC_API_KEY as an example.
  3. ANTHROPIC_MODEL: Set this to a supported model from the Model list.

macOS

  1. In the terminal, check the default shell type:

    echo $SHELL
  2. Set the environment variables based on the shell type:

    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-coder-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-coder-plus"' >> ~/.bash_profile
  3. In the terminal, apply the environment variables:

    Zsh

    source ~/.zshrc

    Bash

    source ~/.bash_profile
  4. In the terminal, check whether the environment variables have taken effect:

    echo $ANTHROPIC_BASE_URL
    echo $ANTHROPIC_API_KEY
    echo $ANTHROPIC_MODEL

Windows

  1. On Windows, use CMD or PowerShell to set the base URL and API key provided by Model Studio as environment variables.

    CMD

    1. In CMD, set the environment variables:

      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-coder-plus"
    2. Open a new CMD window and check whether the environment variables have taken effect:

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

    PowerShell

    1. In PowerShell, set the environment variables:

      # 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-coder-plus", [EnvironmentVariableTarget]::User)
    2. Open a new PowerShell window and check whether the environment variables have taken effect:

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

4. Run claude code

Go to the project directory and run the claude command in the terminal.

claude

The first time you use claude code, you might need to log on to an Anthropic account. To skip it:

image

  1. Locate the .claude.json file in your user home directory:

    • macOS / Linux: ~/.claude.json

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

  2. Set hasCompletedOnboarding to true.

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

(Optional) More ways to configure models

Claude Code supports the following model configuration methods, listed in descending order of priority. A higher-priority configuration overwrites a lower-priority one.

  1. During a conversation: Run /model <model_name> to switch models. This method is suitable for temporarily switching models.

    /model qwen3-coder-plus
  2. When starting claude code: Run claude --model <model_name> to specify a model. This method is suitable for a single session.

    claude --model qwen3-coder-plus
  3. Set environment variables: Use different models based on task complexity. Claude Code automatically selects the appropriate model based on the task type. This method is suitable for global applications.

    export ANTHROPIC_DEFAULT_OPUS_MODEL="qwen3-coder-plus"
    export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen3-coder-plus"
    export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3-coder-flash"

    Where:

    • ANTHROPIC_DEFAULT_OPUS_MODEL: Used for high-difficulty tasks such as complex reasoning and architecture design.

    • ANTHROPIC_DEFAULT_SONNET_MODEL: Used for daily tasks such as code writing and feature implementation.

    • ANTHROPIC_DEFAULT_HAIKU_MODEL: Used for simple jobs such as syntax checking and file searching.

  4. Set permanently in the settings.json configuration file: Create a settings.json file in the project root directory or user home directory and add the model configuration information. This method allows for permanent configuration at the project or user level.

    {
      "env": {
        "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3-coder-plus",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3-coder-plus",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3-coder-flash"
      }
    }

Error codes

HTTP status code

Error type

Description

400

invalid_request_error

The request format or content is invalid. This can be caused by missing required request parameters or incorrect data types for parameter values.

400

Arrearage

The service is paused due to an overdue payment. Add funds to your account and then retry the request.

403

authentication_error

The API key is invalid. This can be caused by a missing API key in the request header or an incorrect API key.

404

not_found_error

The requested resource was not found. This can be caused by a typo in the compatible API endpoint or a non-existent model specified in the request header.

429

rate_limit_error

The account has reached its rate limit. Reduce the request frequency.

500

api_error

An internal server error occurred. Retry the request later.

529

overloaded_error

The API server is currently overloaded and cannot process new requests.

FAQ

Question 1: After starting claude code, the interface displays "Unable to connect to Anthropic services. Failed to connect to api.anthropic.com: ERR_BAD_REQUEST". What should I do?

image

Configure the environment variables again, and then run the claude command in the terminal.

Question 2: My tokens are consumed too quickly. How do I save tokens?

Claude Code scans the entire project directory, reads relevant code files, and maintains full conversation history to provide coding suggestions. As a result, token consumption is much higher than in typical chat scenarios. Use the following methods to control consumption:

  1. Reduce irrelevant files: To avoid token consumption from scanning irrelevant files, start Claude Code in a specific project directory and keep only the necessary project files.

  2. Summarize conversations: Claude Code uses the conversation history as context. When the conversation length reaches 95% of the context window, Claude Code automatically summarizes the content. Run /compact manually if needed.

  3. Use precise instructions: Vague requests can trigger unnecessary file scans and consume more tokens. Ask clear and specific questions or provide precise instructions when using Claude Code.

  4. Break down tasks: When handling complex tasks, break them down into several simple jobs.

  5. Reset context: Before starting a new task, use /clear to reset the context and prevent irrelevant information from consuming tokens.

For more tips on saving tokens, see the official Claude Code documentation. To view your exact token consumption and expense details, see Bill inquiry and cost management.