Skip to main content
Connect AI Tools

Qwen Code

Official terminal-based AI coding tool

When using qwen4-max-preview, the default output limit is 32768; for longer output, set generationConfig.samplingParams.max_tokens in the model entry.

Common scenarios

Qwen Code supports the following scenarios:
  • AI-assisted coding: Generate, complete, and review code from the terminal using natural language to speed up everyday development.
  • Web development: Provide a screenshot of a target website, and Qwen Code parses the page structure to generate high-fidelity front-end code.
  • Video production: Given an open-source repository URL, generate a dedicated promotional video in one step.

Install Qwen Code

  • macOS/Linux
  • Windows
Open a terminal and run the following command to install Qwen Code.
bash -c "$(curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.sh)" -s --source bailian

Add a model

Choose your client and complete the configuration.
  • CLI
  • Desktop
  • IDE plugin
1

Connect the provider

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

Select a region

Select Singapore as the region.
3

Enter the API key

  • Token Plan
  • Pay-as-you-go
Use a Token Plan API key from the console.
4

Verify

qwen -p "Hello"

Configuration file

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

Open or create the configuration file

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

Write the configuration

  • Token Plan Individual
  • Token Plan Team Edition
  • Pay-as-you-go
Get a Token Plan API key from the console and replace YOUR_API_KEY.
{
  "$version": 4,
  "env": {
    "QWENCLOUD_TOKEN_PLAN_API_KEY": "YOUR_API_KEY"
  },
  "modelProviders": {
    "openai": [
      {
        "id": "auto",
        "name": "[Token Plan Individual] auto",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen4-max-preview",
        "name": "[Token Plan Individual] qwen4-max-preview",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen3.8-max",
        "name": "[Token Plan Individual] qwen3.8-max",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen3.8-flash",
        "name": "[Token Plan Individual] qwen3.8-flash",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen3.7-max",
        "name": "[Token Plan Individual] qwen3.7-max",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen3.7-plus",
        "name": "[Token Plan Individual] qwen3.7-plus",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen3.6-flash",
        "name": "[Token Plan Individual] qwen3.6-flash",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen-image-3.0-pro",
        "name": "[Token Plan Individual] qwen-image-3.0-pro",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen-audio-3.0-tts-plus",
        "name": "[Token Plan Individual] qwen-audio-3.0-tts-plus",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen-audio-3.0-realtime-plus",
        "name": "[Token Plan Individual] qwen-audio-3.0-realtime-plus",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "qwen-audio-3.0-asr-flash",
        "name": "[Token Plan Individual] qwen-audio-3.0-asr-flash",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "wan2.7-image",
        "name": "[Token Plan Individual] wan2.7-image",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "wan2.7-image-pro",
        "name": "[Token Plan Individual] wan2.7-image-pro",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "wan3.0-video",
        "name": "[Token Plan Individual] wan3.0-video",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "deepseek-v4.1-flash",
        "name": "[Token Plan Individual] deepseek-v4.1-flash",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "deepseek-v4.1-flash-1017",
        "name": "[Token Plan Individual] deepseek-v4.1-flash-1017",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "deepseek-v4-pro",
        "name": "[Token Plan Individual] deepseek-v4-pro",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "deepseek-v4-pro-0813",
        "name": "[Token Plan Individual] deepseek-v4-pro-0813",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "deepseek-v4-flash-0731",
        "name": "[Token Plan Individual] deepseek-v4-flash-0731",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "glm-5.3",
        "name": "[Token Plan Individual] glm-5.3",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "glm-5.2",
        "name": "[Token Plan Individual] glm-5.2",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "happyhorse-1.1-i2v",
        "name": "[Token Plan Individual] happyhorse-1.1-i2v",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "happyhorse-1.1-t2v",
        "name": "[Token Plan Individual] happyhorse-1.1-t2v",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "happyhorse-1.1-r2v",
        "name": "[Token Plan Individual] happyhorse-1.1-r2v",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      },
      {
        "id": "decision-model-preview",
        "name": "[Token Plan Individual] decision-model-preview",
        "baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
        "envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
      }
    ]
  },
  "security": {
    "auth": {
      "selectedType": "openai"
    }
  },
  "model": {
    "name": "auto"
  }
}
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 the QwenCloud CLI

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

Install the CLI

Please install the QwenCloud CLI globally: npm install -g @qwencloud/qwencloud-cli
2

Configure the API Key

Get an API Key from the 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

Start using it

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

Qwen Code IDE plugins

Qwen Code supports usage as a plugin in VS Code and JetBrains IDE, providing AI coding capabilities within the IDE.

VS Code

Ensure your VS Code version is 1.85.0 or higher before use.
  1. Open VS Code, search for Qwen Code Companion in the Extensions Marketplace and install it.
  2. The CLI and IDE plugin share the same settings.json. If you have already completed the configuration above, skip this step. Otherwise, follow the Add a model section above.
  3. Click the icon in the upper-right corner to launch Qwen Code. Type or click /, then select Switch model to switch models.

JetBrains IDE

Ensure your JetBrains IDE supports Agent Client Protocol (ACP) before use.
  1. Qwen Code IDE depends on Qwen Code CLI. First, follow the Install Qwen Code section in this document to install and complete Add a model.
  2. Open JetBrains IDE, go to the AI Chat page, and click Install Plugin. IDEA will install the JetBrains AI Assistant plugin.
  3. Click the three-dot menu in the upper-right corner of the AI Chat window, select Add Custom Agent, and fill in the following configuration. Replace /path/to/qwen with the Qwen Code installation path. Run the following command to find the path:
    • macOS/Linux: which qwen
    • Windows: where qwen (CMD) or Get-Command qwen (PowerShell)
{
  "agent_servers": {
    "qwen": {
      "command": "/path/to/qwen",
      "args": ["--acp"],
      "env": {}
    }
  }
}
  1. After configuration, Qwen Code will appear in the AI Chat panel. You can switch models in the lower-right corner.

Qwen Code Desktop

Qwen Code Desktop is the GUI application of Qwen Code with a built-in CLI runtime, requiring no additional command-line tool installation. The desktop version shares the same settings.json configuration file with the CLI. If you have already completed configuration through the CLI, the desktop version is ready to use without additional setup. Visit the Qwen Code GitHub Releases page to download the desktop installer for your operating system (macOS, Windows, or Linux). If you have not configured yet, you can do so through the desktop GUI:
  1. Open Qwen Code Desktop, click Settings on the left sidebar, and select the AI tab.
  2. In the Model Provider section, click + Connect.
  3. In the popup, select the QwenCloud tab and choose the billing plan that suits your needs:
    • Token Plan: For teams, billed by token consumption.
    • Standard API Key: Pay-as-you-go with an existing QwenCloud API Key.
  4. Enter the API Key as prompted to complete the configuration.

Common commands

The following commands apply to Qwen Code CLI. The IDE plugin only supports some commands. Please refer to actual usage.
CommandDescriptionExample
/modelSwitch the model used in the current session./model
/authChange the authentication method./auth
/initAnalyze the current directory and create an initial context file (QWEN.md)./init
/clearClear the terminal screen and start a new conversation./clear
/compressReplace chat history with a summary to save tokens./compress
/settingsOpen the settings editor to configure language, theme, and more./settings
/summaryGenerate a project summary based on the conversation history./summary
/resumeResume a previous conversation session./resume
/statsDisplay detailed statistics for the current session./stats
/helpDisplay help information for available commands./help or /?
/quitExit Qwen Code./quit
For more advanced features of Qwen Code, see the Qwen Code official documentation.

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

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.