@rice-as681/opencode-quota-toast
v0.1.0
Published
Zero-dependency OpenCode plugin: per-turn TUI toast showing remaining LLM token quota + $ budget from the Rice gateway's /llm/v1/quota endpoint.
Readme
@rice-as681/opencode-quota-toast
A zero-dependency OpenCode plugin that shows a TUI toast after each turn
with your remaining LLM quota from the Rice gateway's GET /llm/v1/quota
endpoint — e.g. 5M/5M tokens · $0.42/$5.00 · resets ~11h. It's the transient
counterpart to the persistent sidebar panel
(@rice-as681/opencode-quota-sidebar).
It uses only the stable OpenCode plugin API (the event hook +
client.tui.showToast) and polls /quota on session.idle, rate-limited to
one toast per minute by default.
Install
This plugin ships inside the canonical Rice student config — if you pasted
opencode.json from the portal's Set up OpenCode guide, you already have
it:
"plugin": ["@rice-as681/[email protected]"]OpenCode installs the package from npm automatically with its bundled Bun — no
manual npm install, no Node required.
No-npm alternative: copy index.ts into ~/.config/opencode/plugins/ (or
<repo>/.opencode/plugins/) — local plugin files auto-load at startup.
Key + base URL resolution (first match wins)
- env
RICE_LLM_API_KEY(+ optionalRICE_LLM_BASE_URL) - auto-discovered from your OpenCode config (
~/.config/opencode/opencode.jsonand the project'sopencode.json): aprovider.<id>whoseoptions.baseURLis set, preferring the Rice gateway host. The key comes fromoptions.apiKeywhen present, else from OpenCode's/connectcredential store (theauth.jsonentry for that provider id).
The canonical student config deliberately omits options.apiKey (the key is
stored via /connect instead), so the auth.json fallback is the normal path.
Resolution happens per-turn, so a key connected mid-session is picked up
without a restart.
Tuning: RICE_QUOTA_MIN_INTERVAL_MS (min ms between toasts; default 60000),
RICE_QUOTA_TOAST_MS (toast linger; default 10000).
Alternative
For an always-visible panel instead of a per-turn toast, add
@rice-as681/opencode-quota-sidebar to tui.json — see
../rice-quota-sidebar/.
