All Products
Search
Document Center

Alibaba Cloud Model Studio:Claude Code

Last Updated:Jan 28, 2026

The Qwen series models in Alibaba Cloud Model Studio are compatible with the Anthropic API, allowing you to call them using Claude Code.

Important
  1. This document applies only to the international edition (Singapore region).

  2. This document applies only to the pay-as-you-go mode. If you have subscribed to the Model Studio Coding Plan and want to use it with Claude Code, see the Coding Plan documentation instead.

Getting started

If you are familiar with Claude Code, run the following commands to quickly connect to 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 Anthropic-compatible service provided by Model Studio 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 selection recommendations

Use the following models for different task types:

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

  • Daily coding tasks (such as writing functions and generating unit tests): Use qwen3-coder-plus.

  • Simple jobs (such as code formatting and explaining snippets): 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 first.

    If you encounter problems, see Create an Alibaba Cloud account.
  2. Activate Model Studio: Use your Alibaba Cloud account to go to the Model Studio platform. After you read and agree to the terms, 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 get a model inference free quota valid for 90 days. For more information, see the Free quota for new users.
Note

Charges are incurred if the quota is used up or expires. To avoid these charges, use the Free quota only feature. The actual fees are subject to the prices on 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, run the following command to install Claude Code.

    npm install -g @anthropic-ai/claude-code

Windows

To use Claude Code on Windows, install WSL or Git for Windows. Then, run the following command in WSL or Git Bash.

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 connect to Model Studio through the Anthropic-compatible interface, 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, run the following command to check the default shell type.

    echo $SHELL
  2. Set the environment variables based on the shell type. The commands are as follows:

    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, run the following command to apply the environment variables.

    Zsh

    source ~/.zshrc

    Bash

    source ~/.bash_profile
  4. Open a new terminal and run the following commands to 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, run the following commands to 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 run the following commands to check whether the environment variables have taken effect.

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

    PowerShell

    1. In PowerShell, run the following commands to 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 run the following commands to 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 have 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 parameters or incorrect data types for parameter values.

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 misspelled compatible interface or a model in the request header that does not exist.

429

rate_limit_error

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

500

api_error

A general 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: How to save tokens?

  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. You can also run /compact manually.

  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.