OpenCode Integration
v3.8.1Last updated: 2026-05-14
Was this page helpful?
Loading OmniRoute...
Status: Generally available.
Audience: Operators wiring OpenCode to an OmniRoute deployment.
Source of truth (config schema):
Source of truth (npm package): (publishable workspace)
OpenCode is an agentic CLI/desktop AI client. It reads its provider catalog from (or ) and follows the schema at . OmniRoute exposes itself to OpenCode as one of those providers β every request flows through OmniRoute's standard OpenAI-compatible surface, so OpenCode automatically benefits from Auto-Combo routing, circuit breakers, key policies, observability, etc.
two supported integration paths. Pick one β they generate the same config.
in place.
# After installing OmniRoute (npm i -g @omniroute/cli or local clone) omniroute config opencode \ --baseUrl http://localhost:20128 \ --apiKey "$OMNIROUTE_API_KEY"
(), so an existing keeps its other providers and comments. The OmniRoute entry is added/replaced atomically.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"omniroute": {
"npm": "@ai-sdk/openai-compatible",
"name": "OmniRoute",
"options": {
"baseURL": "http://localhost:20128/v1",
"apiKey": "<your-key>",
},
"models": {
"claude-opus-4-5-thinking": { "name": "claude-opus-4-5-thinking" },
"claude-sonnet-4-5-thinking": { "name": "claude-sonnet-4-5-thinking" },
"gemini-3.1-pro-high": { "name": "gemini-3.1-pro-high" },
"gemini-3-flash": { "name": "gemini-3-flash" },
},
},
},
}
npm install --save-dev @omniroute/opencode-provider
import { writeFileSync } from "node:fs";
import { buildOmniRouteOpenCodeConfig } from "@omniroute/opencode-provider";
const config = buildOmniRouteOpenCodeConfig({
baseURL: "http://localhost:20128",
apiKey: process.env.OMNIROUTE_API_KEY ?? "sk_omniroute",
// Optional: override the model catalog exposed to OpenCode
models: ["auto", "claude-opus-4-7", "gpt-5.5"],
modelLabels: { auto: "Auto-Combo" },
});
writeFileSync("opencode.json", JSON.stringify(config, null, 2));
from or call the CLI generator.
package README for the full API.
. At runtime, OpenCode loads (already a transitive dependency of OpenCode) and configures it with + . From there:
export const OMNIROUTE_DEFAULT_OPENCODE_MODELS = [ "claude-opus-4-5-thinking", "claude-sonnet-4-5-thinking", "gemini-3.1-pro-high", "gemini-3-flash", ] as const;
. Recommended additions:
:
| ) | |
|---|---|
the most common breakage seen in older configs. If you have an from before v3.8.0 that points at , re-run the generator or call again.
| value | |
|---|---|
| (default for local) | (literal placeholder) |
+ , OmniRoute's also honours the key from . OpenCode uses the OpenAI surface, so it'll always send β no Anthropic special-case applies here.
on every request with URL containing |
. | |
| and the key is unknown. | (local only) and use . |
|
| to surface ones you've enabled. | ||
| . | ). |
means README,