Skip to main content
Clients & tools

OpenCode

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.

Install OpenCode

  1. Install Node.js (v18.0 or later).
  2. Run the following command in the terminal to install OpenCode:
npm install -g opencode-ai
Run the following command to verify the installation. If a version number is displayed, the installation was successful.
opencode -v

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
Write the configuration for your chosen plan.

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.
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "bailian-token-plan": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Qwen Cloud",
      "options": {
        "baseURL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "qwen3.6-plus": {
          "name": "Qwen3.6 Plus",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 8192
            }
          }
        },
        "deepseek-v3.2": {
          "name": "DeepSeek V3.2"
        },
        "MiniMax-M2.5": {
          "name": "MiniMax M2.5"
        },
        "glm-5": {
          "name": "GLM-5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 8192
            }
          }
        }
      }
    }
  }
}

Coding Plan

Replace YOUR_API_KEY with the Coding Plan dedicated API Key. For available models, refer to Coding Plan supported models.
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "bailian-coding-plan": {
      "npm": "@ai-sdk/anthropic",
      "name": "Qwen Cloud",
      "options": {
        "baseURL": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "qwen3.6-plus": {
          "name": "Qwen3.6 Plus",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "qwen3.5-plus": {
          "name": "Qwen3.5 Plus",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "qwen3-max-2026-01-23": {
          "name": "Qwen3 Max 0123"
        },
        "qwen3-coder-next": {
          "name": "Qwen3 Coder Next"
        },
        "qwen3-coder-plus": {
          "name": "Qwen3 Coder Plus"
        },
        "MiniMax-M2.5": {
          "name": "MiniMax M2.5"
        },
        "glm-5": {
          "name": "GLM-5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "glm-4.7": {
          "name": "GLM-4.7",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "kimi-k2.5": {
          "name": "Kimi K2.5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        }
      }
    }
  }
}

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):
export DASHSCOPE_API_KEY="YOUR_API_KEY"
After saving, run 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: