pi-quota-monitor
Real-time OpenAI Codex, Claude, Antigravity, and Grok quota status for Pi
Package details
Install pi-quota-monitor from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-quota-monitor- Package
pi-quota-monitor- Version
0.3.3- Published
- Oct 11, 2026
- Downloads
- 724/mo · 44/wk
- Author
- amazingumi
- License
- MIT
- Types
- extension
- Size
- 336.5 KB
- Dependencies
- 1 dependency · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
Pi Quota Monitor
中文
在 Pi 状态栏、/quota 和本机控制台查看 OpenAI Codex / Claude / Antigravity / Grok 额度与本地 Token 用量。
安装
需要 Node.js 22+。额度查询需要对应服务商的登录凭据;本机 Antigravity agy 模式还需要 agy 可执行文件。
pi install npm:pi-quota-monitor
安装后重启 Pi 或重新加载扩展。仓库开发可运行 pi --extension ./extensions/index.ts,或 pi install .。extensions/index.ts 是包的唯一 Pi 入口;实现与控制台静态文件放在 src/,测试放在 test/,发布检查脚本放在 scripts/。package.json 的 pi.extensions 显式指向入口,npm 包须包含 extensions/ 和 src/。
命令
| 命令 | 作用 |
|---|---|
/quota |
查看额度、重置时间及用量 |
/quota-refresh |
立即查询额度 |
/quota-interval 180 |
设置查询间隔(60–3600 秒) |
/quota-console |
打开本机控制台 |
/quota-account-save <名称> |
保存当前 Codex OAuth 账号 |
/quota-account-list |
列出已保存账号 |
/quota-account-use <名称> |
切换 Codex 账号,不更换会话 |
/quota-account-import <名称> <本机JSON路径> |
导入 Pi OAuth profile |
其他账号操作见 /quota-account-current、/quota-account-backup、/quota-account-backups、/quota-account-restore、/quota-account-delete、/quota-account-reset-cache 和 /quota-account-reset-usage。
显示与估算
- 状态栏 OAI / CLA / AGY 显示 5 小时 / 每周剩余额度;GRK 显示 SuperGrok 共享额度剩余(不是 5 小时窗口,也不是 xAI API 预付费余额);未知值为
-。控制台四个额度卡片底部可分别选择是否在 pi-web 状态栏显示对应片段(TUI 保持显示)。启用倒计时后,OAI 的↻对 Pro 使用每周窗口,其他套餐使用 5 小时窗口,GRK 使用共享额度重置时间。 - 额度圆环的百分比显示在右侧图例。四张卡片的圆环尺寸相同,并在卡片顶部对齐;窄屏下一起缩小。
- 控制台默认地址:
http://127.0.0.1:38457,仅监听本机。远程查看可使用 SSH 端口转发;不要将端口暴露到局域网。 - OAI 额度卡片显示账号剩余额度。Claude 卡片显示剩余额度,以及剩余金额的条件估算;它对应 Pi 当前 Anthropic OAuth 账号,与 Codex 账本视图无关。
- 账号额度下降包含其他客户端,不能直接归因于本 Pi。Claude / Antigravity 的条件估算只累计有本地 Token 的额度下降区间,并不证明全部下降由 Pi 造成;混合外部用量仍可能使结果偏差。无可计价记录、读数不足或账本不完整时显示
—。 - 本地 Token 金额按公开 API 标价估算,不是订阅实付、账户余额或服务商额度。价格表(核对于 2026-09-25)涵盖 DeepSeek、OpenAI、Gemini API、Claude API、xAI 的部分主流精确模型 ID;
openai-codex、antigravity与xai也仅套用相应公开 API 标价,并非 OAuth 订阅账单。完整模型与来源见src/tokens/pricing.ts。 - DeepSeek 每百万 Token 谷时 / 峰时价格(缓存命中输入、未命中输入、输出):
deepseek-flash为 $0.003 / $0.006、$0.15 / $0.30、$0.60 / $1.20;deepseek-v4-pro为 $0.022 / $0.044、$0.66 / $1.32、$1.98 / $3.96。峰时为周一至周五 UTC 01:00–04:00、06:00–10:00,中国法定假日除外;其余为谷时。按消息时间戳选档,已内置 2026 年官方假期;其他年份尚未内置假期,工作日峰时可能高估。跨档请求也只能近似。DeepSeek 缓存写入按未命中输入计价。 google-vertex / gemini-3.8-flash按 Google Cloud 官方定价 的全球区域 2026 年底前推广价估算(每百万 Input / Cached input / Output Token 分别为 $0.75 / $0.075 / $3.75);自 2027-01-01 起使用已公布的 $1.50 / $0.15 / $7.50;Gemini API 的 3.6–3.8 Flash 亦按各自已公布的促销/后续价格切换。非全球区域、批量、Grounding、音频和缓存存储等额外收费不在账本内;Claude 缓存写入按 5 分钟档估算,无法分辨 1 小时档。未知模型或无法确定费率的缓存写入不臆测价格。- Grok 文本模型按 xAI 全球按量价格 估算:
grok-4.7/grok-4.6为每百万 Input / Cached input / Output $2 / $0.50 / $6,提示超过 20 万 Token 时整单改为 $4 / $1 / $12;grok-4.5为 $2 / $0.30 / $6,长上下文为 $4 / $0.60 / $12;grok-4.3为 $1.25 / $0.20 / $2.50,长上下文为 $2.50 / $0.40 / $5。xAI 没有单独的缓存写入价,写入不另加价。美国区域端点的 10% 加价、工具调用和图像/视频不在账本内。账本里没有保存金额的xai记录,读取时按这张表计价,文件本身不改写。
账号与本地数据
- 使用 Pi 的
/login登录 Codex 后,可保存或切换账号。使用 Pi 的/login anthropic登录 Claude Pro/Max;本插件暂不管理 Claude 多账号,Anthropic API Key 不具备订阅额度。Claude OAuth 额度与账号资料接口并非 Anthropic 公开稳定 API,可能失效;资料无法确认时不保存跨账号读数或估算金额,未归属及其他账号的 Token 不参与校准。Grok 使用 Pi 的/login xai(设备码 OAuth),查询cli-chat-proxy.grok.com的共享额度;该接口并非公开稳定 API,可能失效。xAI API Key 和管理密钥不会被发送到该接口,也不代表 SuperGrok 剩余额度。身份无法确认时不保存跨账号读数。凭据由 Pi 刷新,本插件不另存 OAuth token。切换会验证凭据并在失败时回滚;同一 Pi 数据目录的其他进程也会读取共享的auth.json,请勿在其请求期间切换。 - 只有当前登录账号可查询 Codex 实时额度。Antigravity 用量在账号视图间共享。
- Token 账本位于
pi-quota-monitor/usage/:主 Agent 的message_end与可用的 pi-subagents cost RPC 合并;按 child session 的模型消息去重,无法读取会话的 CLI child 按 runId 记录为未计价用量,不猜测其模型。无法可靠确定 child 使用的 Codex 账号时,该 child 仅在「总体用量」中显示;缺失的运行元数据、子会话不可读或未加载 pi-subagents 时本地汇总仍是下界;不保存提示词或凭据。Reasoning 已计入 Output,不重复累计。 - 控制台「各模型明细」可按 Provider / Model 删除现有本地账本记录,删除前自动备份;账号视图只删除该账号的 Codex 记录,其他 Provider 在视图间共享。总量、趋势及金额随之变化。服务商实际额度不受影响;未来的新用量仍会写入,已删除的可识别 subagent 运行不会因重复同步而重现。恢复旧备份可能重新导入已删除的记录。
- 额度读数位于
quota-readings/,不在账号/账本备份中。 - 账号备份包含 OAuth token:请保存在私有目录,勿分享或提交。重置本地用量不会重置服务商额度。
- 配置位于
~/.pi/agent/pi-quota-monitor/config.json;PI_CODING_AGENT_DIR可更改 Pi 数据目录。
发布与画廊收录
npm ci
npm run check # 包含 npm 打包清单与静态资源检查
npm view pi-quota-monitor@latest version keywords pi --json
Pi 画廊以已公开发布的 npm 版本为准:pi-package 关键字使其有资格被检索,并不保证立即出现在搜索结果。可检查 包详情页 与名称筛选;若详情可访问、筛选却缺失,通常不是 extensions/ 布局问题。仓库改动不会更新已发布版本;测试通过后需提升版本号并由有 npm 发布权限的维护者发布,随后再检查索引。请勿为了收录而重复发布相同版本或提交本地凭据。
English
View OpenAI Codex / Claude / Antigravity / Grok quotas and local token usage in Pi's status bar, /quota, and a local dashboard.
Install
Requires Node.js 22+ and credentials for the providers you query. Local Antigravity agy mode also requires the agy executable.
pi install npm:pi-quota-monitor
Restart Pi or reload extensions. For repository development, use pi --extension ./extensions/index.ts or pi install .. extensions/index.ts is the sole Pi entry point; implementation and dashboard assets live in src/, tests in test/, and packaging checks in scripts/. The explicit pi.extensions manifest points to the entry, and both extensions/ and src/ must be packed.
Commands
| Command | Purpose |
|---|---|
/quota |
Show quotas, resets, and usage |
/quota-refresh |
Query quotas now |
/quota-interval 180 |
Set query interval (60–3600 seconds) |
/quota-console |
Open the local dashboard |
/quota-account-save <name> |
Save the current Codex OAuth account |
/quota-account-list |
List saved accounts |
/quota-account-use <name> |
Switch Codex account without replacing the session |
/quota-account-import <name> <local-JSON-path> |
Import a Pi OAuth profile |
Other account commands: /quota-account-current, /quota-account-backup, /quota-account-backups, /quota-account-restore, /quota-account-delete, /quota-account-reset-cache, and /quota-account-reset-usage.
Display and estimates
- OAI / CLA / AGY status-bar values are 5-hour / weekly remaining quota. GRK is the SuperGrok shared credit remaining, not a 5-hour window and not an xAI API prepaid balance. Unknown values show
-. Each dashboard card can hide its own pi-web status segment; TUI keeps all of them. When countdowns are enabled, OAI's↻uses the weekly window for Pro and the 5-hour window for other plans; GRK uses the shared-credit reset. - The quota-ring percentage is shown in the legend. All four cards use the same ring size, aligned to the top of the card, and shrink together on narrow screens.
- The dashboard defaults to
http://127.0.0.1:38457and listens on loopback only. Use SSH forwarding for remote access; do not expose it to the LAN. - Claude quota and conditional amount estimates use Pi's current Anthropic Pro/Max OAuth login (
/login anthropic) and only account-attributed Pi usage. Anthropic OAuth usage/profile endpoints are undocumented and can change; when identity is unavailable, amounts are withheld. API-key usage is not a subscription quota. Grok quota uses Pi's xAI device-code OAuth (/login xai) against the undocumented Grok CLI billing host. Inference and management keys are not sent there and do not represent SuperGrok remaining credit. Readings are not stored across accounts when identity cannot be confirmed. The dashboard has independent pi-web OAI/CLA/AGY/GRK status-bar switches; TUI keeps the provider segments. - OAI cards show account remaining quota. Claude cards show remaining quota and a conditional remaining-dollar estimate from adjacent readings.
- Account quota drops include other clients and cannot be directly attributed to this Pi. Claude / Antigravity conditional estimates sum only intervals that also have local tokens. Concurrent external usage can still skew them. Unpriced or incomplete samples show
—. - Local Token amounts use public API list prices, not subscription charges, balances, or provider limits. The catalogue (checked 2026-09-25) covers exact mainstream model IDs from DeepSeek, OpenAI, Gemini API, Claude API, and xAI.
openai-codex,antigravity, andxaiuse corresponding API list prices, not OAuth subscription bills. Seesrc/tokens/pricing.tsfor models and sources. - DeepSeek off-peak / peak prices per million cache-hit input, cache-miss input, output tokens:
deepseek-flash$0.003 / $0.006, $0.15 / $0.30, $0.60 / $1.20;deepseek-v4-pro$0.022 / $0.044, $0.66 / $1.32, $1.98 / $3.96. Peak: Monday–Friday, 01:00–04:00 and 06:00–10:00 UTC, excluding Chinese public holidays; all other times are off-peak. Pricing uses message timestamps and the official 2026 holiday calendar; holidays in other years are not yet encoded, so weekday peak estimates may be high. Requests spanning a tier boundary are approximate. DeepSeek cache writes use cache-miss input rates. google-vertex / gemini-3.8-flashuses Google Cloud's promotional global rates through 2026 ($0.75 / $0.075 / $3.75 per million input / cached-input / output tokens), changing to published $1.50 / $0.15 / $7.50 on 2027-01-01. Gemini API 3.6–3.8 Flash models similarly switch at their published dates. Non-global regions, batch, grounding, audio and cache storage are not inferred. Claude cache writes assume the 5-minute tier; the ledger cannot distinguish 1-hour writes. Unknown models or unsupported cache writes remain unpriced.- Grok text models use xAI's global on-demand prices. Per million input / cached-input / output tokens:
grok-4.7andgrok-4.6are $2 / $0.50 / $6, or $4 / $1 / $12 once the prompt exceeds 200k tokens;grok-4.5is $2 / $0.30 / $6, or $4 / $0.60 / $12;grok-4.3is $1.25 / $0.20 / $2.50, or $2.50 / $0.40 / $5. xAI has no separate cache-write charge. The US endpoint premium, tool calls, and image/video usage are not inferred.xairows without a stored amount are priced from this catalogue when read; the ledger files stay unchanged.
Accounts and local data
- Log in to Codex with Pi's
/loginbefore saving or switching accounts. Claude uses/login anthropic; this plugin does not manage multiple Claude accounts, and an Anthropic API key is not a subscription quota. Those OAuth usage and profile endpoints are undocumented and can change. Grok uses/login xaiand queries shared SuperGrok credit atcli-chat-proxy.grok.com; that host is also undocumented. Inference and management keys are not sent there. Pi refreshes credentials; this plugin does not store a second copy. Switching verifies the credential and rolls back on failure; avoid switching while another Pi process sharingauth.jsonis making requests. - Live Codex quota is available only for the active account. Antigravity usage is shared across account views.
- Token ledgers in
pi-quota-monitor/usage/combine main-agentmessage_endwith the optional pi-subagents cost RPC. Child session turns are deduplicated against ambient events; CLI children without readable sessions are recorded by run ID as unpriced usage, without guessing a model. Children without a verifiable Codex account appear only under overall usage, not in an account-filtered view. Missing run metadata, unreadable sessions, or an absent pi-subagents extension make local totals a lower bound. No prompts or credentials are stored. Reasoning is included in Output, not counted twice. - The dashboard's model breakdown can delete existing local ledger records by Provider / Model after an automatic backup. An account view removes only that account's Codex records; other providers are shared. Totals, trends, and estimates update without affecting provider quotas. Future usage is still collected, while identifiable deleted subagent runs are not re-imported on reconciliation. Restoring an older backup may re-import deleted records.
- Quota readings live in
quota-readings/and are not included in account or ledger backups. - Account backups contain OAuth tokens: keep them private. Resetting the local usage ledger does not reset provider quotas.
- Configuration lives in
~/.pi/agent/pi-quota-monitor/config.json;PI_CODING_AGENT_DIRchanges the Pi data directory.
Publishing and gallery discovery
npm ci
npm run check # includes a packed-file and dashboard-asset check
npm view pi-quota-monitor@latest version keywords pi --json
The Pi gallery uses the published public npm version. The pi-package keyword makes it eligible for discovery but does not guarantee an immediate search result. Compare the direct package page with the name filter; a working detail page with a missing search result is not fixed by changing the local directory layout. Repository changes do not update npm: after checks pass, a maintainer with npm publishing access must bump the version and publish, then recheck indexing. Do not republish the same version or commit local credentials.