pi-sub-quota

Coding-plan quota and prepaid balance in the pi footer, shown only while a supported provider such as ZAI/GLM, Kimi, DeepSeek, Moonshot, MiniMax, Anthropic, Codex, OpenRouter, or OpenCode Go is active

Packages

Package details

extension

Install pi-sub-quota from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-sub-quota
Package
pi-sub-quota
Version
0.2.4
Published
Nov 4, 2026
Downloads
648/mo · 389/wk
Author
ohmrabit
License
MIT
Types
extension
Size
145 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-sub-quota

See your coding-plan quota — and your prepaid balance — right in the pi footer. Nothing to run: while a supported provider is active, the numbers are simply there:

↑1.2k ↓3.4k 38%/200k                    (zai-coding-cn 13% 58%) glm-5.3 • max
↑1.2k ↓3.4k 38%/200k                 (zai-coding-cn 96% 41m 58%) glm-5.3 • max
↑960 ↓1.2k 38%/200k                      (deepseek ¥18.67+¥1.00) deepseek-flash • max
  • The two percentages are your plan's usage windows — the 5-hour one first, then the 7-day one. Green means plenty left, amber means watch out, red means nearly gone.
  • The countdown (41m) appears on its own when a window needs attention: it is nearly used up (≥ 80%) or about to reset (within 30 minutes). Quiet windows stay quiet and show only their percentage.
  • DeepSeek has no usage windows; you see your balance instead, split into what you topped up and what was granted (¥18.67+¥1.00), exact to the cent. Accounts with several currencies show one balance per currency.

Install

pi install npm:pi-sub-quota

Restart pi (or run /reload). There is nothing to configure: the extension reuses the credentials pi already stored, so the quota always belongs to the account pi is actually running with. When no supported provider is active — or there is no data yet — the footer stays exactly as pi built it.

Commands

Command Effect
/quota cached quota for every configured provider, instantly — stale numbers refresh in the background and the panel updates when they land
/quota refresh force a re-fetch for the active provider now (at most one request per provider per minute, machine-wide, plus one immediate in-cycle retry when a request fails)
/quota mode inline|line|off how — and whether — the footer shows quota
/quota help list options

Everything completes with Tab. inline is the default, and your choice is remembered across sessions; off restores the built-in footer.

The two display modes

inline (default) — the numbers live inside the provider prefix:

(zai-coding-cn 96% 41m 58%)
               │   │   └ 7d window
               │   └ countdown — only while it matters
               └ 5h window

When the terminal gets narrow, the balance folds into a single exact total (¥19.67), then the quota drops away, then the prefix — your stats are never sacrificed.

line — a dedicated quota line under the stats, always in full detail:

~/dev/project (main)
↑1.2k ↓3.4k 38%/200k                            (zai-coding-cn) glm-5.3 • max
(Max) 5h ▓▓▓▓▓▓▓▓▓▓ 96% 41m · 58%

Every window always shows its label, meter, percentage, and reset, and the line opens with your plan tier ((Max)). The meters shrink automatically on narrow terminals.

The /quota panel

/quota shows all configured providers at once — the active one first:

zai-coding-cn  coding plan · Max · active
  5h  ▓▓▓▓░░░░░░   62% left   reset 13:47 (3h17m)
  7d  ▓▓▓▓▓░░░░░   55% left   reset Fri 15:00 (3d4h)

deepseek  pay as you go · ¥19.67 + ¥1.00 granted · $2.50

kimi-coding  coding plan · Allegretto · booster ¥100.00/¥200.00
  5h  ▓▓▓▓▓▓▓░░░   30% left   reset 17:10 (6h40m)
  7d  ▓░░░░░░░░░   89% left   reset Mon 00:00 (3d13h)

/quota refresh · /quota mode line|inline|off · /quota help

The footer shows how much you have used; the panel shows what is left, as a meter and a percentage, with each reset as a concrete local time (13:47 today, Fri 15:00 this week, Sep 01 later) followed by a relative countdown (3h17m, 3d4h). The panel never waits on the network: whatever is cached renders the moment you press Enter — old numbers carry a ~, missing ones read fetching… — and a second panel replaces it once the refreshed numbers land.

Supported providers

Provider What you see
ZAI / GLM coding plans — zai-coding-cn, zai-coding, GLM and bigmodel aliases 5h / 7d usage windows with resets, your plan tier (Lite / Pro / Max)
Kimi — kimi-coding 5h / 7d usage windows (+ 30d monthly pool on plans that report one), membership tier (Andante / Moderato / Allegretto) from the account endpoint, and the booster wallet balance (booster ¥5.00/¥20.00) once topped up
DeepSeek — deepseek prepaid balance per currency, topped-up + granted split
Moonshot / Kimi Open Platform — moonshotai, moonshotai-cn prepaid balance (available + voucher granted), CNY on the China platform and USD on the global one — a separate wallet from the Kimi coding plan
MiniMax — minimax, minimax-cn 5h / 7d usage windows of the token plan's coding lane, subscription title (e.g. Token Plan Plus)
Anthropic subscription — anthropic via /login (Claude Pro / Max) 5h / 7d usage windows with resets; needs the OAuth login — an API-key entry is pay-as-you-go and shows nothing
OpenAI Codex subscription — openai-codex (ChatGPT Plus / Pro) 5h / 7d usage windows with resets, plan type (plus / pro), and the remaining credits balance; needs the OAuth login — an API-key entry is pay-as-you-go and shows nothing
OpenRouter — openrouter prepaid credit balance (purchased credits minus usage)
OpenCode Go — opencode-go 5h rolling / 7d weekly (and monthly, when the plan reports one) usage windows; the pay-as-you-go opencode provider stays out — OpenCode does not expose its prepaid balance to API keys

Custom providers work without configuration too: detection falls back to the model's base URL host (bigmodel.cn, *.z.ai with a /coding path, *.kimi.com / *.kimi.ai with a /coding path, *.deepseek.com, *.moonshot.cn / *.moonshot.ai, *.minimax.io / *.minimaxi.com / *.minimax.cn, *.anthropic.com, *.chatgpt.com with a /codex path, *.openrouter.ai, *.opencode.ai with a /go/ path).

Good to know

  • Numbers refresh while you work — on model switches, on every agent run, after each assistant turn, and throughout pi-subagents child runs (the parent session itself stays quiet while children burn the same account: a foreground child holds the turn open inside its subagent tool call, a background child leaves the parent idle, so child-progress events drive the refresh) — but at most once every five minutes per provider; a session with nothing pending, mode off, and non-TUI sessions (RPC, JSON) send no requests at all.
  • A turn that finishes while the five-minute window is still closed is not lost: the skipped refresh is retried once, the moment the window (or the machine-wide one-minute request floor) opens — so a session that goes idle right after a big turn still picks that turn up. Nothing is polled: the wake-up exists only while activity is waiting to be covered.
  • Quota requests ride pi's own network path: pi installs a proxy-aware fetch at startup, so a proxy configured in pi settings (httpProxy) or via HTTPS_PROXY applies to them too — relevant where Anthropic and OpenAI endpoints need one. Without a proxy those providers simply report fetch failures on the /quota panel and the footer stays as pi built it.
  • Each provider endpoint is asked at most once per minute, machine-wide: every attempt (even a failed one) persists its timestamp in the shared cache before the request starts, so several pi sessions keep their distance too. A failed request earns a single immediate retry inside its cycle; when a fetch keeps failing, the /quota panel says so on the provider's own line — never as an interrupting notification.
  • A failed refresh never breaks anything: the last numbers stay, marked ~, until the next success — and /quota says why a provider failed (quota unavailable (HTTP 401)) or when it will retry (retry in 42s).
  • Several pi sessions on the same machine share one cache safely.
  • A lapsed Kimi OAuth token is skipped with a note — it refreshes the next time pi itself calls Kimi.
  • Credentials come only from pi's own store; no environment variables are read, and a key can never be sent to the wrong host.
  • While quota is displayed, the footer is a re-implementation of pi's and drops a few rare markers (the virtual-model routing arrow, xp, (auto)). Everything else renders the same.

License

MIT © 2026 Ning. See LICENSE.