Skip to content

OpenCode

Prerequisites

OpenCode provides an official installer script plus npm, bun, and brew install options.

  • If you use the official installer script, you usually do not need to prepare npm manually first
  • If you use the npm install path, install Node.js and npm first
  • If you use the bun install path, install bun first

For the npm path, install Node.js from: https://nodejs.org/en/download

  • macOS / Windows: install the LTS release from that page
  • Linux: use the distro-specific method listed there

On macOS, if you already use Homebrew, you can also run:

bash
brew install node

This installs both Node.js and npm.

Then verify:

bash
node -v
npm -v

For Windows CLI workflows, the official docs currently recommend WSL.

Install

Official install page: https://opencode.ai/

Recommended install command from the official site:

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

The official site also provides npm, bun, and brew install options.

Configure

Configure a custom provider in opencode.json with the Responses API:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "codex_proxy": {
      "npm": "@ai-sdk/openai",
      "name": "Codex Proxy",
      "options": {
        "baseURL": "https://api.gemiaude.com/v1",
        "apiKey": "{env:OPENAI_API_KEY}"
      },
      "models": {
        "gpt-5-codex-mini": {
          "name": "gpt-5-codex-mini"
        }
      }
    }
  },
  "model": "codex_proxy/gpt-5-codex-mini"
}

Option 2: Auth command or environment variable

You can also use opencode auth login or run /connect inside OpenCode to save the service as a custom provider. For environment-variable-based setup, export OPENAI_API_KEY in the current shell.

Option 3: cc-switch tool

If you prefer a tool to write the configuration automatically, use cc-switch: https://github.com/farion1231/cc-switch/releases

OpenAI-compatible gateway integration docs