Your privacy choices

Allow optional cookies for referral attribution, visit analytics, and Google Ads purchase measurement.

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.

SettingRecommended valueNotes
Base URLhttps://api.llm-token.cn/v1Start with the root path that includes /v1; remove it if the client reports an error.
API Keysk-xxxxxxxxEnter your complete LLM API Gateway Key.
Model IDFull model name from the model listIt must match exactly.

1. Install OpenCode

Choose any installation method. After installation, confirm that running opencode in the terminal starts the application.

System / methodCommand
npm
npm install -g opencode-ai
macOS / Linux Homebrew
brew install anomalyco/tap/opencode
Install script
curl -fsSL https://opencode.ai/install | bash

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.

  1. Open CC Switch and select the option to add a custom provider.
  2. Enter a provider name, such as "LLM API Gateway."
  3. Set the Base URL to https://api.llm-token.cn/v1.
  4. Enter your complete Key in the API Key field.
  5. 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 added yet and highlighting the plus icon in the upper-right corner for adding one.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 name, API Key, and Base URL highlighted, plus a button for adding models.Add-provider screen for OpenCode and CC Switch, with fields for provider…

3. Switch Models in the Terminal

  1. Open a terminal and run opencode.
  2. After OpenCode starts, press Ctrl + P.
  3. Find Switch Model and press Enter.
  4. 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 displayed, an example prompt in the input box, theme-switching tips, and version 1.14.30.OpenCode terminal interface with the current GPT-5.5 OpenAI model displa…

Ctrl + P

OpenCode terminal command menu with Switch model highlighted and the ctrl+x m shortcut shown beside it.OpenCode terminal command menu with Switch model highlighted and the ctr…

OpenCode Select model screen showing built-in models and a custom gpt-5.5 model highlighted, with shortcuts for connecting a provider and marking favorites.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 highlighted by a red arrow and Git repository controls on the right.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, with the custom gpt-5.5 option highlighted by a red arrow.OpenCode desktop model menu showing options such as GPT-4 nano and GPT-4…

5. Verification and Troubleshooting

SymptomResolution
opencode does not startReopen the terminal and confirm that the npm or brew installation path is included in PATH.
The custom model is missingConfirm that CC Switch saved the configuration, then restart OpenCode.
The request failsCheck the Base URL, API Key, and model ID. Start with https://api.llm-token.cn/v1.
The model responds slowlyTest a faster model, such as claude-sonnet-4-6 or MiniMax-M3-highspeed.