Aggregate AI subscription/API usage and flag use-it-or-lose-it allotments
pip install aiuse==3.12.1 Copy PIP instructions
Your AI subscriptions reset unused capacity you already paid for. Claude, Codex, Copilot, Cursor, Grok, Gemini, OpenCode, and more each carve your usage into 5-hour / weekly / monthly windows — and whatever you don't burn by the reset is just gone. aiuse polls every plan you have from one terminal command and tells you, in plain language, what to use right now before it resets, and what's about to run out early so you can pace yourself.
CLI command: aiuse (stub ai → same entrypoint)
Every report line's vendor name is grep-able (case-insensitive, substring OK) for the actual agent CLI whose quota it tracks:
aiuse --json exposes this same mapping per account row as cli_binary (null when there is no local CLI) — see docs/json-contract.md. Note the trap this table exists for: the quota CLIs (qwencloud, bl, caut, caam, tokscale, openusage, cswap, codexbar) measure usage; they are not how you burn it.
This is real aiuse output from synthetic demo accounts, not a screenshot. It's the exact table printed by plain aiuse, read bottom → top: the pools most worth using right now sort to the bottom.
A sub-day rolling window (the 5-hour kind) that has not been used yet sends no reset time — its clock starts on first use — so its cell shows the window's full length and a ↻ marker instead of a countdown, e.g. 0u/100l/5h↻. Unused windows of a day or longer get no span. The legend line ↻ = starts on first use appears only when at least one such cell is on the board. The marker is screen-only; --json is unchanged.
An in-use window whose source stops sending its reset time (CodexBar sends none for Antigravity's 5-hour windows; OpenUsage does) keeps its countdown: aiuse carries forward the last reset an earlier reading measured for that window, from any source, while that reset is still ahead and the window's usage has not fallen since (a fall means it reset). A carried time is an estimate, so it renders with ~ like any estimated reset (~3h), and --json marks it with resets_at_carried_from (docs/json-contract.md). A window that has not been used yet is never carried: its reported reset only slides with every query.
The colored ## score is the action queue from 0 (empty) to 99 (use as soon as possible). Its action-state boundaries are contiguous: slow ends at 49, mid runs from 50–74, and an active use recommendation starts at 75. ?? means usage could not be fetched; -- means rolling prepaid/PAYG inventory has no use-or-lose urgency.
Inside each live band (slow 25-49, mid 50-74, use 75-99) the score is how much money is at risk in the pool's window, log-scaled onto the band's range (6 points per decade, $0.01 at the band's floor to $100 at its ceiling). A window is priced from the plan's monthly_price in [plans. ], spread over the window's refills per waking month (16 waking hours a day by default, so a 5-hour window is 1/97 of the month and a weekly one about a third) and scaled by the plan's value_multiplier. Two figures come out of that price:
The band's older signal only breaks ties: recovery speed in slow, the analyzer score in mid and use. A window whose length is neither reported nor named in its label has no refill to price and sits at its band's floor. Plan tier is not detected, so each provider defaults to its lowest tier: set [plans.claude] monthly_price = 200 for Max, or [plans.claude."me@x.com"] monthly_price = 200 for one account (the account value wins). For ordering, a provider with no price is valued at the cheapest configured plan; it still shows no dollar figure.
aiuse suggest, the JSON suggestion and the use: head of aiuse status name the burn the board ranks last — the bottom use row, else the bottom mid row a burn alert backs — not the loudest analyzer score.
Green (use) is capacity to burn now before it resets; red is capacity already lost (empty, including a zero/negative prepaid balance) or a source that failed to fetch (error); everything else is informational (n/a positive prepaid balances that never expire, slow windows you should pace yourself on, mid windows on track — nothing to do).
Services are named for the CLI you actually type, so the name doubles as something to grep for. The two OpenCode services are the exception — they abbreviate to an oc- family prefix (oc-go, oc-zen) to stay narrow.
pipx install aiuse aiuse doctor # see which data-source tools are already on your PATH aiuse # usage table for everything aiuse can see right now No config file is required to start — aiuse doctor tells you exactly which of the optional data-source tools (below) it found, and aiuse works with however many you already have installed. See Install below for Homebrew, git-tip, and editable-dev options.
AI agents: start at AGENTS.md for a map of this repo, active priorities, and contributor guidance.
This project shells out to tools already on your PATH (and optionally hits CodexBar's loopback HTTP server and OpenUsage’s loopback API); it does not scrape billing dashboards itself. For more on collector setup, reliability, and source selection, see the documentation index.
Use cswap as the Claude source and CodexBar for every other provider. Keep CodexBar's Claude source disabled, even as a fallback. tokscale and paseo are the cross-check sources that stay supported. caut, caam, OpenUsage.ai, and OpenUsage.sh are deprecated because they overlap that set; the code still runs when the tool is installed, and support comes back if someone asks. All collectors are enabled by default, whether installed now or prepared for later; disable any source in config.toml when it is not appropriate for your machine. On macOS, keep CodexBar's Claude integration disabled while its Keychain-prompting bug is open.
pipx install aiuse # or from git tip: # pipx install 'git+https://github.com/djbclark/aiuse.git' aiuse doctor (ai is installed as a stub that runs the same CLI.)
brew tap djbclark/aiuse brew trust djbclark/aiuse brew install aiuse Developers (editable):
cd /path/to/aiuse python3 -m venv .venv source .venv/bin/activate pip install -e ".[dev]" Optional config (standard location: ~/.config/aiuse/, or $XDG_CONFIG_HOME/aiuse/):
# Create the canonical config.toml (never overwrites) aiuse --generate-config # Or copy the example by hand: mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/aiuse" cp config/config.example.toml "${XDG_CONFIG_HOME:-$HOME/.config}/aiuse/config.toml" File Purpose ~/.config/aiuse/config.toml All user settings: collectors, plans, analysis, timeouts, and macOS options aiuse --generate-config creates missing parent directories and writes the TOML starter without overwriting it. Provider credentials stay with cswap, CodexBar, caut, OpenUsage, and tokscale — this file does not hold tokens or emails.
OpenCode Zen prepaid balance is a distinct service from OpenCode Go quota. CodexBar can report it, and aiuse can independently cross-check the live OpenCode billing response when a signed-in browser session is available. This is opt-in and normal collection never opens a browser or reads its cookie database.
# One-time optional browser reader for a pipx install. pipx inject aiuse browser-cookie3 # Validate the OpenCode session, then save only the validated cookie through # SecretSpec. The default manifest is ~/.config/aiuse/secretspec.toml. aiuse credential refresh opencode-zen --from chrome --profile Default The command reads only opencode.ai cookies, validates an authenticated workspace and a live Zen balance before saving, and never prints the cookie. Use --dry-run to validate without saving. aiuse credential refresh --help lists its confirmation, profile, timeout, and manifest options. See the OpenCode Zen balance guide for the source model and SecretSpec details.
aiuse normally unifies source-local account names automatically when each identifying source reports exactly one account for a provider. For a genuinely multi-account provider, map a local name explicitly instead of letting aiuse guess:
[account_aliases.codex.openusage_sh] "codex-cli" = "me@example.com" aiuse --full prints this exact table when a multi-account source cannot be matched safely. Explicit mappings take precedence over automatic normalization.
When one source reports several accounts for a provider (Claude excepted, which cswap owns), aiuse picks the best source per account, so an account only one tool sees still gets its row, and cross-checks pair rows only by matching label. Several ClinePass accounts, for example, need CodexBar's --all-accounts and labelled native keys:
# One row per CodexBar token account. [collectors.codexbar] all_accounts = ["clinepass"] # http_url = "http://127.0.0.1:10546" # http_token = "" # Label = the CodexBar token-account name. Key: env first, then # secretspec, then sudo-secretspec. [[collectors.clinepass.accounts]] label = "work" env = "CLINEPASS_API_KEY_WORK" secret = "CLINE_API_KEY" [[collectors.clinepass.accounts]] label = "personal" secret = "CLINE_API_KEY_PERSONAL" See ClinePass quota.
Some vendors rate-limit quota probes. aiuse reads agy's (Antigravity's) quota at most once every 15 minutes across every aiuse process (CLI, LaunchAgent, watch, serve), reusing the last reading in between. Tune or disable it per provider, in seconds. See Antigravity pools: query rate limit:
[query_min_interval] antigravity = 900 # 0 disables Daily workflow # Once: create defaults under ~/.config/aiuse/ (never overwrites) aiuse --generate-config aiuse doctor # PATH tools + config presence + timeouts # Once per machine: install the data-source tools you intend to use # (normally cswap, CodexBar, and tokscale; caut, caam, and both OpenUsage tools are deprecated) ./packaging/install-deps.sh # or: just -f ~/ops/site-djbclark/justfile install-aiuse-deps # macOS: follow the trust guide from the documentation index when needed aiuse trust setup # caut: stable codesign + guide aiuse trust sign-caut # re-run after every cargo install aiuse trust fix-codexbar-cache --dry-run # CodexBar#679: trust CLI on cache items # Optional: refresh the separately reported OpenCode Zen prepaid balance. aiuse credential refresh opencode-zen --from chrome --profile Default # Morning / before a long coding block aiuse # usage table on stdout (use-soon at bottom); meta on stderr aiuse --full # long report: per-provider, tips, History, detailed plan aiuse --brief # same as default (compat alias) aiuse --no-tui # classic plain-text report (also used when piping) aiuse -q # table only (no stderr meta / Collecting…) aiuse suggest # single best burn pool (or “nothing urgent”) aiuse status # one line for shell prompts / status bars aiuse prompt # synonym of status # Shell completion (bash or zsh) eval "$(aiuse --print-completion bash)" # or: source completions/ai.bash # Tighter thresholds for “only what resets soon” aiuse --min-remaining 50 --max-days 7 Usage # Pretty human-readable report (default) aiuse aiuse --format pretty aiuse --no-color # plain text, no ANSI aiuse -q / --quiet # suppress progress on stderr # or without install: PYTHONPATH=src python -m ai # Machine-readable JSON on stdout (progress on stderr unless -q) aiuse --json aiuse --format json aiuse --json --alerts-only aiuse suggest --json aiuse --save ~/tmp/ai-snapshot.json # also write JSON file # Decision helpers aiuse suggest # single best burn pool aiuse status # one line for prompts / status bars aiuse prompt # synonym of status aiuse serve # loopback HTTP API for agents aiuse watch # full-screen board (q/esc quit · u now · a all; screen-only sweep; default 10m) aiuse watch -i 2m # faster refresh aiuse watch --once # one frame on stdout (scripts / tmux) aiuse watch --all-providers # OPERATOR-ONLY: live board of every provider, screen only (see below) aiuse attribute # what spent the quota: points burned beside tokens per client aiuse attribute --since 7d --provider clinepass --intervals aiuse sample # scheduled entry point: samples faster while quota is moving # Faster / partial aiuse --providers copilot,grok,codex # query these separately aiuse --no-tokscale aiuse --min-remaining 50 --max-days 10 # Subprocess timeout for external tools (default 45s; also in config.toml) aiuse --timeout 45 aiuse -t45 # Environment check (tools on PATH, config files, timeouts) — no usage collection aiuse doctor aiuse --doctor Programmatic use and AI orchestration aiuse turns the many local authenticated quota sources into one normalized, machine-readable snapshot. An agent can call it once instead of opening billing pages, finding credentials, or independently interpreting each provider’s reset bars — saving tokens and avoiding inconsistent conclusions.
# Full live snapshot, ranked alerts, and the best next action. aiuse -q --json # Only actionable alerts for a short agent/tool call. aiuse -q --json --alerts-only # The single best pool to use next, or null when there is nothing urgent. aiuse suggest --json JSON is written to stdout; -q keeps progress off stderr. Exit 0 means a successful run with no burn/conserve alert, 1 is a hard collection failure, and 2 is a successful run with an actionable alert. The stable fields and exit-code contract are in docs/json-contract.md.
For a long-lived local agent, aiuse serve provides the same decisions through a loopback HTTP API; see the documentation index.
aiuse watch --all-providers (and the watch a key) is operator-only. AI agents and automation must not run it without explicit permission from the human operator. It polls every provider, deliberately overriding [disabled_services], [hidden_pools], analysis.excluded_pools, hidden ceiling/total rows, and collector disable flags — providers are disabled for reasons (vendor rate limits, cost, opt-outs) that this sweep ignores. Its output is display-only: nothing is written to snapshots, the token ledger, or sampler state, though the shared cross-process query throttle still applies so the sweep cannot hammer a vendor.
Projects that want the ranking logic without depending on this CLI can reuse the language-neutral shared quota semantics: JSON Schemas, enums, pace rules, and golden fixtures are designed to be copied or validated from any language. aiuse uses those fixtures itself, but they do not require importing its Python package.
aiuse doctor checks config file presence, config validation (unknown keys, bad timeouts, dead plan aliases), all seven data-source tools on PATH (and OpenUsage.ai loopback HTTP when the CLI is missing), and a light version probe (cswap --version, codexbar -V, caut --version, caam --version, tokscale --version). It does not call usage APIs or verify login sessions.
Most subscription coding plans (Claude Pro/Max, ChatGPT Plus/Codex, Cursor, Copilot, SuperGrok, Google AI Pro, …) grant windows of usage (5-hour, weekly, monthly). When the window resets, unused capacity disappears — you still paid for the month.
This command intentionally does not report historical local-token usage or API-equivalent cost estimates (use ccusage-class tools for local burn, not plan %).
CodexBar reads the Max plan's promotional API credits from claude.ai and can report "100% unused" while the Anthropic console shows the grant half spent. The Anthropic Admin API has no credit-balance endpoint (its GET /v1/organizations/cost_report returns cost-to-date only), so record the console figures yourself:
aiuse set-credits omp --remaining 95.57 --total 200 --expires 2026-11-08 --note "console 2026-10-19" The figures go to ~/.cache/aiuse/credit-overrides.json with a timestamp and are applied at read time (--json, --available, serve), so a cached snapshot is corrected too. Which reading wins:
When CodexBar gives no updatedAt, observed_at falls back to the snapshot's collection time. The plain aiuse report does not apply the override; --json, --available and serve do.
source (codexbar or operator-override) and observed_at are in the omp account and pool JSON, and age_seconds/stale derive from observed_at. expires_at is on the account and the pool.
When an expiring grant lapses within 21 days and more than 50% is left (the bar slides down in the last 10 days: 25% at 5 days out, 5% at 1 day), the pool carries burn_before_reset (expires_at, days_left, remaining_percent, remaining_usd, suggestion) and aiuse --available prints burn before reset: ... under its line. remaining_percent still means the share left (used_percent is the share consumed).
The Anthropic Admin API has no balance endpoint, but its cost report (GET https://api.anthropic.com/v1/organizations/cost_report, docs: https://platform.claude.com/docs/en/api/beta/organization/cost_report/retrieve) gives the spend since a date, so the balance is derived: grant total minus spend since the grant date, clamped to 0..total. It is a lower bound on the promo balance: the cost report counts all org spend since granted_at, including spend the grant did not cover (the first real run read $89.56 against the console's $95.57). Give the grant parameters once, on the override:
Hourly refresh with launchd (not loaded for you). The wrapper is copied out of the checkout so a branch switch cannot change what launchd runs:
mkdir -p ~/.local/bin ~/Library/LaunchAgents ~/Library/Logs/aiuse install -m 755 packaging/launchd/aiuse-credits-refresh ~/.local/bin/aiuse-credits-refresh gsed -e "s|@REFRESH_BIN_PATH@|$HOME/.local/bin/aiuse-credits-refresh|" -e "s|@AIUSE_BIN_PATH@|$(command -v aiuse)|" \ -e "s|USER_LOCAL_BIN|$HOME/.local/bin|" -e "s|LOG_DIR|$HOME/Library/Logs/aiuse|" \ packaging/launchd/com.djbclark.aiuse-credits-refresh.plist \ > ~/Library/LaunchAgents/com.djbclark.aiuse-credits-refresh.plist launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.djbclark.aiuse-credits-refresh.plist Unload with launchctl bootout gui/$(id -u)/com.djbclark.aiuse-credits-refresh.
================================================================================ AI USAGE — USE IT OR LOSE IT Collected at … · 3 accounts · 2 alerts ================================================================================ ## Per-provider usage -------------------------------------------------------------------------------- Codex · account=you@example.com · plan=plus · selected live source: CodexBar quota: Codex weekly quota [============] 100% left 0% used resets in 6.4d (Tue Jul 28 9:59pm) flex:▒ semi · pace -100% ## Cross-checks (informational) -------------------------------------------------------------------------------- Tools poll at different times; multi-account Claude is cswap-only. … ## Tips -------------------------------------------------------------------------------- • … ## Action plan — use these before they reset -------------------------------------------------------------------------------- 6 windows with unused capacity across 5 providers. THIS WEEK (start now — capacity will reset or needs lead time) ───────────────────────────────────────────────────────────── . Codex · you@example.com · Codex weekly quota: 88% left · use within 6.4 days · pace -40% — projected 52% unused@reset Semi-throttled — steady usage will exhaust it. . OpenCode Go · default · OpenCode Go weekly quota: 98% left · use within 4.5 days · pace -95% — projected 91% unused@reset Burstable — one heavy session will cover it. Project layout src/aiuse/ cli.py # entrypoint collectors/ # cswap, codexbar, caut, caam, openusage, tokscale analysis/use_or_lose.py report.py config/config.example.toml tests/ Tests just test just check # tests plus deterministic lint, type, spelling, and format checks just lint # full check plus Bandit, Semgrep, and Gitleaks just format The quality suite mirrors the applicable tools from stayturgid: pytest, Ruff, mypy, yamllint, markdownlint, Prettier (including TOML support), typos, Bandit, Semgrep, Gitleaks, pre-commit, and just. Ansible, shell, JavaScript/CSS, dotenv, Caddy, and browser-page checks are omitted because this repository contains none of those corresponding inputs.
Pace knobs (in config.toml under [analysis.pace]):
Shared allotment: analysis.provider_overrides. .shared_allotment: true (Claude/Gemini default) scores only the longest window per account.
Lapsed subscriptions: analysis.lapsed_accounts maps "provider/account" to a reason (e.g. "claude/me@mit.edu" = "not renewed"). A not-renewed plan keeps serving stale collector cache that looks like usable quota; the entry makes that account show as empty instead of on-pace.
Excluded pools: analysis.excluded_pools maps "provider" or "provider/pool_family" to a reason (e.g. "grok" = "reserved for another agent"). The quota stays in every report, but aiuse --available leaves the pool out of its shortlist and lists it under excluded (JSON) or on stderr (text), so orchestrators never route to it.
Disabled services: top-level [disabled_services] maps "provider" to a reason (e.g. "grok" = "vendor shelved until its reset"). Stronger than an exclusion — for TUIs that must temporarily not be used even though they have headroom: provider-only collectors skip the service entirely (no subprocess/authenticated fetch), its rows are dropped from every report, snapshot and history entry, --available never lists it (even from a cache written before the entry), and the reason travels on the snapshot as disabled_services so readers know why the provider is absent. aiuse doctor warns when a provider-only collector override for a disabled provider silently has no effect.
Hidden pools: top-level [hidden_pools] maps "provider" or "provider/pool_family" to a reason (e.g. "cursor/auto" = "not routing Auto this week"). Display-only: matching windows are dropped at collection and omitted from human outputs and --available. Weaker than [disabled_services]; stronger than analysis.excluded_pools (routing-only).
Ceiling rows: analysis.show_total_rows (default false) hides total/ceiling rows in the board, --full, --for-chat, and --available when breakdown sub-rows exist. JSON always includes them with role: "ceiling"; sub-rows carry effective_left_percent when the ceiling binds.
All 2 files in this release have provenance metadata.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
All 2 files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Jul 25, 2026 2 release files Loss of provenance




