A plugin for OpenCode 2.x. Before each prompt you send, it asks Nadir whether the prompt is simple, medium or complex. On a simple or medium prompt it adds a short note to that turn with Nadir's read and the subagents you configured with their own model. The agent decides whether to hand work off. The plugin never changes the session model.
Nadir only returns the tier. Your provider keys stay in OpenCode and the conversation never passes through Nadir.
Setup
Save the plugin in your global OpenCode plugins directory (or in a project's .opencode/plugins/). It is one file of about 90 lines with no dependencies; read it before you run it.
mkdir -p ~/.config/opencode/plugins curl -fsSL https://getnadir.com/integrations/opencode/nadir-route.js \ -o ~/.config/opencode/plugins/nadir-route.js
Then give at least one subagent a cheaper model. Without one, the plugin has nothing to suggest and stays silent.
{
"agents": {
"light": {
"mode": "subagent",
"model": "anthropic/claude-haiku-4-5",
"description": "Routine, well-specified edits, tests and docs"
}
}
}Behavior
- Complex prompts get no note. Simple and medium prompts get one
<nadir-route>block with the tier odds and your handoff subagents, appended to the prompt you sent. It stays in the conversation, so prompt caching is unaffected. - The plugin sends up to 8,192 characters of the prompt you typed and nothing else: no system prompt, files, tool output or earlier turns.
- Errors, a non-200 answer or a timeout (1.5 seconds by default) leave your prompt unchanged. The plugin fails open.
With or without a key
Without a key the plugin uses the free anonymous tier of https://api.getnadir.com/v1/bucket. It is rate-limited per IP and keeps no per-request record, only aggregate counts. Set NADIR_API_KEY to see decisions in your Nadir dashboard, or NADIR_BASE_URL to use a self-hosted Nadir.
The same settings can go in plugin options instead of the environment: apiKey, baseURL and timeoutMs. See the Decision API for the full contract.