Skip to content

Repository files navigation

agent-quota

One command, terminal tables for the AI products that matter when you live inside subscription and rate-limit windows: Claude, OpenAI Codex, GitHub Copilot, OpenCode, Z.ai, plus optional balance views for OpenCode Zen, OpenRouter, and DeepSeek.

agent-quota is positioned first as a tracker for subscription-backed and rate-limited AI usage: rolling windows, weekly caps, monthly included quotas, token buckets, and similar limits. That is the main product surface, and today it includes Claude, Codex, Copilot, Z.ai, and OpenCode, with room for more IDE and platform subscriptions in the same shape. Codex currently reports its weekly included usage window and displays the remaining allowance. The usage table now shows Plan and User metadata next to each provider's windows; providers that do not expose those fields yet render or Unknown.

Pay-as-you-go balances are still supported, but as a secondary table for credits and prepaid balances such as OpenCode Zen, OpenRouter, and DeepSeek. Usage-based bars display the remaining allowance, with colour shifting to yellow below 30% and red below 10%; rows without a percentage render as plain text. Claude now resolves plan, team, and user details from its account and organization endpoints; Codex resolves the subscription plan plus the signed-in user name from the ChatGPT session payload. Human-readable Codex team/workspace names are still limited by what that session payload exposes.

Originally based on waybar-ai-usage by @NihilDigit, now a standalone project — no Waybar / Wayland / Linux dependency. Just a terminal.

Install

# from a clone
uv sync
uv run agent-quota

# or install as a uv tool
uv tool install .
agent-quota

Requires Python 3.11+ and uv.

Usage

agent-quota                       # one-shot table (uses ~/.config/agent-quota/config.toml)
agent-quota setup                 # interactive picker for which providers to enable
agent-quota --watch               # auto-refresh every 15s
agent-quota --watch 30            # custom interval
agent-quota --only claude,codex   # one-off subset (overrides config)
agent-quota --view usage          # show only the usage-based limits table
agent-quota --view payg           # show only the pay-as-you-go quota table
agent-quota --browser firefox     # cookie source for cookie-auth providers

Press Ctrl+C to exit watch mode. Exit code is 0 if every selected provider is OK, 1 otherwise.

First run

The first time you run agent-quota without a config file, it prompts you to pick which providers to monitor and saves your selection to ~/.config/agent-quota/config.toml. The setup flow lists subscription/rate-limit providers first:

# agent-quota configuration
# Edit this file or run `agent-quota setup` to change.
enabled = ["claude", "codex", "copilot"]

For API-auth providers, agent-quota setup also offers to collect the key inline and writes the matching per-provider config file for you. Re-run agent-quota setup any time to change the selection or update saved keys. Pass --only to override the config for a single invocation. If stdin/stdout aren't a TTY (e.g. running from cron or piped), agent-quota skips the prompt and falls back to all providers so non-interactive use still works.

Auth per provider

Provider Auth What you need
Claude Browser cookies Be logged into claude.ai in any supported browser
Codex Browser cookies Be logged into chatgpt.com
Zen Browser cookies Be logged into opencode.ai
Copilot GitHub PAT or browser cookies Token in ~/.config/agent-quota/copilot.conf, or be logged into github.com (org-managed Copilot)
Z.ai API token (JWT) Token in ~/.config/agent-quota/zai.conf
OpenRouter Management key Key in ~/.config/agent-quota/openrouter.conf
DeepSeek API key Key in ~/.config/agent-quota/deepseek.conf

Supported cookie sources: chrome, chromium, brave, edge, firefox, helium. The first one that has a valid session wins. Override order with --browser <name> (repeatable).

For Copilot, Z.ai, OpenRouter, and DeepSeek, setup will prompt for the token/key when you enable the provider. You can still edit the corresponding ~/.config/agent-quota/*.conf file manually later.

Copilot config

# ~/.config/agent-quota/copilot.conf
GITHUB_TOKEN=github_pat_...   # fine-grained PAT with "Plan (read)" permission
COPILOT_QUOTA=300             # your monthly included quota; default 300

Org-managed Copilot accounts can omit GITHUB_TOKEN — the tool falls back to scraping github.com/settings/copilot/features using your browser cookies.

Z.ai config

# ~/.config/agent-quota/zai.conf
ZAI_TOKEN=eyJ...              # web JWT or GLM Coding Plan API key

Works with two token shapes:

  • Web session JWT — open z.ai → DevTools (F12) → Network → any api.z.ai request → copy the Authorization header value only, without the Bearer prefix.
  • GLM Coding Plan API key — paste it directly.

The monitor API expects the raw token (no Bearer ), so the same ZAI_TOKEN field accepts either format. The web JWT can't be auto-refreshed; if it expires, copy a fresh one from DevTools. GLM Coding Plan keys are long-lived.

OpenRouter config

# ~/.config/agent-quota/openrouter.conf
OPENROUTER_API_KEY=sk-or-...

OpenRouter documents GET /api/v1/credits against a management key, so use a key with access to the credits endpoint.

DeepSeek config

# ~/.config/agent-quota/deepseek.conf
DEEPSEEK_API_KEY=sk-...

Caching

Results are cached in ~/.cache/agent-quota/<provider>.json (TTL: 60s, Z.ai 120s). Concurrent runs (e.g. --watch + a one-shot) coordinate via .updating marker files.

Per-provider CLI

Each provider also has a standalone debug CLI:

uv run python -m providers.claude
uv run python -m providers.codex
uv run python -m providers.copilot
uv run python -m providers.zai
uv run python -m providers.zen
uv run python -m providers.go
uv run python -m providers.openrouter
uv run python -m providers.deepseek

These are useful for diagnosing a specific provider in isolation.

License

MIT — see LICENSE.

About

Integrated TUI to monitor subscription rate-limit windows and API quota.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages