Qwen Code

Updated at:

Use Alibaba Cloud Model Studio models in Qwen Code.

Quick Start

Choose your client and complete the configuration.

CLI

  1. 1

    Connect the provider

    Run qwen, select Alibaba ModelStudio on first use, and then select a billing plan when prompted.

  2. 2

    Select a region

    Select China (Beijing) as the region.

  3. 3

    Enter the API key

    Token Plan

    Use a Token Plan API key:

    Pay-as-you-go

    Use a Model Studio API key from the console.

    Coding Plan

    Use a Coding Plan API key from the console.

  4. 4

    Verify

    qwen -p "Hello"
    

Desktop

  1. 1

    Open model settings

    Click More > Settings > Models, then click + Add Model.

  2. 2

    Select the provider

    Select Alibaba ModelStudio as the type, Token Plan, Coding Plan, or Standard API Key as the provider, and China (Beijing) as the region.

  3. 3

    Enter the API key

  4. 4

    Select models and save

    Model IDs are prefilled; keep or add as needed. Click Save, then select the new model from the model list.

IDE plugin

  1. 1

    Install the extension

    Install Qwen Code Companion from your IDE's extension marketplace.

  2. 2

    Configure the model

    Add the configuration for your billing plan as described in Configuration file.

  3. 3

    Open Qwen Code

    Click the Qwen icon, or run Qwen Code: Open from the Command Palette.

Configuration file

In addition to the options above, you can also connect using a configuration file.

  1. 1

    Open or create the configuration file

    • macOS / Linux: ~/.qwen/settings.json
    • Windows: C:\Users\<username>\.qwen\settings.json
  2. 2

    Write the configuration

    Token Plan Personal Edition

    Get a Token Plan API key from the console and replace YOUR_API_KEY.

    {
      "$version": 4,
      "env": {
        "BAILIAN_TOKEN_PLAN_API_KEY": "YOUR_API_KEY"
      },
      "modelProviders": {
        "openai": [
          {
            "id": "auto",
            "name": "Token Plan auto",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.8-max",
            "name": "Qwen3.8 Max",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.8-flash",
            "name": "Qwen3.8 Flash",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.7-max",
            "name": "Qwen3.7 Max",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.7-plus",
            "name": "Qwen3.7 Plus",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.6-flash",
            "name": "Qwen3.6 Flash",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen-image-3.0-pro",
            "name": "Qwen Image 3.0 Pro",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen-audio-3.0-tts-plus",
            "name": "Qwen Audio 3.0 TTS Plus",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen-audio-3.0-realtime-plus",
            "name": "Qwen Audio 3.0 Realtime Plus",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen-audio-3.0-asr-flash",
            "name": "Qwen Audio 3.0 ASR Flash",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "wan2.7-image",
            "name": "Wan2.7 Image",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "wan2.7-image-pro",
            "name": "Wan2.7 Image Pro",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "wan3.0-video",
            "name": "Wan3.0 Video",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "deepseek-v4.1-flash",
            "name": "DeepSeek V4.1 Flash",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "deepseek-v4.1-flash-1017",
            "name": "DeepSeek V4.1 Flash 1017",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "deepseek-v4-pro",
            "name": "DeepSeek V4 Pro",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "deepseek-v4-pro-0813",
            "name": "DeepSeek V4 Pro 0813",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "deepseek-v4-flash-0731",
            "name": "DeepSeek V4 Flash 0731",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "glm-5.3",
            "name": "GLM-5.3",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "glm-5.2",
            "name": "GLM-5.2",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "happyhorse-1.1-i2v",
            "name": "HappyHorse 1.1 I2V",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "happyhorse-1.1-t2v",
            "name": "HappyHorse 1.1 T2V",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "happyhorse-1.1-r2v",
            "name": "HappyHorse 1.1 R2V",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "decision-model-preview",
            "name": "Decision Model Preview",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          }
        ]
      },
      "security": {
        "auth": {
          "selectedType": "openai"
        }
      },
      "model": {
        "name": "auto"
      }
    }
    

    Token Plan Team Edition

    Assign a seat and generate a Token Plan API key in team management, then replace YOUR_API_KEY.

    {
      "$version": 4,
      "env": {
        "BAILIAN_TOKEN_PLAN_TEAM_API_KEY": "YOUR_API_KEY"
      },
      "modelProviders": {
        "openai": [
          {
            "id": "auto",
            "name": "Token Plan auto",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen3.8-max",
            "name": "Qwen3.8 Max",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen3.8-flash",
            "name": "Qwen3.8 Flash",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen3.7-max",
            "name": "Qwen3.7 Max",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen3.7-plus",
            "name": "Qwen3.7 Plus",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen3.6-plus",
            "name": "Qwen3.6 Plus",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen3.6-flash",
            "name": "Qwen3.6 Flash",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen-image-2.0",
            "name": "Qwen Image 2.0",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen-image-2.0-pro",
            "name": "Qwen Image 2.0 Pro",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen-image-3.0-pro",
            "name": "Qwen Image 3.0 Pro",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen-audio-3.0-tts-plus",
            "name": "Qwen Audio 3.0 TTS Plus",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen-audio-3.0-realtime-plus",
            "name": "Qwen Audio 3.0 Realtime Plus",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "qwen-audio-3.0-asr-flash",
            "name": "Qwen Audio 3.0 ASR Flash",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "wan2.7-image",
            "name": "Wan2.7 Image",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "wan2.7-image-pro",
            "name": "Wan2.7 Image Pro",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "wan3.0-video",
            "name": "Wan3.0 Video",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "deepseek-v4.1-flash",
            "name": "DeepSeek V4.1 Flash",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "deepseek-v4.1-flash-1017",
            "name": "DeepSeek V4.1 Flash 1017",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "deepseek-v4-pro",
            "name": "DeepSeek V4 Pro",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "deepseek-v4-pro-0813",
            "name": "DeepSeek V4 Pro 0813",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "deepseek-v4-flash-0731",
            "name": "DeepSeek V4 Flash 0731",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "kimi-k2.7-code",
            "name": "Kimi K2.7 Code",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "kimi-k2.6",
            "name": "Kimi K2.6",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "kimi-k2.5",
            "name": "Kimi K2.5",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "glm-5.3",
            "name": "GLM-5.3",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "glm-5.2",
            "name": "GLM-5.2",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "glm-5.1",
            "name": "GLM-5.1",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "glm-5",
            "name": "GLM-5",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "MiniMax-M2.5",
            "name": "MiniMax M2.5",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "happyhorse-1.1-i2v",
            "name": "HappyHorse 1.1 I2V",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "happyhorse-1.1-t2v",
            "name": "HappyHorse 1.1 T2V",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          },
          {
            "id": "happyhorse-1.1-r2v",
            "name": "HappyHorse 1.1 R2V",
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_TEAM_API_KEY"
          }
        ]
      },
      "security": {
        "auth": {
          "selectedType": "openai"
        }
      },
      "model": {
        "name": "auto"
      }
    }
    

    Pay-as-you-go

    Get a Model Studio API key from the console and replace YOUR_API_KEY. Replace {WorkspaceId} with your Workspace ID. The example lists the latest models in China North 2 (Beijing); for other models, see supported models.

    {
      "$version": 4,
      "env": {
        "BAILIAN_API_KEY": "YOUR_API_KEY"
      },
      "modelProviders": {
        "openai": [
          {
            "id": "qwen3.8-max",
            "name": "Qwen3.8 Max",
            "baseUrl": "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_API_KEY"
          },
          {
            "id": "qwen3.7-plus",
            "name": "Qwen3.7 Plus",
            "baseUrl": "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_API_KEY"
          },
          {
            "id": "qwen3.8-flash",
            "name": "Qwen3.8 Flash",
            "baseUrl": "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_API_KEY"
          },
          {
            "id": "deepseek-v4-pro-0813",
            "name": "DeepSeek V4 Pro 0813",
            "baseUrl": "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_API_KEY"
          },
          {
            "id": "deepseek-v4.1-flash",
            "name": "DeepSeek V4.1 Flash",
            "baseUrl": "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_API_KEY"
          }
        ]
      },
      "security": {
        "auth": {
          "selectedType": "openai"
        }
      },
      "model": {
        "name": "qwen3.8-max"
      }
    }
    

    Coding Plan

    Get a Coding Plan API key from the console and replace YOUR_API_KEY.

    {
      "$version": 4,
      "env": {
        "BAILIAN_CODING_PLAN_API_KEY": "YOUR_API_KEY"
      },
      "modelProviders": {
        "openai": [
          {
            "id": "qwen3.7-plus",
            "name": "Qwen3.7 Plus",
            "baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
            "envKey": "BAILIAN_CODING_PLAN_API_KEY"
          },
          {
            "id": "qwen3.6-plus",
            "name": "Qwen3.6 Plus",
            "baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
            "envKey": "BAILIAN_CODING_PLAN_API_KEY"
          },
          {
            "id": "kimi-k2.5",
            "name": "Kimi K2.5",
            "baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
            "envKey": "BAILIAN_CODING_PLAN_API_KEY"
          },
          {
            "id": "glm-5",
            "name": "GLM-5",
            "baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
            "envKey": "BAILIAN_CODING_PLAN_API_KEY"
          },
          {
            "id": "MiniMax-M2.5",
            "name": "MiniMax M2.5",
            "baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
            "envKey": "BAILIAN_CODING_PLAN_API_KEY"
          },
          {
            "id": "qwen3.5-plus",
            "name": "Qwen3.5 Plus",
            "baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
            "envKey": "BAILIAN_CODING_PLAN_API_KEY"
          }
        ]
      },
      "security": {
        "auth": {
          "selectedType": "openai"
        }
      },
      "model": {
        "name": "qwen3.7-plus"
      }
    }
    

NoteThe variable name in env must match the model entry's envKey. Keep security.auth.selectedType set to openai and $version set to 4.

Integrate Bailian CLI

Bailian CLI registers a Skill at ~/.qwen/skills/bailian-cli/ during installation, allowing Qwen Code to invoke Bailian capabilities through conversation. Install Node.js 18+ before use.

  1. 1

    Install Bailian CLI

    Please install the Alibaba Cloud Bailian CLI globally: npm install -g bailian-cli
    
  2. 2

    Configure the API Key

    Get an API Key (Get from console), then tell Qwen Code:

    My API Key is: sk-xxxxxxxxxxxxx
    

    WarningAn API Key is a sensitive credential. Do not disclose it. A plaintext API Key pasted into the conversation may be retained in session logs. Use settings.json or an environment variable instead.

  3. 3

    Start using it

    Generate 6 Amazon e-commerce hero images for a white wireless Bluetooth headset.
    

Learn More

For more commands, sub-agents, MCP, Skills, and examples, see the Qwen Code documentation and examples.

Error Codes

If you encounter errors during configuration, refer to the FAQ documentation for your billing plan:

FAQ

How do I use savings plans and resource plans with pay-as-you-go?

The pay-as-you-go setup remains the same: use your general Model Studio API key and Base URL. After you purchase a savings plan or resource plan, it takes effect automatically and eligible usage is deducted automatically. See Savings plans and resource plans.

What if the model I want is missing after configuration?

Try the following in order:

  1. Upgrade Qwen Code to the latest version.
  2. If the model is still missing, add it manually under modelProviders.openai in ~/.qwen/settings.json, then restart Qwen Code. See Configuration file for details.

What should I do if the qwen command is not found after installation on Windows?

Close and reopen cmd so that the environment variable takes effect, then run qwen --version to confirm the installation.