opencode-9routerplus-usage
v0.1.1
Published
OpenCode plugin that shows 9routerplus usage stats after AI completion
Downloads
275
Maintainers
Readme
9Router Usage Notifier
OpenCode plugin that displays 9routerplus usage statistics after each completed assistant turn.
Features
- Shows usage stats after every AI response
- Displays: estimated cost, input/output tokens, total requests
- Configurable period:
today,last24h, or7d(defaults totoday) - Usage display mode supports
inline,toast, orbothand defaults totoast
Installation
Primary install flow:
npx opencode-9routerplus-usageWhat the installer does:
- creates
~/.config/opencode/9routerplus-usage.jsonif missing - adds
opencode-9routerplus-usageto~/.config/opencode/opencode.json - relies on OpenCode's npm plugin support so the plugin is installed/loaded from the package entry directly
- prints a reminder to check
baseURLandallowedProviders
Manual fallback:
npm install -g opencode-9routerplus-usage
opencode-9routerplus-usageIf you prefer to edit OpenCode config yourself, add this plugin entry:
{
"plugin": ["opencode-9routerplus-usage"]
}Then create the plugin config file with:
npm run setupwhen working from this repo locally.
Configuration
- Ensure plugin is listed in
~/.config/opencode/opencode.json:
{
"plugin": [
"@spoons-and-mirrors/subtask2@latest",
"opencode-agent-skills",
"@tarquinen/opencode-dcp@latest",
"opencode-9routerplus-usage"
]
}The npx opencode-9routerplus-usage command can add this automatically.
- Create plugin config file next to
opencode.json:
Path: ~/.config/opencode/9routerplus-usage.json
{
"baseURL": "http://localhost:20128",
"period": "today",
"enabled": true,
"usageDisplay": "toast",
"minNotifyIntervalMs": 1500,
"requestTimeoutMs": 3500,
"allowedProviders": ["9routerplus"]
}Minimal (recommended to start):
{
"baseURL": "http://localhost:20128",
"period": "today",
"usageDisplay": "toast",
"allowedProviders": ["9routerplus"]
}Quick setup command (auto-create config file):
npm run setupOptions
baseURL- 9routerplus server URL (default:http://localhost:20128)period- Time period:today,last24h, or7d(default:today)enabled- Enable/disable plugin (default:true)usageDisplay- Usage presentation mode:inline,toast, orboth(default:toast)minNotifyIntervalMs- De-duplicate end-of-turn status emission across supported completion hooks per session (default:1500)requestTimeoutMs- API request timeout in ms (default:3500)allowedProviders- Show usage when active provider matches, or when the model id is namespaced under an allowed provider such as9routerplus/...(default:["9routerplus"])
Behavior
- Plugin reads model/provider from OpenCode session metadata.
- Success status appears when provider attribution matches
allowedProviders, or when the model id itself is namespaced under an allowed provider. - End-of-turn success output is de-duplicated across
session.idleandexperimental.text.complete. usageDisplayis the only presentation switch for usage output.- API/runtime errors are shown as toast and de-duplicated (shown once per error key until recovery).
Usage
Once installed and configured, the plugin shows a success toast after each eligible assistant completion by default. If you switch usageDisplay to inline or both, the inline status block looks like this:
────────────────────────────────────────────────────
9ROUTERPLUS TODAY · REQ 1023 · $155 · IN 155M · OUT 150K
────────────────────────────────────────────────────Default success toast content:
Title: 9ROUTERPLUS TODAY · $155
Message: TOTAL REQUEST 1023
IN 155M · OUT 150KRequirements
- OpenCode with plugin support
- 9routerplus running with
/api/plugin/usage-summaryendpoint
