Qwen Code is a terminal-based AI coding tool that can be connected to Alibaba Cloud Model Studio via pay-as-you-go, Coding Plan, or Token Plan (Team Edition).
Install Qwen Code
-
Run the installation command
-
macOS/Linux:
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 -
Windows:
Type
cmdin the taskbar search box, select Run as administrator, and run the following command in thecmdwindow to install Qwen Code.curl -fsSL -o %TEMP%\install-qwen.bat https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.bat && %TEMP%\install-qwen.bat --source bailian
-
-
Close and reopen the
cmdwindowOn Windows, after installation is complete, close the current
cmdwindow to apply the environment variables. Reopencmdand run the following command to check the installed version.qwen --version
Configure Access Credentials
Launch Qwen Code and type /auth for visual configuration. Alibaba Cloud Model Studio offers three billing plans. Choose based on your needs:
-
Token Plan (Team Edition): Subscription per seat, with token consumption deducted from Credits.
-
Coding Plan: Fixed monthly subscription, metered by model invocation count.
-
Pay-as-you-go: Post-paid based on actual usage.
Token Plan (Team Edition)
Launch Qwen Code and type /auth, then select Subscription Plan > Alibaba Cloud Model Studio Token Plan, and enter the Token Plan (Team Edition) dedicated API Key to complete the configuration. For available models, see Token Plan (Team Edition) supported models.
Coding Plan
Launch Qwen Code and type /auth, then select Subscription Plan > Alibaba Cloud Model Studio Coding Plan, choose the Coding Plan region (global), and enter the Coding Plan dedicated API Key to complete the configuration. For available models, see Coding Plan supported models.
Pay-as-you-go
Launch Qwen Code and type /auth, select Use your own API Key > Standard API Key, then choose the region and enter the Alibaba Cloud Model Studio API Key to complete the configuration. For available models, see OpenAI-compatible - Supported Models.
Verify Configuration
After configuration is complete, run the following command in your project directory to launch Qwen Code and start a conversation.
qwen
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.
-
Open VS Code, search for
Qwen Code Companionin the Extensions Marketplace and install it. -
The CLI and IDE plugin share the same
settings.json. If you have already completed the configuration above, skip this step. Otherwise, follow the Configure Access Credentials section above. -
Click the icon in the upper-right corner to launch Qwen Code. Type or click
/, then selectSwitch modelto switch models.
JetBrains IDE
Ensure your JetBrains IDE supports Agent Client Protocol (ACP) before use.
-
Qwen Code IDE depends on Qwen Code CLI. First, follow the Install Qwen Code section in this document to install and complete Configure Access Credentials.
-
Open JetBrains IDE, go to the AI Chat page, and click Install Plugin. IDEA will install the JetBrains AI Assistant plugin.
-
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/qwenwith the Qwen Code installation path. Run the following command to find the path:-
macOS/Linux:
which qwen -
Windows:
where qwen(CMD) orGet-Command qwen(PowerShell)
{ "agent_servers": { "qwen": { "command": "/path/to/qwen", "args": ["--acp"], "env": {} } } } -
-
After configuration, Qwen Code will appear in the AI Chat panel. You can switch models in the lower-right corner.
Common Commands
The following commands apply to Qwen Code CLI. The IDE plugin only supports some commands. Please refer to actual usage.
|
Command |
Description |
Example |
|
|
Switch the model used in the current session. |
|
|
|
Change the authentication method. |
|
|
|
Analyze the current directory and create an initial context file (QWEN.md) for defining project-level instructions and context. |
|
|
|
Clear the terminal screen and start a new conversation. |
|
|
|
Replace chat history with a summary to save tokens. |
|
|
|
Open the settings editor to configure language, theme, and more. |
|
|
|
Generate a project summary based on the conversation history. |
|
|
|
Resume a previous conversation session. |
|
|
|
Display detailed statistics for the current session. |
|
|
|
Display help information for available commands. |
|
|
|
Exit Qwen Code. |
|
For more advanced features of Qwen Code, see the Qwen Code official documentation.
Learn More
-
For advanced features such as sub-agents, MCP, and Skills in Qwen Code, see the Qwen Code official documentation.
-
For Qwen Code use cases, see Use Cases.
FAQ
Error Codes
If you encounter errors during configuration, refer to the FAQ documentation for your billing plan:
-
Pay-as-you-go: Error codes
-
Coding Plan: Coding Plan FAQ
-
Token Plan (Team Edition): Token Plan (Team Edition) FAQ
How to switch models?
Type the /model command directly in Qwen Code to select and switch from the list of models configured in settings.json. To add a new model, add the corresponding configuration under settings.json in the modelProviders section, then restart Qwen Code.