OpenCode Setup Guide
Install OpenCode and switch models in both the terminal and desktop app.
Use case: OpenCode is an open-source AI coding tool available in both terminal and desktop versions. This guide follows the sequence: install OpenCode → configure an LLM API Gateway model → switch models in the terminal or desktop app → verify the setup.
| Setting | Recommended value | Notes |
|---|---|---|
| Base URL | https://api.llm-token.cn/v1 | Start with the root path that includes /v1; remove it if the client reports an error. |
| API Key | sk-xxxxxxxx | Enter your complete LLM API Gateway Key. |
| Model ID | Full model name from the model list | It must match exactly. |
1. Install OpenCode
Choose any installation method. After installation, confirm that running opencode in the terminal starts the application.
| System / method | Command |
|---|---|
| npm | |
| macOS / Linux Homebrew | |
| Install script | |
For the desktop app, download the installer from the official website: https://opencode.ai/. The terminal and desktop versions can share the same model configuration.
2. Add the LLM API Gateway Provider with CC Switch
If you already use CC Switch, follow the screenshots below to add a custom provider.
- Open CC Switch and select the option to add a custom provider.
- Enter a provider name, such as "LLM API Gateway."
- Set the Base URL to
https://api.llm-token.cn/v1. - Enter your complete Key in the API Key field.
- Enter the full model name from the model list in the Model ID field.
CC Switch screen used with OpenCode, showing that no provider has been a…
Add-provider screen for OpenCode and CC Switch, with fields for provider…
3. Switch Models in the Terminal
- Open a terminal and run
opencode. - After OpenCode starts, press
Ctrl + P. - Find Switch Model and press Enter.
- Scroll to the custom-model list and select the model you just configured.
opencode
OpenCode terminal interface with the current GPT-5.5 OpenAI model displa…
Ctrl + P
OpenCode terminal command menu with Switch model highlighted and the ctr…
OpenCode Select model screen showing built-in models and a custom gpt-5.…
4. Use the Desktop App
Open the OpenCode desktop app, find the model configured through CC Switch in the model selector, and select it to begin.
Dark OpenCode desktop interface with the Big Pickle model option highlig…
OpenCode desktop model menu showing options such as GPT-4 nano and GPT-4…
5. Verification and Troubleshooting
| Symptom | Resolution |
|---|---|
| opencode does not start | Reopen the terminal and confirm that the npm or brew installation path is included in PATH. |
| The custom model is missing | Confirm that CC Switch saved the configuration, then restart OpenCode. |
| The request fails | Check the Base URL, API Key, and model ID. Start with https://api.llm-token.cn/v1. |
| The model responds slowly | Test a faster model, such as claude-sonnet-4-6 or MiniMax-M3-highspeed. |