@aholbreich/pi-quota0.2.0
Pi extension that shows AI subscription quota in the footer and lets the agent check it before spending.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-quota
See how much of each AI subscription is left, right in Pi's footer, and let the agent check quota before it spends any, for example before it launches a subagent.
~/git/project (main)
↑49k ↓8.7k $1.533 17.5%/272k (openai-codex) gpt-6.2-astra • minimal
tl 0.12.0: no ledger Codex 5h ━━━───── 43% ⟳ 4h 7m W ━━────── 26% ⟳ 6d 10h
Install
pi install npm:@aholbreich/pi-quota
Try it for one session without installing:
pi -e npm:@aholbreich/pi-quota
Run /reload in sessions that are already open. Tested with Pi 1.7.
Supported subscriptions
| Pi provider | Shown as | Reads |
|---|---|---|
openai-codex |
ChatGPT Codex subscription: 5-hour and weekly windows | Pi's ChatGPT login |
github-copilot |
GitHub Copilot subscription: monthly premium requests | Pi's GitHub Copilot login (github.com) |
claude-code |
Claude subscription: 5-hour and weekly windows | The Claude CLI login (~/.claude, or CLAUDE_CONFIG_DIR) |
deepseek |
DeepSeek account balance | The DeepSeek API key stored in Pi |
Local models such as llama.cpp have no quota and are never shown as limited.
Claude quota is shown for models of a provider named claude-code, which uses the Claude CLI
login. Pi's built-in anthropic provider is a different login and is not mapped to it.
Footer
When the current model belongs to a supported subscription, the footer shows one thin bar per usage window, directly beneath the model name and aligned with it on the right:
- Bar and percentage: how much of the window is used, in your theme's success colour below 70%, warning from 70% and error from 90%.
⟳ 4h 7m: time until the window resets.- DeepSeek: the balance as an amount, without a bar.
quota unknown: the quota could not be read. Unknown never counts as exhausted.12m old: the last reading is older than the refresh interval.
For a llama.cpp model, the quota row shows router reachability instead of quota:
llama.cpp ● router (reachable), llama.cpp ○ router offline (connection failed or timed out),
or llama.cpp ? router (not yet checked or inconclusive). This does not check whether a model
is loaded or start inference.
In the interactive terminal UI, pi-quota checks at startup, on model selection and once a minute while a
llama.cpp model is active. It uses the active model's base URL from Pi's catalog, which Pi configures
through /login llama.cpp or LLAMA_BASE_URL (the Pi 1.6+ default is http://127.0.0.1:9931). The
one-second, unauthenticated health check uses /health or /v1/health for Pi's usual chat base URL.
It accepts only loopback addresses or localhost, does not follow redirects, and does not print the
configured URL. Missing or nonlocal URLs, URLs containing credentials, query parameters or fragments,
and ambiguous responses such as proxy authentication errors show unknown. A stale catalog entry may
still point to the previous router. RPC and headless sessions do not run the footer check.
Other extensions' statuses share the quota row on the left when both fit, and move to the next row in narrow terminals.
pi-quota draws Pi's footer itself, because Pi statuses can't be right-aligned. It installs the footer once per session. If another extension later installs its own footer, that one wins and pi-quota does not take it back.
Agent tool: quota_status
pi-quota gives the agent a quota_status tool, plus one rule in the system prompt: check
quota_status before launching a subagent. The tool also works in print mode and other sessions
without a terminal UI.
Claude subscription: unknown
ChatGPT Codex subscription: usable; 5-hour: 57% left (resets in 4h 7m)
GitHub Copilot subscription: exhausted (resets in 6d 4h); monthly: 0% left (resets in 6d 4h)
DeepSeek account balance: 14.20 USD
llama.cpp router: reachable
Local candidates: llama.cpp/local-qwen3.6-35b-a3b
Usable subscription alternatives: ChatGPT Codex subscription (openai-codex, 1 model)
- Without arguments: connected providers, local router status when applicable, local model candidates,
and usable subscriptions as alternatives. Subscription alternatives require known remaining allowance and
name the Pi provider; the agent is told to get model IDs with
pi --list-models <provider>. - With
{"provider": "openai-codex"}: only that subscription. Use{"provider": "llama.cpp"}for just the router state and local candidates. - Verdicts:
exhaustedmeans a reading no more than five minutes old shows a window at 100% used with a future reset. If multiple windows are exhausted, the verdict reports the latest reset.usablemeans a fresh reading shows allowance and no reported window is exhausted. Missing, invalid, stale or fully expired readings giveunknown. Account balances and local models are not judged by subscription windows.
The tool reuses the terminal footer's router observation when available. Otherwise it can make one bounded health check, cached for one minute in the session. It checks the selected local model's endpoint, or a single configured endpoint in the catalog if no local model is selected. With no unambiguous endpoint, it reports unknown. A local candidate is a catalog entry, not a guarantee that its model is loaded or can run. Quota verdicts and alternatives are advisory: pi-quota neither blocks requests nor changes the selected model.
Ask the agent, for example: "Check quota before choosing a model for the subagent."
Privacy and limits
- Read-only credentials: pi-quota only reads logins that Pi or the Claude CLI already stored. It
never writes, refreshes or resolves them. An expired login shows
quota unknownuntil Pi or the CLI refreshes it. - No secrets in output: tokens, account emails and raw provider replies never appear in the footer, the tool output or the cache.
- At most one read per 5 minutes: each provider is read at most once every 5 minutes, shared by
the footer, the tool and all Pi processes of the same profile, including subagents. Only usage
percentages, reset times and balances are cached, in
<Pi profile>/pi-quota-cache-v1/(owner-only permissions). - Unknown instead of extra reads: if that cache can't be kept safely, for example on Windows or when the Pi profile is inside a git checkout, quota shows as unknown instead of being read more often.
- Unofficial endpoints: Claude and GitHub Copilot quota come from endpoints their own apps use. They are not documented and may change.
- Not read: DeepSeek keys that Pi resolves from an environment variable or a command, and GitHub Enterprise Copilot logins.
Development
This project follows BDD: behavior is specified in features/*.feature first. See AGENTS.md.
npm install
npm run check # TypeScript
npm run test:all # unit tests + Cucumber
pi -e ./extensions/quota/index.ts
Releases: see docs/release-workflow.md.
License
MIT