Skip to main content

Qwen Code

Use Alibaba Cloud Model Studio models in Qwen Code.

Quick Start

Choose your client and complete the configuration.
  • CLI
  • Desktop
  • IDE plugin
  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 Singapore as the region.
  3. 3

    Enter the API key

    • Token Plan
    • Pay-as-you-go
    • Coding Plan
    Use a Token Plan API key:
  4. 4

    Verify

    qwen -p "Hello"
    

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
    • Token Plan Team Edition
    • Pay-as-you-go
    • Coding Plan
    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.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen4-max",
            "name": "Qwen4 Max",
            "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.8-max",
            "name": "Qwen3.8 Max",
            "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.8-flash",
            "name": "Qwen3.8 Flash",
            "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.7-max",
            "name": "Qwen3.7 Max",
            "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.7-plus",
            "name": "Qwen3.7 Plus",
            "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "qwen3.6-flash",
            "name": "Qwen3.6 Flash",
            "baseUrl": "https://token-plan.ap-southeast-1.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.ap-southeast-1.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.ap-southeast-1.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.ap-southeast-1.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.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "wan2.7-image",
            "name": "Wan2.7 Image",
            "baseUrl": "https://token-plan.ap-southeast-1.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.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "wan3.0-video",
            "name": "Wan3.0 Video",
            "baseUrl": "https://token-plan.ap-southeast-1.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.ap-southeast-1.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.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "deepseek-v4-pro",
            "name": "DeepSeek V4 Pro",
            "baseUrl": "https://token-plan.ap-southeast-1.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.ap-southeast-1.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.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "glm-5.3",
            "name": "GLM-5.3",
            "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "glm-5.2",
            "name": "GLM-5.2",
            "baseUrl": "https://token-plan.ap-southeast-1.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.ap-southeast-1.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.ap-southeast-1.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.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          },
          {
            "id": "decision-model-preview",
            "name": "Decision Model Preview",
            "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
            "envKey": "BAILIAN_TOKEN_PLAN_API_KEY"
          }
        ]
      },
      "security": {
        "auth": {
          "selectedType": "openai"
        }
      },
      "model": {
        "name": "auto"
      }
    }
    
    When using qwen4-max, the default output limit is 32768. For longer output, set generationConfig.samplingParams.max_tokens in the model entry. qwen4-max has a 1M-token context. The maximum output is 131,072 tokens in non-thinking mode and 262,144 tokens for thinking and the final answer combined. The defaults are reasoning_effort=high and thinking_budget=131072.
The 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
    
    An 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

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, it takes effect automatically and eligible usage is deducted automatically. See Savings plans.
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.
Close and reopen cmd so that the environment variable takes effect, then run qwen --version to confirm the installation.