OpenCode Zen provider extension for pi.
pi install npm:@ravshansbox/pi-opencode-zenPi loads the provider from ./index.ts and registers an opencode-zen provider that exposes OpenCode Zen models.
The extension:
- supports anonymous mode by using the API key value
public - adds OpenCode request headers on every
opencode-zenprovider request:x-opencode-clientx-opencode-sessionx-opencode-projectx-opencode-request
- sets the OpenCode CLI-style
User-Agent
This extension mirrors OpenCode CLI behaviour as closely as possible:
- it fetches the live visible model IDs from the OpenCode Zen API
- it fetches OpenCode provider metadata from
models.dev - it filters out models with
status === "deprecated" - in anonymous/public mode (
key = "public"), it keeps only models wheremodels.devreportscost.input === 0
Live model visibility source:
curl -H 'Authorization: Bearer public' https://opencode.ai/zen/v1/modelsOpenCode metadata source:
curl https://models.dev/api.jsonThe Zen /models endpoint does not include pricing or deprecation metadata, so the extension combines both sources.
Get an API key from OpenCode Zen, then configure pi in one of these ways.
export OPENCODE_API_KEY=your-real-keyTo use anonymous mode for OpenCode Zen free/public models:
export OPENCODE_API_KEY=publicStore the key in ~/.pi/agent/auth.json under the opencode-zen provider name:
{
"opencode-zen": {
"type": "api_key",
"key": "your-real-key"
}
}Use "key": "public" for anonymous mode.
npm install
npm run check