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
npmmanually first - If you use the
npminstall path, installNode.jsandnpmfirst - If you use the
buninstall path, installbunfirst
For the npm path, install Node.js from: https://nodejs.org/en/download
- macOS / Windows: install the
LTSrelease from that page - Linux: use the distro-specific method listed there
On macOS, if you already use Homebrew, you can also run:
brew install nodeThis installs both Node.js and npm.
Then verify:
node -v
npm -vFor Windows CLI workflows, the official docs currently recommend WSL.
Install
Official install page: https://opencode.ai/
Recommended install command from the official site:
curl -fsSL https://opencode.ai/install | bashThe official site also provides npm, bun, and brew install options.
Configure
Option 1: Config file (recommended)
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
