Pi extension: remaining subscription/context usage in the status bar (Codex, Kimi, z.ai, Claude).
- TypeScript 95%
- JavaScript 5%
xai was falling through to context-only because subscription-left had no Grok fetcher. Pull the same grok.com gRPC-web GetGrokCreditsConfig meter Settings uses, plus legacy monthly build credits when present. |
||
|---|---|---|
| assets | ||
| extensions/subscription-left | ||
| tests | ||
| .gitignore | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
pi-subscription-left
A Pi extension that shows your remaining subscription / context usage in a dedicated row below the editor — colored by how much you have left, with the reset time and last-updated timestamp.
Supported providers
| Provider | Auth source (~/.pi/agent/auth.json) |
Usage endpoint |
|---|---|---|
| OpenAI Codex (ChatGPT sub) | openai-codex.access |
chatgpt.com/backend-api/codex/usage |
| Kimi Coding | kimi-coding.key |
api.kimi.com/coding/v1/usages |
| z.ai GLM Coding Plan | zai.key |
api.z.ai/api/monitor/usage/quota/limit |
| Anthropic / Claude (OAuth sub) | anthropic.access |
api.anthropic.com/api/oauth/usage |
| MiniMax | minimax.key |
api.minimax.io/v1/token_plan/remains |
| xAI / Grok (OAuth sub) | xai.access |
grok.com gRPC-web GetGrokCreditsConfig (+ monthly build credits) |
For providers that expose rate-limit headers on responses (Anthropic/OpenAI API keys), the tightest window is read straight from response headers. Providers without a subscription endpoint fall back to showing context window remaining.
Behavior
- Refreshes on
session_start,model_select, after each agent response, and on a 60-second poll while a long response is streaming. - API fetches are throttled to once every 5 minutes per provider (the Anthropic and Codex usage endpoints rate-limit aggressively).
- Last-known values are cached to disk (
~/.pi/agent/subscription-left-cache.json) so the display survives restarts and Cloudflare challenge waves. - Stale-context safe: the poll timer stops itself on
/reloadinstead of crashing Pi.
Install
This package is distributed via Forgejo (not npm). Add it to your Pi settings.json:
{
"packages": [
"git:forgejo.supportportal.org/hex/pi-subscription-left@main"
]
}
Then restart Pi or run /reload.
Commands
/usage-left— force a refresh (bypasses the 5-minute throttle) and show current usage.
License
MIT
