Skip to content

OpenCode Setup Guide ​

An open-source AI coding assistant and intelligent coding companion in the terminal.

Overview

OpenCode is an open-source AI coding assistant that helps write, debug, and improve code from the terminal, IDE, or desktop environment. It supports a native terminal TUI, parallel sessions, and 75+ model providers, making it a strong fit for command-line developers.

ResourceURL
OpenCode projecthttps://github.com/opencode-ai/opencode

Features ​

  • Native terminal TUI: designed for efficient command-line workflows
  • Smart LSP loading: automatically loads the right language server for better context
  • Parallel sessions: run multiple sessions independently
  • Session sharing: share session links for collaboration
  • 75+ model providers: supports many providers, including local models
  • Multi-platform: terminal CLI, desktop app beta, and IDE extensions

Installation and Configuration ​

Step 1: Install OpenCode ​

Open a terminal and install OpenCode globally:

bash
npm install -g opencode-ai

After installation, run opencode. If the TUI appears, installation succeeded.

Successful installation screen

Step 2: Install CC-Switch ​

See CC-Switch and install it locally.

Step 3: Add a Xiaomai Provider ​

1. Choose configuration target

Open CC-Switch, choose OpenCode from the top configuration tabs, then click Add Provider.

2. Fill in provider information

Configure the parameters as follows:

FieldDescription
Preset providerChoose xiaomai
Provider IDCustom name, such as xiaomai-Claude
API formatUse Anthropic for Claude models, OpenAI for GPT models, and Google (Gemini) for Gemini models
API KeyEnter the key created in the Xiaomai API console
Extra optionsEnter {"setCacheKey":true}

Verify Configuration ​

  1. Reopen the terminal and run opencode
  2. Run /models and check whether the configured channel appears in the model list
  3. If you can see the added model, configuration succeeded

Model list verification

Start coding.

Conversation interface

FAQ ​

npm not found during installation ​

Install Node.js first. See Node.js installation.

The configured channel does not appear in the model list ​

  • Confirm the configuration was saved correctly in CC-Switch
  • Restart the terminal and run opencode again
  • Check whether the API key is correct

More Questions ​

Read the FAQ or contact support.

Friendly, practical, and reliable AI coding support