Skip to content

Repository files navigation

OpenCode Quota logo

Quota, usage, and token visibility in OpenCode and your terminal.

npmnpm downloadsCILicense: MIT

OpenCode Quota sidebar


Quick start

npx @slkiser/opencode-quota init

Important

Node.js >= 22 is required.

Upgrading from v3? Read the v4 migration guide.

After installation:

  1. Restart OpenCode.
  2. Run a slash command in OpenCode, or use opencode-quota show from your terminal.
  3. If you enabled the sidebar, open the session sidebar and look for Quota.
  4. If you enabled the compact status line, look at the bottom of Home or below the message input.

Updating

  1. Close OpenCode.

  2. Run:

    npx @slkiser/opencode-quota@latest update
  3. Review the exact config edits and cache directories, then confirm.

  4. Restart OpenCode.

Use --dry-run to preview without changing anything. Otherwise, update shows the OpenCode Quota config and cache changes and asks before applying them. It leaves your other plugins and settings alone. Use --yes only when you intentionally need a noninteractive run.

Choose your setup

OpenCode Quota TUI sidebar panelOpenCode Quota popup toast
Sidebar panel
A full quota view in OpenCode's session sidebar.
TUI toast
Quota checks can appear automatically while you work.
OpenCode Quota TUI status lineOpenCode Quota token report
Compact status line
Short quota text on Home and below the message input.
Token reports
/tokens_today, /tokens_weekly, session reports, and more.

More ways to use it:

  • Check quota from a terminal with opencode-quota show
  • Use JSON output in scripts, status bars, CI checks, and other tools
  • Send quota data to monitoring tools with optional OpenTelemetry metrics
  • Run the same slash commands in the TUI, Web, and Desktop
  • Tune reset countdown precision without changing the default compact display
  • Choose current-session or descendant-tree token totals across /quota, toasts, the sidebar, and the compact input line
  • Diagnose authentication, quota sources, pricing, and maintainer notices

See Configuration for UI options and Manual install for setup details.

Commands

Core slash commands

CommandUse when
/quotaShow current quota
/quota_statusDiagnose setup, authentication, providers, pricing, and notices
/quota_announcementsRead active bundled maintainer notices
/pricing_refreshRefresh local runtime pricing from models.dev
/tokens_todayShow tokens used today
/tokens_dailyShow tokens used in the last 24 hours
/tokens_weeklyShow tokens used in the last 7 days
/tokens_monthlyShow tokens used in the last 30 days, including pricing
/tokens_allShow tokens used across all local history
/tokens_sessionShow tokens used in the current session
/tokens_session_allShow current session plus descendant sessions
/tokens_between YYYY-MM-DD YYYY-MM-DDShow tokens used between two dates

CLI commands

Use the CLI for scripts, CI, or a quick terminal check outside OpenCode.

CommandUse when
opencode-quota init --dry-runValidate and preview installer changes without writing files
opencode-quota updatePreview, confirm, and apply a scoped OpenCode Quota update
opencode-quota update --dry-runPreview exact config and cache targets without changing them
opencode-quota showCheck quota from your terminal
opencode-quota show --provider <id>Check one provider only, such as copilot or openai
opencode-quota show --jsonPrint JSON for scripts, status bars, and other tools
opencode-quota show --json --threshold <pct>Fail when quota is low; return exit 2 for incomplete results
opencode-quota statusRun the same diagnostics as /quota_status from a terminal
opencode-quota status --provider <id>Diagnose one provider by canonical ID or synonym
opencode-quota status --jsonPrint secret-safe JSON diagnostics for scripts and CI

Providers

Pre-configured American providers

Personal
ProviderAuth/setupData fromReports
Anthropic (Claude)Needs setupLocal CLI/OAuthQuota
Chutes AIAutomaticRemote APIQuota
CursorNeeds setupLocal estimateBudget and spend
GitHub CopilotAutomaticRemote APIUsage and budget
Google AGYNeeds setupRemote APIQuota
Google AntigravityNeeds setupRemote APIQuota
Kilo GatewayAutomaticRemote APIQuota and balance
NanoGPTAutomaticRemote APIQuota and balance
Ollama CloudAutomaticRemote APIQuota and usage
OpenAIAutomaticRemote APIQuota
OpenCode GoNeeds setupDashboard scrapingQuota
OpenCode ZenNeeds setupDashboard scrapingBudget and balance
OpenRouterAutomaticRemote APIBudget and spend
SyntheticAutomaticRemote APIQuota
xAI SuperGrokAutomaticRemote APIQuota
Business / Enterprise
ProviderAuth/setupData fromReports
Anthropic (Claude)Needs setupLocal CLI/OAuthQuota
Chutes AIAutomaticRemote APIQuota
CursorNeeds setupLocal estimateBudget and spend
Gemini CLI (deprecated)Existing setups onlyRemote APIQuota
GitHub CopilotNeeds setupRemote APIUsage and budget
Google AGYNeeds setupRemote APIQuota
Google AntigravityNeeds setupRemote APIQuota
NanoGPTAutomaticRemote APIQuota and balance
OpenAIAutomaticRemote APIQuota
OpenCode ZenNeeds setupDashboard scrapingBudget and balance
OpenRouterAutomaticRemote APIBudget and spend
SyntheticAutomaticRemote APIQuota
xAI SuperGrokAutomaticRemote APIQuota

Gemini CLI quota support is deprecated for new installs. Existing v4 configurations still work, with removal planned for v5.0.0. See the provider guide before choosing a replacement.

Pre-configured Chinese providers

Personal
ProviderAuth/setupData fromReports
Alibaba Coding PlanAutomaticLocal estimateQuota
DeepSeekAutomaticRemote APIBalance and status
Kimi CodeAutomaticRemote APIQuota
MiniMax Coding PlanAutomaticRemote APIQuota
MiniMax Coding Plan (CN)AutomaticRemote APIQuota
Qwen CodeNeeds setupLocal estimateQuota
Xiaomi MiMoNeeds setupDashboard APIQuota and balance
Z.ai Coding PlanAutomaticRemote APIQuota
Zhipu Coding PlanAutomaticRemote APIQuota
Business / Team
ProviderAuth/setupData fromReports
Kimi CodeAutomaticRemote APIQuota
MiniMax Coding PlanAutomaticRemote APIQuota
MiniMax Coding Plan (CN)AutomaticRemote APIQuota
Zhipu Coding PlanAutomaticRemote APIQuota

These vendors offer team or business plans, but the current integrations report only the configured member API key rather than organization-wide usage.

The quota view uses short labels such as Day quota, 5h quota, Day budget, and Balance. Bar width varies by surface. JSON keeps the precise accounting type for scripts.

Custom providers

You can add a provider with an HTTPS quota API, or track a local usage estimate for one that does not have one. Run the guided setup:

npx @slkiser/opencode-quota@latest provider add

OpenRouter works automatically with the API key already configured in OpenCode. A custom OpenRouter definition remains available when you need a different endpoint or label.

For another API, choose the response format it uses: quota-v1 for OpenCode Quota's standard response, json-v1 to point to each value in a JSON response, or openrouter-key-v1 for OpenRouter's key endpoint. The setup asks one question at a time, never asks for a response body or secret, and shows the complete config before saving.

Setup details live in the Provider setup guide.

Troubleshooting

If quota or token data looks wrong:

  1. Run /quota_status in OpenCode, or opencode-quota status from a terminal for the same diagnostics. Use opencode-quota show for a quick quota glance.
  2. Confirm the expected provider appears in the detected provider list.
  3. Confirm companion auth plugins are before @slkiser/opencode-quota in opencode.json.
  4. If token reports are empty, start OpenCode once so it creates opencode.db, then run a session with model usage.
  5. Check Troubleshooting for common symptoms and provider-specific fixes.

Reference

Project guides:

External references:

Contributors

Thanks to everyone who has contributed to OpenCode Quota.

License

MIT

Remarks

OpenCode Quota is not built by the OpenCode team and is not affiliated with OpenCode or any provider listed above.

Star history

Star History Chart

About

OpenCode quota & tokens usage with zero context window pollution. Supports OpenCode Go, Cursor, GitHub Copilot, OpenAl, Kimi Code, Alibaba Coding Plan, Chutes Al, Google Antigravity, Z.ai Coding Plan and more.

Topics

Resources

Contributing

Stars

819 stars

Watchers

3 watching

Forks

Releases

Contributors

Languages