@mr.mm/opencode-omniroute-pluginOpenCode plugin for the OmniRoute AI Gateway. Drives dynamic model discovery, /connect auth flow, and multi-instance OmniRoute providers via the official @opencode-ai/plugin contract.
1
22
4 in 7 days
27.1
Multi-signal model
2 months ago
2026-06-08
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@mr.mm/opencode-omniroute-plugin@0.1.2"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@mr.mm/opencode-omniroute-plugin@0.1.2"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D @mr.mm/opencode-omniroute-pluginopencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
OpenCode plugin for the OmniRoute AI Gateway.
Pulls a live model catalog from /v1/models, aggregates combos via /api/combos, maps OmniRoute capabilities to the OpenCode ModelV2 contract, and supports multiple side-by-side OmniRoute instances.
Fork of @omniroute/opencode-plugin with additional fixes — see Changes from upstream.
Install
npm install @mrmm/opencode-omniroute-plugin
# or
bunx add @mrmm/opencode-omniroute-plugin
For local development, clone and build:
git clone https://github.com/mrmm/opencode-omniroute-plugin
cd opencode-omniroute-plugin
bun install && bun run build
Then reference the dist directly in opencode.jsonc:
{
"plugin": [
[
"/path/to/opencode-omniroute-plugin/dist/index.js",
{ "providerId": "omniroute" },
],
],
}
Quick start
// ~/.config/opencode/opencode.jsonc
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
[
"@mrmm/opencode-omniroute-plugin",
{
"providerId": "omniroute",
"baseURL": "https://your-omniroute-instance.example.com",
"modelCacheTtl": 300000,
},
],
],
}
opencode auth login --provider omniroute
# prompts for API key, writes to ~/.local/share/opencode/auth.json
Note: Use
--providerexplicitly.opencode auth login omnirouteis parsed as a positional URL argument on OC ≤1.15.5 and fails. Tracked upstream.
Multi-instance (prod + staging)
OC ≤1.15.5 dedupes plugin loads by module path — two entries pointing at the same file collapse to one. Workaround: install the package twice into separate directories.
mkdir -p ~/.config/opencode/plugins/omniroute-prod
mkdir -p ~/.config/opencode/plugins/omniroute-staging
npm install --prefix ~/.config/opencode/plugins/omniroute-prod @mrmm/opencode-omniroute-plugin
npm install --prefix ~/.config/opencode/plugins/omniroute-staging @mrmm/opencode-omniroute-plugin
{
"plugin": [
[
"./plugins/omniroute-prod/node_modules/@mrmm/opencode-omniroute-plugin/dist/index.js",
{ "providerId": "omniroute", "baseURL": "https://or.example.com" },
],
[
"./plugins/omniroute-staging/node_modules/@mrmm/opencode-omniroute-plugin/dist/index.js",
{
"providerId": "omniroute-staging",
"baseURL": "https://or-staging.example.com",
},
],
],
}
Plugin options
| Option | Type | Default | Description |
|---|---|---|---|
providerId |
string |
"omniroute" |
Unique provider id across plugin entries |
displayName |
string |
"OmniRoute" / OmniRoute (<id>) |
Label in the OpenCode UI |
modelCacheTtl |
number |
300000 (5 min) |
/v1/models TTL in ms — keep ≥60 000 to avoid compaction hangs |
baseURL |
string |
from auth.json after /connect |
Override OmniRoute base URL |
features |
object |
see below | Feature toggles |
features block
| Feature | Default | Description |
|---|---|---|
combos |
true |
Surface /api/combos as pseudo-models with LCD capability/limit join |
enrichment |
true |
Overlay display names + per-token pricing from /api/pricing/models |
compressionMetadata |
false |
Tag combo names with compression pipeline emoji (e.g. [rtk🟡 → caveman🟠]) |
providerTag |
true |
Prepend upstream provider label so cc/claude-opus-4-7 → Claude - Claude Opus 4.7 |
usableOnly |
false |
Filter to providers with a healthy connection in /api/providers |
diskCache |
true |
Persist last-good catalog to disk; hydrates on cold start when /v1/models is unreachable |
geminiSanitization |
true |
Strip $schema/$ref/additionalProperties from tool params for gemini-* models |
mcpAutoEmit |
false |
Auto-write mcp.<providerId> pointing at <baseURL>/api/mcp/stream |
fetchInterceptor |
true |
Inject Authorization: Bearer on requests targeting baseURL |
Changes from upstream
Fixes applied on top of @omniroute/opencode-plugin at v3.8.9:
| Fix | Detail |
|---|---|
interleaved capability mapping |
caps.thinking from OmniRoute was not propagated to ModelV2.capabilities.interleaved (hardcoded false). Extended thinking models now surface correctly in OpenCode's picker. Upstream PR: diegosouzapw/OmniRoute#3138 |
Development
bun install
bun run build # tsup → dist/
bun test tests/ # 228 tests, ~150ms
Release
Tag a version to trigger the release workflow (builds, tests, publishes to npm, creates GitHub Release):
git tag v0.1.2 && git push origin v0.1.2
Requirements
- Node
>=22or Bun>=1.1 - OpenCode
>=1.15with@opencode-ai/plugin >=1.14.49
License
MIT — see LICENSE.