Merged. Thank you, @maxmad64bis. The design is what made this easy to carry: gated on a new `telemetry` option that is `z.boolean().default(false)`, inert on a host that has no `aisdk` domain, marking matching inference calls in their options only (filtered by provider and SDK package), no fetch wrapping, no client assignment, and any registration failure degraded to a warning. Five tests, one per property. One thing happened on our side and you should know exactly what: #14370 landed first and rewrote `src/index.ts` against the stable `@opencode/plugin` 2.0.12 contract, which collapses the per-event `aisdk` domains into a single named entry point `ctx.aisdk.hook(name, cb)`. Your registration block was written against the beta callable `ctx.aisdk.sdk(cb)`, so it was re-applied onto the new shape rather than merged as-is — mirroring how #14370 wired the sibling Gemini `"language"` hook. The `"sdk"` event on the stable contract carries exactly the three fields your callback already read (`model` / `package` / `options`), so nothing was lost: **the callback body is unchanged**. In the test file, every `it(...)` body and every assertion is byte-identical to yours. Only the host fake moved, and only because it had to: `ctx.catalog` → `ctx.provider` + `ctx.model` (the tip's `assertContext` now requires those transforms and no longer knows `catalog`), and the two callable domains → one `hook(name, cb)` router — the same fake the tip's own `gemini-language.test.ts` uses. The header comment was updated where it cited the old contract version. Validation before merge: `telemetry-sdk-hook.test.ts` 5 pass / 0 fail; the full `@omniroute/opencode-plugin-v2` suite 244 pass / 0 fail across 65 suites (= #14370's 239 plus your 5); `npm run build` and `tsc --noEmit` over src + tests under `strict: true` both exit 0; `typecheck:core`, `check:file-size` and `check:changelog-integrity` green. The net change to `index.ts` is purely additive — the few removed lines are prettier reflow of #14370's own lines.
@omniroute/opencode-plugin-v2
OpenCode v2 plugin (define({ id, setup }), Promise API) that publishes the live OmniRoute catalog — models from /v1/models, combos from /api/combos (least-common-denominator join), auto-combos from /api/combos/auto, enrichment (names + pricing), and usable-provider filtering — into the v2 catalog.transform, with key + env auth via integration.transform.
Companion to @omniroute/opencode-plugin (OpenCode v1, same repo). The two packages are independent: this one carries its own catalog-mapping logic and the v1 plugin is left untouched.
Install
npm install @omniroute/opencode-plugin-v2
opencode.json:
{
"plugins": [
{
"package": "@omniroute/opencode-plugin-v2",
"options": {
"providerId": "omniroute",
"baseURL": "http://localhost:20128"
}
}
]
}
Local file:// install
OpenCode resolves a local plugin directory by probing the subpaths
server.* / index.* (then tui, rpc) at the package root — it never
reads package.json main/exports. A folder exposing only dist/ is
therefore silently skipped (no loading plugin, no error).
This package ships a root server.js re-exporting ./dist/index.js for
exactly that probe, so pointing OpenCode at a local checkout works:
{
"plugins": [
{
"package": "file:///path/to/OmniRoute/@omniroute/opencode-plugin-v2",
"options": {
"providerId": "omniroute",
"baseURL": "http://localhost:20128"
}
}
]
}
Prerequisites when targeting a folder: run npm run build first (the root
server.js re-exports ./dist/index.js), and keep the folder's root
server.js — dist/ alone is not resolvable by the host.
Credentials
The plugin needs a gateway key to read the catalog, and looks for one in this order:
- The credential you connected in OpenCode. The plugin registers an
integration, so
opencode auth(or the Connect action in the model picker) can store a key for it. Nothing is written toopencode.json— this is the recommended route. apiKeyin the plugin options, when you want a per-project override. Remember that this puts the key in a config file you may be committing.OMNIROUTE_API_KEYin the environment.
If none of the three yields a key, the catalog is empty and the plugin says so once at startup rather than leaving you with a silent empty model list.
The management token is a different key
Combos, provider health and enrichment (display names, pricing, free-tier
budgets) come from the gateway's /api/* endpoints, which most deployments
gate behind a management token rather than the inference key. Set it
explicitly:
"options": {
"baseURL": "http://localhost:20128",
"managementReadToken": "<management read token>"
}
The token can also come from the OMNIROUTE_MANAGEMENT_API_KEY environment
variable (the option wins when both are set). Resolution order:
managementReadToken option, then OMNIROUTE_MANAGEMENT_API_KEY, then the
apiKey fallback.
Left unset, managementReadToken falls back to apiKey for backwards
compatibility, and the plugin warns once at startup that the fallback is
active. When a gateway rejects that fallback, the catalog still
publishes — but with raw model ids instead of display names, no canonical
alias dedupe, no pricing and no combos. The plugin warns once per endpoint
when this happens, naming the endpoint and the consequence, so the degraded
catalog is never a mystery.
Options
| Key | Default | Notes |
|---|---|---|
providerId |
"omniroute" |
Provider id and integration id; models publish under <providerId>/… |
baseURL |
required | OmniRoute gateway root (no /v1 suffix needed) |
apiKey |
connected credential, then OMNIROUTE_API_KEY |
Chat key for /v1/* — see Credentials |
managementReadToken |
option, then OMNIROUTE_MANAGEMENT_API_KEY, then apiKey |
Management key for /api/* (combos, providers, enrichment) — usually not the same key |
displayName |
"OmniRoute" |
Provider display name |
timeoutMs |
10000 |
Per-endpoint fetch timeout (auto-combos use 5s) |
modelCacheTtlMs |
300000 |
Catalog cache TTL; disk snapshot warms cold starts |
timeouts |
per-endpoint override | { models, combos, autoCombos, enrichment } in ms; falls back to timeoutMs |
enrichment |
true |
Fetch names + pricing (/api/pricing*, /api/free-tier/summary) |
providerTag |
true |
Prefix a display name with the upstream provider it routes to |
geminiSanitization |
true |
Strip $schema/additionalProperties from tool schemas sent to Gemini models ($ref tools are forwarded untouched) |
usableOnly |
false |
Filter to healthy provisioned providers (/api/providers) |
visibleModels / hiddenModels |
[] |
Exact-or-suffix allowlists, deny wins |
apiFormat.allowAnthropic |
false |
Route allowlisted ids to the Anthropic API block |
apiFormat.anthropicModels |
[] |
Full model ids routed to Anthropic |
apiFormat.anthropicPrefixes |
v1 defaults | Deprecated, warns once — prefer anthropicModels |
logLevel / startupDebug |
warn / false |
Logger verbosity |
Tool calling on Gemini models
Gemini answers 400 INVALID_ARGUMENT — for the whole request, not just the
offending tool — when a tool declaration carries $schema or
additionalProperties. Anything that emits standard JSON Schema therefore
breaks tool calling as soon as the chain routes to Gemini.
The plugin strips those keywords from tool schemas bound for a Gemini model of
this provider, and leaves every other request untouched. A tool carrying a
$ref is forwarded untouched instead of stripped: removing the reference
would widen the schema to "accept anything". Set
"geminiSanitization": false to turn it off.
Migrating from the v1 plugin
The v2 plugin publishes provider id X bare. The v1 plugin published opencode-X (native-adapter gate). Sessions pinned to opencode-X/... must re-select the model under X/....
License
MIT