Zai Quota
OpenCode TUI plugin - Z.AI coding plan quota gauges (5h window + plan) in the sidebar
0
505
11 in 7 days
36.1
Multi-signal model
16 days ago
2026-09-18
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-zai-quota@1.0.2"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-zai-quota@1.0.2"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-zai-quotaOpenCode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
OpenCode TUI plugin that shows your Z.AI coding plan quota (zai-coding-plan) directly in the sidebar: a gauge for the short usage window and one for the plan-level allowance, with live colors as you approach the limits.
Features
- Panel in the session sidebar with one gauge per quota limit:
- Bar (26 cells) filled according to consumption percentage.
- Dynamic colors: green < 70%, yellow 70-89%, red >= 90%.
- Reset countdown per limit (from
nextResetTime). - Usage / allowance numbers, plan level, and last-refresh time in the header.
- Compact
zai:N%chip next to the session prompt input. - Refreshes every minute, on
session.idle, and on demand via the/zai-quotacommand (also in the command palette,ctrl+p). - Colors read from the active OpenCode theme (
api.theme.current.*) — no hardcoded hex values.
Install
OpenCode TUI plugins are not auto-discovered: installing the package only
downloads it — the plugin must also be registered in tui.json. Two ways:
Option 1 — Plugin manager inside OpenCode (recommended)
npm install -g opencode-zai-quota- Open OpenCode, press
ctrl+pand run plugin install (or open the plugin manager and addopencode-zai-quota). - The plugin manager writes the entry to
tui.jsonfor you. Restart OpenCode.
Option 2 — Manual registration
npm install -g opencode-zai-quota- Add the plugin to
~/.config/opencode/tui.json(a project-level.opencode/tui.jsonalso works):
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["opencode-zai-quota"]
}
- Restart OpenCode. The
Z.AI PLANpanel appears in the session sidebar and thezai:N%chip next to the prompt input.
Editing
tui.jsonrequires a restart: config is not hot-reloaded. Unknown top-level keys intui.jsonare rejected and will crash startup — keep the shape shown above.
Authentication
The token is read automatically from OpenCode's own credentials
(~/.local/share/opencode/auth.json): the zai-coding-plan entry first, then
zai. If you can chat with a zai-coding-plan model in OpenCode, the widget
works with zero configuration.
Environment fallbacks: ZAI_TOKEN / Z_AI_TOKEN.
Data source
GET https://api.z.ai/api/monitor/usage/quota/limit
Authorization: Bearer <token>
Commands
| Slash command | Palette title | Description |
|---|---|---|
/zai-quota (/zq) |
Z.AI quota: refresh now | Force a refresh and show a toast with the result |
Note
This is a community plugin, not affiliated with Z.AI or OpenCode.
Freeze guard (v1.0.2)
When the Z.AI provider kills a stream with Weekly/Monthly Limit Exhausted, the
turn used to hang in the TUI (looking frozen). The plugin now listens for the
session.error event, shows an error toast with the reset time, refreshes the
gauges, and aborts the stuck turn automatically so the UI unfreezes
immediately. Switch model with /models to keep working until the reset.
License
MIT
Similar plugins
Tui Quota Usage
opencode-tui-quota-usage
OpenCode quota usage sidebar tracker for OpenCode V2 CLI/TUI
Providers Balances
opencode-providers-balances
OpenCode TUI plugin that shows provider account balances in the session sidebar. Providers are configured entirely in opencode.jsonc.
Usage Monitor
opencode-usage-monitor
OpenCode TUI sidebar plugin that displays API usage quotas for OpenAI and Z.AI (GLM) providers