Set up OpenCode

Open-source terminal coding agent. Add one custom provider to opencode.json

Steps

  1. Install OpenCode (skip if installed)

    On macOS / Linux use the official script or npm. On Windows the docs recommend WSL, or install with npm directly. Check with opencode --version.

    macOS / Linux

    curl -fsSL https://opencode.ai/install | bash

    Windows

    npm install -g opencode-ai
  2. Store the key in an environment variable

    The config refers to the key as {env:CHERRYCHAT_API_KEY}, so the key itself lives in an environment variable. Reopen the terminal afterwards.

    • CHERRYCHAT_API_KEY (API key): sk-your-key

    macOS / Linux (append to ~/.zshrc)

    echo 'export CHERRYCHAT_API_KEY="sk-your-key"' >> ~/.zshrc
    source ~/.zshrc

    Windows (reopen PowerShell afterwards)

    setx CHERRYCHAT_API_KEY "sk-your-key"
  3. Write opencode.json

    The global config lives at ~/.config/opencode/opencode.json (open it with the command below). On native Windows, put opencode.json in the project root instead; it applies to that project only. Paste the content and save. Add more models in models the same way.

    • options.baseURL (API address): https://gpt.cherrychat.org/v1 (Stop at /v1)
    • Model name: claude-sonnet-5-5

    Open the file (macOS)

    mkdir -p ~/.config/opencode && touch ~/.config/opencode/opencode.json && open -e ~/.config/opencode/opencode.json

    opencode.json content

    {
      "$schema": "https://opencode.ai/config.json",
      "model": "cherrychat/claude-sonnet-5-5",
      "provider": {
        "cherrychat": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "CherryChat",
          "options": {
            "baseURL": "https://gpt.cherrychat.org/v1",
            "apiKey": "{env:CHERRYCHAT_API_KEY}"
          },
          "models": {
            "claude-sonnet-5-5": { "name": "claude-sonnet-5-5" }
          }
        }
      }
    }
  4. Start and verify

    Open a new terminal in your project folder and run the command below; a reply means it works. For interactive use run opencode and type /models to switch between the CherryChat models.

Common pitfalls

Error → cause → fix

What you seeWhyWhat to do
HTTP 401 / invalid API keyThe variable is not loaded (terminal not reopened), or the key is wrong or disabledReopen the terminal and run opencode auth list; copy the key again from My Keys if needed
HTTP 404 Not FoundbaseURL is missing /v1 or was set to https://gpt.cherrychat.org/v1/chat/completions (path doubled)Change it to https://gpt.cherrychat.org/v1
ProviderModelNotFoundError or model not foundThe model in "model" is not listed under models, or the name does not match the Models pageAdd the model under models and match the Models page exactly (all lowercase)
HTTP 402 or "insufficient balance" (billing_error in Claude format)Your credits cannot cover this call. API calls are paid from credits only; memberships and unlimited plans do not applyTop up any amount in the CherryChat Store, then retry after a few seconds
HTTP 429 Too Many RequestsToo many requests: by default 120 per minute per key and 8 at a time per accountLower the concurrency or requests per second in the tool and wait for the Retry-After seconds; most tools retry on their own

Guide checked 2026-11-02. The tool's screens may change; the official docs win if they differ.

API · API Pricing

Operated by UK Company CHERRYCHAT LTD · Company Number 16096119 · Support WeChat: JsnonoChat · Content is AI-generated — please verify before relying on it

CherryChat

The network is slow. Still loading…