Track OpenCode quota & tokens via Toasts/Commands with zero context window pollution.
Quota provider supports: GitHub Copilot, OpenAI (Plus/Pro), Qwen Code, Chutes AI, Firmware AI, Google Antigravity, and Z.ai coding plan.
Token provider supports: All models and providers in models.dev.
Quota Toasts - See your remaining quota at a glance after each assistant response.
Token Report Commands - Track token usage and estimated costs across sessions using only local OpenCode SQLite history plus the bundled models.dev snapshot (no network calls).
- OpenCode >= 1.2.0 (uses SQLite
opencode.dbfor session/message history)
This plugin no longer supports the legacy folder-based JSON session storage used by older OpenCode versions.
Add to your opencode.json (strict JSON) or opencode.jsonc (JSONC with comments/trailing commas):
{
"plugin": ["@slkiser/opencode-quota"]
}That's it. Providers are auto-detected based on your OpenCode configuration. Toasts appear automatically after assistant responses.
Optional: To restrict which providers are queried, set enabledProviders explicitly:
{
"experimental": {
"quotaToast": {
"enabledProviders": ["copilot", "openai", "qwen-code", "google-antigravity"]
}
}
}LLM Agents: Ask your agent to install
https://github.com/slkiser/opencode-quotawith the providers you have enabled. See LLM Agent Installation Instructions for details.
| Command | Description |
|---|---|
/quota |
Show quota toast (verbose) |
/quota_status |
Show diagnostics (config, providers, accounts) + pricing health |
/tokens_today |
Tokens used today (calendar day) |
/tokens_daily |
Tokens used in last 24 hours |
/tokens_weekly |
Tokens used in last 7 days |
/tokens_monthly |
Tokens used in last 30 days (incl. pricing sections) |
/tokens_all |
Tokens used all time |
/tokens_session |
Tokens used in current session |
/tokens_between |
Tokens between two dates (YYYY-MM-DD) |
Token reporting commands are the /tokens_* family (there is no /token command).
| Provider | Config ID | Auth Source |
|---|---|---|
| GitHub Copilot | copilot |
OpenCode auth (automatic) |
| OpenAI (Plus/Pro) | openai |
OpenCode auth (automatic) |
| Qwen Code (OAuth) | qwen-code |
OpenCode auth via opencode-qwencode-auth |
| Firmware AI | firmware |
OpenCode auth or API key |
| Chutes AI | chutes |
OpenCode auth or API key |
| Google Antigravity | google-antigravity |
Multi-account via opencode-antigravity-auth |
| Z.ai | zai |
OpenCode auth (automatic) |
Token pricing coverage is broader than quota provider support: /tokens_* maps usage against all provider/model entries present in the bundled models.dev data snapshot.
GitHub Copilot
Setup: Works automatically if OpenCode has Copilot configured and logged in.
Optional: For more reliable quota reporting, provide a fine-grained PAT:
- Create a fine-grained PAT at GitHub with Account permissions > Plan > Read
- Create
copilot-quota-token.jsonunder OpenCode's runtime config directory (seeopencode debug paths):
{
"token": "github_pat_...",
"tier": "pro"
}username is optional (kept for backwards compatibility). If provided, it is used only as a fallback for legacy GitHub REST paths.
Both fine-grained PATs (github_pat_...) and classic PATs (ghp_...) should work. Fine-grained PATs must include Account permissions > Plan > Read.
Tier options: free, pro, pro+, business, enterprise
OpenAI
Setup: Works automatically if OpenCode has OpenAI/ChatGPT configured.
Qwen Code
Setup: Requires OAuth credentials from the opencode-qwencode-auth plugin.
Quota output for Qwen is local-only estimation:
- 1000 requests per UTC day (resets at UTC midnight)
- 60 requests per rolling minute
- Counter increments on successful question-tool completions while plugin is enabled and current model is
qwen-code/*
No remote quota endpoint is called for Qwen and Alibaba API is not used.
Local state file path:
.../opencode/opencode-quota/qwen-local-quota.json(under OpenCode state dir)
Use /quota_status to verify auth detection and local Qwen counter status.
If the local Qwen state file is missing, /quota_status reports usage from a default empty state.
Firmware AI
Setup: Works automatically if OpenCode has Firmware configured. Alternatively, provide an API key:
{
"provider": {
"firmware": {
"options": {
"apiKey": "{env:FIRMWARE_API_KEY}"
}
}
},
"experimental": {
"quotaToast": {
"enabledProviders": ["firmware"]
}
}
}The apiKey field supports {env:VAR_NAME} syntax or a direct key.
Chutes AI
Setup: Works automatically if OpenCode has Chutes configured. Alternatively, provide an API key:
{
"provider": {
"chutes": {
"options": {
"apiKey": "{env:CHUTES_API_KEY}"
}
}
},
"experimental": {
"quotaToast": {
"enabledProviders": ["chutes"]
}
}
}Google Antigravity
Setup: Requires the opencode-antigravity-auth plugin for multi-account support:
{
"plugin": ["opencode-antigravity-auth", "@slkiser/opencode-quota"]
}Account credentials are stored under OpenCode's runtime config directory (see opencode debug paths).
If you are troubleshooting, /quota_status prints the candidate paths checked for antigravity-accounts.json.
Z.ai
Setup: Works automatically if OpenCode has Z.ai (Coding Plan) configured.
All options go under experimental.quotaToast in opencode.json or opencode.jsonc:
| Option | Default | Description |
|---|---|---|
enabled |
true |
Enable/disable plugin |
enableToast |
true |
Show popup toasts |
toastStyle |
classic |
Toast layout style: classic or grouped |
enabledProviders |
"auto" |
Provider IDs to query, or "auto" to detect |
minIntervalMs |
300000 |
Minimum ms between provider fetches (default: 5 min); Qwen local RPM stays live on question triggers |
toastDurationMs |
9000 |
How long toasts display (ms) |
showOnIdle |
true |
Show toast on idle trigger |
showOnQuestion |
true |
Show toast after a question/assistant response |
showOnCompact |
true |
Show toast after session compaction |
showOnBothFail |
true |
If providers attempt and fail, show a fallback toast |
onlyCurrentModel |
false |
Only show quota for the current model (best-effort) |
showSessionTokens |
true |
Show per-model input/output tokens in toast |
layout.maxWidth |
50 |
Formatting target width |
layout.narrowAt |
42 |
Compact layout breakpoint |
layout.tinyAt |
32 |
Ultra-compact layout breakpoint |
googleModels |
["CLAUDE"] |
Google models: CLAUDE, G3PRO, G3FLASH, G3IMAGE |
debug |
false |
Show debug info in toasts (and a debug-only toast when otherwise suppressed) |
npm install
npm run typecheck
npm test
npm run test:watch
npm run buildToast not appearing? Run /quota_status to check config, provider availability, and whether opencode.db is detected.
If opencode.db is missing, run OpenCode once (OpenCode performs a one-time migration into SQLite on first run after upgrade).
LLM Agent Installation Instructions
This section provides instructions for LLM agents to install and configure opencode-quota based on the user's current OpenCode setup.
First, determine what providers the user has connected. You can:
- Read the user's
opencode.jsonoropencode.jsonc(typically at~/.config/opencode/) - Run
/connectedin OpenCode to see active providers - Ask the user which providers they use
Add the plugin to the user's opencode.json (or opencode.jsonc):
{
"plugin": ["@slkiser/opencode-quota"]
}If the user already has plugins, append to the existing array.
By default, providers are auto-detected. If the user wants to restrict which providers are queried, add explicit enabledProviders:
| If user's config has... | Add to enabledProviders |
|---|---|
github-copilot provider or Copilot models |
"copilot" |
openai / chatgpt provider |
"openai" |
qwen-code provider |
"qwen-code" |
firmware / firmware-ai provider |
"firmware" |
chutes provider |
"chutes" |
google provider with antigravity models |
"google-antigravity" |
opencode-antigravity-auth in plugins |
"google-antigravity" |
opencode-qwencode-auth in plugins |
"qwen-code" |
For a user with Copilot and Google Antigravity:
{
"plugin": [
"opencode-antigravity-auth", // Required for google-antigravity
"@slkiser/opencode-quota",
],
"experimental": {
"quotaToast": {
"enabledProviders": ["copilot", "google-antigravity"],
"googleModels": ["CLAUDE"], // Options: CLAUDE, G3PRO, G3FLASH
"minIntervalMs": 300000, // 5 minutes between fetches
"toastDurationMs": 9000, // Toast shows for 9 seconds
},
},
}After configuration, instruct the user to:
- Restart OpenCode (or reload the window)
- Run
/quota_statusto verify providers are detected - Run
/quotato manually trigger a toast
- Toast not showing: Run
/quota_statusto diagnose - Google Antigravity not working: Ensure
opencode-antigravity-authplugin is installed and accounts are configured - Copilot quota unreliable: Consider setting up a fine-grained PAT (see Provider-Specific Setup above)
MIT
Opencode Quota is not built by the OpenCode team and is not affiliated with them in any way. It is not affiliated with any providers listed above.


{ "experimental": { "quotaToast": { "enabledProviders": [ // Add only the providers the user has configured: // "copilot" - if using GitHub Copilot // "openai" - if using OpenAI/ChatGPT // "qwen-code" - if using Qwen Code OAuth (requires opencode-qwencode-auth) // "firmware" - if using Firmware AI // "chutes" - if using Chutes AI // "google-antigravity" - if using Google Antigravity (requires opencode-antigravity-auth) ], }, }, }