An OpenCode terminal and Desktop plugin that lists the upstream providers for the active OpenRouter model and pins the provider you select.

- Native terminal sidebar and Desktop session side panel with input, output, and cache-read prices per million tokens.
- Rolling 30-minute throughput, latency, and uptime when OpenRouter supplies them; one-day uptime is used as a labelled fallback.
- Click a provider to force subsequent requests for that model to use it.
- Hard routing uses
provider.orderandprovider.onlywithallow_fallbacks: false; OpenRouter cannot silently fail over to another provider. - “Automatic routing” restores normal routing for the model.
/openrouter(or/or-provider) opens a searchable terminal provider picker.- Terminal and Desktop selections share the same per-model state and refresh every 60 seconds by default.
Requires OpenCode 2.2.5 or newer. Desktop support uses OpenCode's experimental GUI plugin API.
Paste this into OpenCode or any AI coding assistant:
Install the OpenCode plugin "opencode-openrouter-provider" from
https://github.com/Jackster/OpenRouter-Provider-Plugin, add it to my
OpenCode configuration, and tell me how to restart so it takes effect.
opencode plugin add github:Jackster/OpenRouter-Provider-PluginAdd the Git package specifier to the plugins array in your global opencode.json:
{
"plugins": [
"github:Jackster/OpenRouter-Provider-Plugin"
]
}opencode plugin add /absolute/path/to/OpenRouter-Provider-PluginFor a manual local installation, add a file:// URL to the plugins array in your global opencode.json:
{
"plugins": [
"file:///absolute/path/to/OpenRouter-Provider-Plugin"
]
}The package exports ./server, ./tui, and ./gui-experimental; OpenCode discovers them from the same plugin entry. Restart the terminal after installation or an upgrade. In Desktop, open Settings > Extensions > Plugins, ensure the plugin is enabled, and click Reload after upgrading.
- Connect OpenRouter in OpenCode and select an OpenRouter model.
- In the terminal, expand OpenRouter Provider in the session sidebar. In Desktop, open the OpenRouter tab in the session side panel.
- Click a provider. The filled dot marks the active selection.
- Click Automatic routing to remove the pin.
The plugin reads the model currently selected in the prompt, including in new sessions. Before a new session's first message — when the host cannot name a model yet — it falls back to your most recently used OpenRouter model, which is what the new session will send with. Provider selection affects subsequent requests, including retries and continuation turns for that model.
Input, output, and cache-read prices are shown separately in USD per million tokens. Throughput is tokens per second; latency is time to first token. Missing prices display as —, never as zero; unavailable metrics are omitted to reduce clutter. Region and service-tier endpoints are grouped under their routable provider slug; a +N suffix indicates additional variants.
Use the Sort control in the terminal sidebar, /openrouter picker, or Desktop panel to order providers by name, cheapest or most expensive input/output/cache price, lowest latency, or highest throughput. In the provider list, the cheapest available price in each price column is green and the most expensive is red. Tied extremes are not highlighted; missing values remain unhighlighted and sort last.
Pricing and uptime are available from OpenRouter's public endpoints API. OpenRouter currently requires an API key for throughput and latency. The plugin uses the active OpenRouter credential loaded by OpenCode (or OPENROUTER_API_KEY in the terminal) only as the Authorization header for the endpoints request. Desktop passes the key transiently to its server RPC for the same lookup. It never writes the key to its state file or displays it.
Only model IDs, provider selections, and recent session model mappings are stored in openrouter-provider.json under OpenCode's configuration directory.
Set plugin options on its entry in opencode.json (minimum refresh interval: 15 seconds):
{
"plugins": [
["opencode-openrouter-provider", { "refreshIntervalMs": 60000 }]
]
}Requires Node.js 24+ for the built-in TypeScript test runner.
npm install
npm run checkThe check runs typechecking, unit and RPC tests, the existing terminal build, and the Desktop CommonJS build. Core modules are independent of either renderer. Tests cover model normalization, endpoint grouping, authenticated fetches, formatting, persistence, Desktop RPC handlers, and hard-routing behavior. A DOM rendering test also switches the real Desktop panel between light and dark modes and verifies its computed dropdown, color-scheme, and price-highlight styles.
The sidebar rendering and mouse-interaction check requires Node.js 26.4 or newer with native FFI enabled:
node --experimental-ffi tests/verify-sidebar.mjs
node --experimental-ffi --conditions=browser tests/verify-sidebar.mjs --bundleIt renders the real terminal component at 38 and 72 columns with deterministic endpoint data, then verifies provider selection and automatic-routing reset.