OpenCode plugin that discovers models through any OpenAI-compatible /v1/models endpoint and preserves OpenRouter-style reasoning metadata, capabilities, limits, modalities, and pricing.
npm install
npm run typecheck
npm run test:run
npm run buildThe build generates the OpenCode model schema from the matching OpenCode Git tag. Specify the target version with a command-line argument or environment variable:
npm run build -- --opencode-version=1.18.4
$env:OPENCODE_VERSION = '1.18.4'; npm run buildSchema generation requires Git and Bun. Set BUN_BINARY when Bun is not on PATH.
At runtime, older OpenCode versions are rejected, matching versions use the generated schema, and newer versions use the older schema as a conservative subset with a warning.
Release automation maintains three release channels:
nightlyis a rolling prerelease built frommain.stableis a rolling release built from the most recent declared project release.opencode-vX.Y.Zcompatibility releases are built against the matching OpenCodevX.Y.Ztag.
Compatibility releases are retained independently of nightly and stable. The cleanup policy is:
- Compatibility releases older than one year are removed first.
- At least the three newest compatibility releases are always retained.
- If release assets exceed the configured storage threshold, the oldest compatibility releases are removed until storage is below the threshold or only three remain.
- If storage is still above the threshold with three releases remaining, cleanup stops and reports a warning rather than deleting one of the required releases.
nightly,stable, and versioned project releases are protected from compatibility cleanup.
The default release-asset threshold is 200 MB (200,000,000 bytes). Override it with the repository variable RELEASE_STORAGE_THRESHOLD_BYTES when needed.
- Targets every configured provider that exposes a string
options.baseURLby default. - Restrict to a subset with plugin options:
[["opencode-openrouter-metadata", { "providers": ["my-gateway"] }]]. - Maps
reasoning.supported_effortsinto OpenCode reasoning variants. - Omits the
nonevariant when upstream marks reasoning as mandatory. - Preserves the complete upstream model record under the normalized model's
openrouterfield. - Deep-merges configured model overrides over discovered metadata.
- Leaves existing models unchanged if discovery fails.
- Never logs credentials or request bodies.
The installed package is loaded by the global OpenCode config. After installation, fully restart OpenCode Desktop and verify with:
opencode models my-gateway --refresh --verboseAny provider that exposes an OpenAI-compatible /v1/models endpoint is discovered. The plugin reads provider.<id>.options.baseURL and provider.<id>.options.apiKey when present.