OpenCode
OpenCode is an open-source terminal AI coding agent that lets you add custom OpenAI-compatible providers in its config file. OpenPalmLab provides /v1/chat/completions, so the setup below is all you need.
Install
Section titled “Install”Install OpenCode first, then follow the steps below to connect it to the gateway. The install script from the official 1.x documentation (macOS / Linux / WSL):
curl -fsSL https://opencode.ai/install | bashOr use a package manager:
npm install -g opencode-aibrew install anomalyco/tap/opencodeOn Windows the official docs recommend WSL; choco install opencode and scoop install opencode also work.
Check the install:
opencode --versionIf it prints a version number, you are set. For all install methods see the official documentation.
Before you start
Section titled “Before you start”- OpenCode is installed.
- You have a console token whose group includes models that support Chat Completions (see the pricing page).
Option 1: generate the config in the console
Section titled “Option 1: generate the config in the console”The console builds the config in your browser; your token never leaves it.
- Open the console API Keys page, choose Terminal Commands in the action menu of the token you want, and pick the OpenCode tab.
- Pick a model and your system (macOS / Linux, Windows CMD or PowerShell; the system only changes how the file path is written).
- Save the content as
~/.config/opencode/opencode.json(on Windows,%USERPROFILE%\.config\opencode\opencode.json), merged with what is there.
The file contains your token, so do not commit it to a repository.
Option 2: write opencode.json by hand
Section titled “Option 2: write opencode.json by hand”Edit ~/.config/opencode/opencode.json:
{ "$schema": "https://opencode.ai/config.json", "provider": { "newapi": { "npm": "@ai-sdk/openai-compatible", "name": "OpenPalmLab", "options": { "baseURL": "https://api.openpalm.ai/v1", "apiKey": "sk-xxxx" }, "models": { "YOUR_MODEL": { "name": "YOUR_MODEL" } } } }, "model": "newapi/YOUR_MODEL"}baseURLmust include/v1.- The key under
modelsand itsnameare a model name from the pricing page. You can list several. modelhas the formprovider/modeland sets the default model.
Check it works
Section titled “Check it works”Run opencode in a project directory and ask anything. Then open the console Usage Logs page; a request record for your token means it works.
Common problems
Section titled “Common problems”| Symptom | Fix |
|---|---|
| Model not found | The model is not listed under models, or model is not written as newapi/<model>. |
401 |
The token is wrong, expired or out of quota. |
404 |
baseURL is missing /v1. |
No available channel for model ... |
That model has no available channel in your group. Choose another model, or use a token in a different group. |
See Troubleshooting for more. Similar clients: Claude Code, Codex CLI, Gemini CLI.