Terminal AI coding assistant
OpenCode is a terminal AI coding tool. Connect it to Qwen Cloud via Token Plan (Team Edition), Coding Plan, or pay-as-you-go billing.
Run the following command to verify the installation. If a version number is displayed, the installation was successful.
Open the following file with a text editor:
Replace
Replace
OpenCode has a built-in
After saving, run
After saving the configuration, restart OpenCode, type
If you encounter errors during configuration, refer to the FAQ documentation for the corresponding billing plan:
Install OpenCode
- Install Node.js (v18.0 or later).
- Run the following command in the terminal to install OpenCode:
Configure access credentials
Open the following file with a text editor:
- macOS / Linux:
~/.config/opencode/opencode.json - Windows:
C:\Users\<username>\.config\opencode\opencode.json
Token Plan (Team Edition)
Replace YOUR_API_KEY with the Token Plan (Team Edition) dedicated API Key. For available models, refer to Token Plan (Team Edition) supported models.
Coding Plan
Replace YOUR_API_KEY with the Coding Plan dedicated API Key. For available models, refer to Coding Plan supported models.
Pay-as-you-go
OpenCode has a built-in Alibaba (China) provider. You can use the Qwen Cloud pay-as-you-go service by setting an environment variable, without creating a configuration file.
Replace YOUR_API_KEY with your Qwen Cloud API Key. For available models, refer to OpenAI compatible - Supported models.
Add the following to your shell configuration file (such as ~/.bashrc or ~/.zshrc):
source ~/.bashrc or source ~/.zshrc to apply the configuration.
Verify configuration
After saving the configuration, restart OpenCode, type /models, search for Qwen Cloud (for pay-as-you-go, search for Alibaba (China)), and select the model you want to use to start a conversation.
FAQ
Error codes
If you encounter errors during configuration, refer to the FAQ documentation for the corresponding billing plan:
- Pay-as-you-go: Error codes and troubleshooting
- Coding Plan: Coding Plan FAQ
- Token Plan (Team Edition): Token Plan (Team Edition) FAQ