@narumitw/pi-usage 0.54.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,29 +1,35 @@
1
- # 📊 pi-usage — Check Provider Usage and Codex Fast Mode
1
+ # 📊 pi-usage — Check Provider Usage, API Balance, and Codex Fast Mode
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@narumitw/pi-usage)](https://www.npmjs.com/package/@narumitw/pi-usage) [![Pi extension](https://img.shields.io/badge/Pi-extension-blue)](https://pi.dev) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)
4
4
 
5
- Check the limits and usage for the provider account Pi is actually using, toggle Fast mode for supported OpenAI Codex models, and report xAI OAuth subscription usage.
5
+ Inspect usage and DeepSeek API balance for Pi's active provider account, query other configured providers, and toggle Fast mode for supported OpenAI Codex models.
6
6
 
7
- The extension reports each provider's native semantics instead of presenting unlike quotas as equivalent.
8
- xAI reporting defaults On and follows the current official Grok Build implementation.
7
+ The extension keeps each provider's native quota, allowance, and spending semantics instead of treating unlike values as equivalent.
8
+ xAI OAuth subscription reporting follows the reviewed Grok Build contract and runs only after an explicit `/usage` action.
9
9
 
10
10
  ## ✨ Features
11
11
 
12
- - Shows current-account usage and next actions through `/usage`.
13
- - Supports OpenAI Codex subscription windows, credits, resets, and model-specific buckets.
14
- - Supports Kimi For Coding plan windows, resets, and separately labeled booster-wallet currency.
15
- - Supports GitHub Copilot allowances and OpenRouter per-key limits and spend windows.
16
- - Supports xAI OAuth subscription allowance and credit reporting.
17
- - Toggles persistent Codex Fast routing through `/fast` or the contextual usage menu.
12
+ - Shows active-account usage and next actions through `/usage`.
13
+ - Reports OpenAI Codex subscription windows, credits, resets, and model-specific buckets.
14
+ - Reports Kimi For Coding plan windows, resets, and separately labeled booster-wallet currency.
15
+ - Reports GitHub Copilot allowances and OpenRouter per-key limits and spending windows.
16
+ - Reports exact DeepSeek API balances with separate CNY and USD values.
17
+ - Reports OpenCode Go plan windows and Z.AI Coding Plan quotas.
18
+ - Reports Fireworks rated API spend for the last 30 days with per-series subtotals.
19
+ - Reports xAI OAuth subscription allowances and credits.
20
+ - Toggles persistent Codex Fast routing through `/fast` or the usage menu.
18
21
  - Redeems eligible Codex resets only after fresh account matching and explicit confirmation.
19
- - Refreshes one or all configured providers with bounded concurrency and partial-result preservation.
20
- - Keeps statusline and cache data scoped to the current provider and runtime account.
22
+ - Refreshes one or all configured providers with bounded concurrency while preserving partial results.
23
+ - Scopes statusline and cache data to the active provider and runtime account.
21
24
  - Resolves credentials through Pi or the process-local OAuth credential-source protocol and validates the effective provider endpoint before sending them.
22
25
 
23
26
  ## 📦 Install
24
27
 
25
- Requires Pi 0.81.0 or newer so the extension can validate the effective base URL attached to resolved provider auth before sending credentials to an official usage endpoint.
26
- The v1 credential-source interoperability path is characterized against Pi 0.84.3; other runtimes retain standalone fallback but do not receive the protocol timing guarantee.
28
+ Requires Pi 0.81.0 or newer to validate the effective base URL for resolved provider auth before sending credentials to an official usage endpoint.
29
+ The v1 credential-source path is characterized against Pi 0.84.3; other runtimes keep the standalone fallback without its protocol timing guarantee.
30
+
31
+ Like every Pi extension, this package runs with Pi's process permissions.
32
+ Review [Security and privacy](#-security-and-privacy) before installation.
27
33
 
28
34
  ```bash
29
35
  pi install npm:@narumitw/pi-usage
@@ -46,18 +52,18 @@ The package declares `dist/index.ts`, so an unbuilt local checkout must run the
46
52
 
47
53
  ## 🚀 Quick start
48
54
 
49
- Run `/usage` in TUI or RPC mode to inspect the current provider, refresh usage, or choose another configured provider.
50
- Use `/fast` separately to toggle Fast mode for a supported current Codex model.
55
+ Run `/usage` in TUI or RPC mode to inspect the active provider, refresh its usage, or choose another configured provider.
56
+ Run `/fast` to toggle Fast mode for a supported active Codex model.
51
57
 
52
58
  ## 💬 Commands
53
59
 
54
- Run:
60
+ Open the manager with:
55
61
 
56
62
  ```text
57
63
  /usage
58
64
  ```
59
65
 
60
- In TUI or RPC mode, the standard menu first queries the current model provider and presents its state with these actions:
66
+ In TUI or RPC mode, the menu first queries the active model provider and then offers these actions:
61
67
 
62
68
  ```text
63
69
  Refresh current usage
@@ -69,13 +75,14 @@ View all configured providers…
69
75
  Close
70
76
  ```
71
77
 
72
- There are intentionally no `/usage --refresh`, `/usage <provider>`, or `/usage --all` argument paths.
73
- Cross-provider traffic requires an explicit interactive choice.
74
- Escape returns from provider selection and closes the root menu.
75
- Print and JSON modes reject `/usage` observably because they cannot host the interactive flow.
76
- The cancellable live-query progress view remains extension-owned because it streams provider work and supports in-flight abort rather than presenting a standard menu screen.
78
+ `/usage` accepts no arguments, including `--refresh`, a provider ID, or `--all`.
79
+ Cross-provider requests require an explicit interactive choice.
80
+ Escape returns from provider selection or closes the root menu.
81
+ Print and JSON modes reject `/usage` because they cannot host the interactive flow.
82
+ The extension owns the cancellable live-query progress view because it streams provider work and supports in-flight abort.
77
83
 
78
- For the current OpenAI Codex provider, **Redeem usage limit reset…** checks fresh earned-reset details, lets you select a reset when details are available, and shows the exact reset before asking for confirmation.
84
+ For the current OpenAI Codex provider, **Redeem usage limit reset…** first checks fresh earned-reset details.
85
+ When details are available, you select a reset and review its exact effect before confirmation.
79
86
  **No, go back** is the safe default and cancellation before confirmation sends no mutation.
80
87
  After confirmation, the reset operation cannot be cancelled from its progress view; session replacement or shutdown still aborts owned work.
81
88
  A transport failure offers **Try again** with the same redemption request ID so the backend can treat an uncertain retry idempotently.
@@ -83,48 +90,59 @@ Successful, already-completed, not-needed, and no-credit outcomes are reported s
83
90
 
84
91
  ## ⚙️ Settings
85
92
 
86
- Choose **Settings** in `/usage` to edit Codex Fast mode and xAI usage through Pi's settings-list interaction in TUI mode.
93
+ Choose **Settings** in `/usage` to edit Codex Fast mode, the Codex reset countdown, and the Fireworks account selector through Pi's settings-list interaction in TUI mode.
87
94
  RPC mode reports the active manual settings path instead of opening terminal UI.
88
95
 
89
- Both preferences live in Pi's user agent directory as `pi-usage.json`, normally `~/.pi/agent/pi-usage.json`.
90
- The file reloads at every session start and is not created until the first successful save.
91
- Changes save immediately in input order inside one Pi process.
92
- Unknown JSON fields are preserved, writes use a private temporary file plus rename, and malformed or invalid files remain untouched.
96
+ These preferences live in `pi-usage.json` under Pi's user agent directory, normally `~/.pi/agent/pi-usage.json`.
97
+ The extension reloads this file at every session start and does not create it until the first successful save.
98
+ Within one Pi process, changes save immediately in invocation order.
99
+ Saves preserve unknown JSON fields and publish through a private temporary file plus rename.
100
+ Malformed or invalid files remain untouched.
93
101
  A failed save restores the prior displayed and effective value, while shutdown waits for queued writes.
94
102
  Separate Pi processes are not mutually locked.
95
103
 
104
+ ### Fireworks account
105
+
106
+ A Fireworks key that can see one account needs no setting.
107
+ For a key that can see several accounts, choose **Fireworks account** in the TUI Settings screen, or set the exact visible account slug in `pi-usage.json` and run `/reload`:
108
+
109
+ ```json
110
+ {
111
+ "fireworksAccountId": "acme"
112
+ }
113
+ ```
114
+
115
+ The `fireworksAccountId` setting is validated as a URL-safe account slug and then checked against the official account listing before billing data is requested.
116
+ Submit a blank value from the TUI input, or remove the JSON field and run `/reload`, to restore single-account auto-selection.
117
+
96
118
  ### Codex Fast mode
97
119
 
98
- Run bare `/fast` to toggle Fast for the active supported Codex model, or use **Turn Fast mode on/off** in `/usage`.
120
+ Run `/fast` without arguments to toggle Fast for the active supported Codex model, or use **Turn Fast mode on/off** in `/usage`.
99
121
 
100
122
  Fast is about 1.5× faster and uses more of your plan allowance.
101
123
  The `codexFastMode` preference defaults to Off.
102
124
 
103
125
  Fast currently applies only to official `openai-codex-responses` requests for `gpt-5.4`, `gpt-5.5`, `gpt-5.6-sol`, `gpt-5.6-terra`, and `gpt-5.6-luna` at `https://chatgpt.com`.
104
126
  It sends `service_tier: "priority"` while enabled and explicit `service_tier: "default"` otherwise.
105
- The statusline adds `fast` only while the preference is effective, for example `codex fast 59% 5h`.
127
+ The statusline adds `fast` only while the preference is effective, for example `codex fast 59% ↻ 2h30m` with the default reset countdown.
106
128
  Unsupported models and custom or proxy origins are left unchanged.
107
129
 
108
130
  `/fast` supports TUI and RPC mode, accepts no arguments, and rejects print or JSON mode before mutation.
109
131
  A toggle affects provider requests whose payload hook starts after the save; a request already sent is unchanged.
110
132
  Repair or remove an invalid file, then run `/reload` before trying the toggle again.
111
133
 
112
- ### xAI usage
134
+ ### Codex statusline reset countdown
135
+
136
+ The `codexStatusResetCountdown` preference defaults to `true`. It replaces the window labels with the time remaining until each returned limit resets.
113
137
 
114
- The `xaiUsage` preference defaults to `true` when the settings file or field is absent.
115
- Turn it Off in the TUI Settings screen or edit the active user file manually, then run `/reload`:
138
+ Turn **Codex reset countdown** Off in the TUI Settings screen, or set it to `false` in `pi-usage.json` and run `/reload`, to restore the legacy `5h` and `wk` labels:
116
139
 
117
140
  ```json
118
141
  {
119
- "xaiUsage": false
142
+ "codexStatusResetCountdown": false
120
143
  }
121
144
  ```
122
145
 
123
- While enabled, xAI is available only through explicit `/usage` current, configured-provider, or all-provider actions.
124
- It does not schedule xAI requests or publish xAI data to the statusline.
125
- The disabled, malformed, and invalid-settings states perform no xAI usage auth resolution or consumer requests.
126
- Turning it Off clears xAI cache state and prevents stale in-flight results from being published.
127
-
128
146
  ## 📋 Provider semantics
129
147
 
130
148
  ### OpenAI Codex
@@ -134,12 +152,13 @@ Turning it Off clears xAI cache state and prevents stale in-flight results from
134
152
  - Source: the Codex usage and earned-reset endpoints using Pi's resolved runtime authorization
135
153
  - Displayed data: returned duration-based windows, resets, credits, earned usage-limit resets, and additional model buckets
136
154
  - Reset mutation: `POST /wham/rate-limit-reset-credits/consume` with a unique redemption request ID and, when available, the selected opaque credit ID
137
- - Statusline examples: `codex 59% 5h 61% wk`, `codex fast 59% 5h`, or `codex spark 100% 5h`
155
+ - Statusline examples: `codex 59% 2h30m 61% ↻ 2d15m`, `codex fast 59% ↻ 2h30m`, or `codex spark 100% ↻ 2h30m`. Set `codexStatusResetCountdown` to `false` for the legacy `5h` and `wk` labels.
138
156
 
139
157
  The statusline selects a returned bucket that matches the current Codex model when one is available.
140
158
  Unlike `pi-codex-usage`, this successor intentionally has no Codex CLI fallback because the CLI may be logged into a different account than Pi's active runtime account.
141
159
 
142
- Reset redemption is available only when Codex is the current provider and Pi's freshly resolved access token exactly matches an OAuth credential from Pi's stored login or a compatible credential source.
160
+ Reset redemption is available only when Codex is the current provider.
161
+ Pi's freshly resolved access token must exactly match an OAuth credential from Pi's stored login or a compatible credential source.
143
162
  `pi-usage` forwards only the bearer authorization and matching `chatgpt-account-id` to the official ChatGPT origin.
144
163
  API-key credentials, configured-but-not-current Codex accounts, account changes during the flow, and custom/proxy origins fail before mutation.
145
164
  Backend-provided titles and descriptions are sanitized for terminal display.
@@ -150,7 +169,8 @@ Opaque credit and account IDs are never shown or persisted by the extension.
150
169
  - Provider ID: `kimi-coding`
151
170
  - Semantics: Kimi Coding Plan request windows plus a separate Extra Usage booster wallet
152
171
  - Source: `GET https://api.kimi.com/coding/v1/usages` using Pi's freshly resolved runtime Bearer credential
153
- - Displayed data: the weekly plan summary, returned sub-windows such as five-hour or daily limits, used and remaining request percentages, valid reset times, wallet balance, monthly spend, and monthly charge limit
172
+ - Displayed plan data: the weekly summary, returned sub-windows, used and remaining request percentages, and valid reset times
173
+ - Displayed wallet data: balance, monthly spend, and monthly charge limit
154
174
  - Statusline examples: `kimi 99% 5h 96% wk` or `kimi 95% 1d`
155
175
 
156
176
  Both Pi API-key credentials and Pi OAuth credentials are accepted because current Pi resolves each form as Bearer authorization for the same official Kimi inference origin.
@@ -171,7 +191,8 @@ The pinned Kimi managed-usage source at `cd7c97b377a77f7ae1b9d541cafe314e986ec07
171
191
  ### GitHub Copilot
172
192
 
173
193
  - Provider ID: `github-copilot`
174
- - Semantics: the allowance reported for the active Copilot plan—AI credits for current usage-based billing, premium requests for legacy annual billing, or chat requests for Copilot Free's limited response shape
194
+ - Semantics: the allowance reported for the active Copilot plan
195
+ - Allowance labels: AI credits for usage-based billing, premium requests for legacy annual billing, or chat requests for Copilot Free
175
196
  - Source: GitHub's undocumented `GET /copilot_internal/user` endpoint
176
197
  - Displayed data: entitlement, remaining allowance, percentage, reset time, plan, and any additional usage beyond the included allowance
177
198
  - Statusline examples: `copilot credits 1200/1500 80%`, `copilot 245/300 82%`, or `copilot chat 40/50 80%`
@@ -181,7 +202,8 @@ GitHub's quota endpoint requires the original GitHub OAuth token rather than the
181
202
  It uses a candidate only when its short-lived access token exactly matches the freshly resolved active runtime credential.
182
203
  Duplicate equivalent candidates are harmless, while conflicting matches fail closed without choosing by extension load order.
183
204
  API-key credentials, account mismatches, GitHub Enterprise accounts, and proxy/custom provider origins fail closed.
184
- The detailed report follows the endpoint's `token_based_billing` marker so AI credits are not mislabeled as legacy premium requests, and it reports overage without treating a negative included balance as a malformed response.
205
+ The detailed report follows the endpoint's `token_based_billing` marker so AI credits are not mislabeled as legacy premium requests.
206
+ It reports overage without treating a negative included balance as malformed.
185
207
 
186
208
  ### OpenRouter
187
209
 
@@ -194,15 +216,52 @@ The detailed report follows the endpoint's `token_based_billing` marker so AI cr
194
216
  The extension does not call OpenRouter's account-level `/credits` endpoint because that operation requires a separate management key.
195
217
  OpenRouter documents the distinction between credit and rate limits in its [API limits guide](https://openrouter.ai/docs/api_reference/limits).
196
218
 
219
+ ### DeepSeek API balance
220
+
221
+ - Provider ID: `deepseek`
222
+ - Semantics: current API account balance, not historical usage or quota
223
+ - Source: documented `GET https://api.deepseek.com/user/balance` using Pi's freshly resolved runtime API key
224
+ - Displayed data: whether API calls are available plus separate total, granted, and topped-up balances for each returned CNY or USD currency
225
+ - Statusline examples: `deepseek CNY 110.00` or `deepseek CNY 110.00 · USD 20.00`
226
+
227
+ The extension queries the fixed balance endpoint only when the selected model origin is `https://api.deepseek.com` and any resolved-auth origin override, when present, has the same official origin.
228
+ Pi's built-in DeepSeek API-key resolver does not attach a redundant auth origin, so the validated model origin remains authoritative when no override exists.
229
+ Custom and proxy origins fail before network access, redirects are rejected, and only the resolved Bearer credential is forwarded from Pi's runtime auth.
230
+ Monetary decimal strings remain exact from the response through display.
231
+ CNY and USD stay separate and are never converted or added together.
232
+ The balance endpoint does not provide historical spend, request windows, reset times, or aggregate token usage, so `pi-usage` does not claim those DeepSeek capabilities.
233
+
234
+ The contract was verified on 2026-08-28 against [DeepSeek's Get User Balance documentation](https://api-docs.deepseek.com/api/get-user-balance) and Pi's [`deepseek.ts`](https://github.com/earendil-works/pi/blob/c49906ec77788625aacbdc53ebca6fbe65bd20f5/packages/ai/src/providers/deepseek.ts) at `c49906ec77788625aacbdc53ebca6fbe65bd20f5`.
235
+ DeepSeek Harness `cd5ef8148158c3a752a658978873241fdf8e2bbc` reports only per-request model token usage and does not provide account balance data.
236
+
237
+ ### Fireworks API spend
238
+
239
+ - Provider ID: `fireworks`
240
+ - Semantics: rated 30-day account spend, not credit balance or spend-cap quota
241
+ - Source: documented `GET https://api.fireworks.ai/v1/accounts` account discovery and `GET https://api.fireworks.ai/v1/accounts/{account_id}/billing/summary` rated costs using Pi's resolved inference API key
242
+ - Displayed data: exact rated spend per currency with serverless, dedicated-deployment, and training subtotals for the trailing 30 days
243
+ - Statusline example: `fireworks USD 12.345678901`
244
+
245
+ The extension queries the fixed endpoints only when the selected model origin is `https://api.fireworks.ai` and any resolved-auth origin override, when present, has the same official origin.
246
+ The account slug is discovered through the documented account listing; a key that can see several accounts must set `fireworksAccountId` in `pi-usage.json` to one of the listed account slugs, and the slug must remain visible to the key.
247
+ Monetary `units` and `nanos` values are summed exactly with integer arithmetic and stay exact through display.
248
+ Fireworks does not expose credit balance, spend caps, per-window quota, or reset times through its API, so `pi-usage` does not claim those Fireworks capabilities; the web console remains the authoritative balance source.
249
+ Rated line items may differ from the final invoice once credits or adjustments are applied.
250
+
251
+ The contract was verified on 2026-07-31 against Fireworks' [Usage & Cost Breakdown](https://docs.fireworks.ai/accounts/exporting-usage-and-costs), [Get billing summary](https://docs.fireworks.ai/api-reference/get-billing-summary), and [List Accounts](https://docs.fireworks.ai/api-reference/list-accounts) API references.
252
+
197
253
  ### OpenCode Go (Zen)
198
254
 
199
255
  - Provider ID: `opencode-go`
200
256
  - Semantics: OpenCode Zen plan usage windows—rolling, weekly, and monthly
201
257
  - Source: `GET https://opencode.ai/zen/go/v1/usage` using Pi's resolved inference API key
202
- - Displayed data: used percentage and reset time for each window; `rate-limited` windows remain visible at their reported usage, while unknown statuses are reported as unavailable notes
258
+ - Displayed data: used percentage and reset time for each window
259
+ - Status handling: `rate-limited` windows remain visible, while unknown statuses become unavailable notes
203
260
  - Statusline examples: `zen 0% r 4% w 2% m`
204
261
 
205
- The fixed endpoint is queried only when the candidate OpenCode Go model and the resolved provider-auth base URL, when present, use the official `https://opencode.ai` origin; other origins fail before sending the credential.
262
+ The fixed endpoint is queried only when the OpenCode Go model uses the official `https://opencode.ai` origin.
263
+ When resolved provider auth includes a base URL, that URL must use the same origin.
264
+ Other origins fail before the credential is sent.
206
265
 
207
266
  ### xAI consumer subscriptions
208
267
 
@@ -210,12 +269,13 @@ The fixed endpoint is queried only when the candidate OpenCode Go model and the
210
269
  - Semantics: consumer subscription allowance and credits, not xAI API-team billing
211
270
  - Identity route: `GET https://cli-chat-proxy.grok.com/v1/user?include=subscription`
212
271
  - Billing route: `GET https://cli-chat-proxy.grok.com/v1/billing?format=credits`
213
- - Displayed data: included allowance percentage or legacy monetary limit, weekly or monthly period and reset, on-demand spend and cap, prepaid balance, and a sanitized optional plan tier
214
- - Statusline: not published; xAI is queried only through an explicit `/usage` action while xAI usage is enabled
272
+ - Displayed data: included allowance or legacy monetary limit, period and reset, on-demand spend and cap, prepaid balance, and a sanitized optional plan tier
273
+ - Statusline: not published; xAI is queried only through an explicit `/usage` action
215
274
 
216
275
  The adapter accepts only the official Pi inference origin `https://api.x.ai` and a freshly resolved bearer that exactly matches one complete Pi OAuth credential.
217
276
  Pi's reviewed OAuth scope is `openid profile email offline_access grok-cli:access api:access`.
218
- `XAI_API_KEY`, duplicate or conflicting OAuth candidates, account mismatches, incomplete OAuth records, custom origins, and proxy-resolved origins fail before consumer-proxy access.
277
+ The adapter rejects `XAI_API_KEY`, duplicate or conflicting OAuth candidates, account mismatches, and incomplete OAuth records.
278
+ It also rejects custom or proxy-resolved origins before consumer-proxy access.
219
279
  API-key users can review API-team spend through [console.x.ai](https://console.x.ai/) instead.
220
280
  The public Management API requires a separate management key and team ID and is intentionally outside this runtime-credential integration.
221
281
 
@@ -232,30 +292,35 @@ The implementation contract was verified against these first-party revisions:
232
292
  - Grok Build [`UserInfo`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-shell/src/auth/model.rs), [`subscription_check.rs`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-shell/src/agent/subscription_check.rs), [`billing.rs`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-shell/src/extensions/billing.rs), [`auth/config.rs`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-shell/src/auth/config.rs), [`xai-grok-http`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-http/src/lib.rs), and [`xai-grok-version`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-version/Cargo.toml) at `9684fa3`.
233
293
  - [xAI Management API team billing boundary at `723dd2a`](https://github.com/xai-org/xai-proto/blob/723dd2aa22d17be35617463837dc47cda008d90e/proto/xai/management_api/v1/billing.proto).
234
294
 
235
- The approved 2026-08-27 disposable-or-maintainer-account protocol smoke used only Pi's OAuth bearer, read no Grok-local files, and received HTTP 200 without redirects from both routes.
295
+ The approved 2026-08-27 protocol smoke used only Pi's OAuth bearer and read no Grok-local files.
296
+ A disposable or maintainer account received HTTP 200 without redirects from both routes.
236
297
  The implementation also sends the non-secret client headers present on both routes in current Grok Build source, with `x-userid` added only for billing.
237
- The sanitized identity shape contained a string `userId` and nullable `subscriptionTier`; the billing shape contained an object `config` with period and distinct on-demand and prepaid wrappers, without retaining field values.
298
+ The sanitized identity shape contained a string `userId` and nullable `subscriptionTier`.
299
+ The billing shape contained a `config` object with period and distinct on-demand and prepaid wrappers, without retaining field values.
238
300
 
239
- Disable `xaiUsage` to stop all xAI consumer usage traffic while preserving other provider behavior.
301
+ xAI identity and billing requests occur only after an explicit current, configured-provider, or all-provider `/usage` action.
240
302
 
241
303
  ### Z.AI (GLM Coding Plan)
242
304
 
243
305
  - Provider ID: `zai` and `zai-coding-cn`
244
306
  - Semantics: GLM Coding Plan quota windows—the rolling 5-hour and weekly plan-usage windows plus the monthly MCP allowance
245
- - Source: Z.AI's undocumented `GET {origin}/api/monitor/usage/quota/limit` endpoint, also used by its official coding plugin, with the origin derived from the model base URL (`https://api.z.ai` or `https://open.bigmodel.cn`)
246
- - Displayed data: explicit used and remaining values, reset times, provider-reported per-tool MCP details, and the reported plan level. Windows that report only a percentage remain percent-based
247
- - Statusline: not published; Z.AI is queried only through `/usage` actions
307
+ - Source: the undocumented `GET {origin}/api/monitor/usage/quota/limit` endpoint also used by Z.AI's official coding plugin
308
+ - Allowed origins: the model base URL must resolve to `https://api.z.ai` or `https://open.bigmodel.cn`
309
+ - Displayed data: explicit used and remaining values, reset times, provider-reported per-tool MCP details, and the reported plan level
310
+ - Percentage-only windows remain percent-based
311
+ - Statusline: publishes remaining plan percentages such as `zai 87% 5h 76% wk`; monthly MCP details remain available through `/usage`
248
312
 
249
313
  The monitor endpoint is not a published API contract and may return legacy `TOKENS_LIMIT` or newer `CREDIT_LIMIT` window names.
250
314
  The extension classifies both forms by the provider's window unit and does not label provider-reported counts as tokens or calls.
251
- The quota monitor expects the raw API key without a `Bearer` prefix, so the extension strips a `Bearer` prefix from the resolved authorization before sending it to the monitor endpoint.
315
+ The quota monitor expects a raw API key without a `Bearer` prefix.
316
+ The extension removes that prefix from resolved authorization before sending it to the monitor endpoint.
252
317
  Fingerprinting and redaction keep using the original resolved credential.
253
318
  Only the official `api.z.ai` and `open.bigmodel.cn` origins are queried; other origins fail before sending the credential.
254
319
 
255
320
  ## 🧭 Current and configured accounts
256
321
 
257
- `Current` means the provider and credential used by Pi's selected model.
258
- `Configured` means Pi reports runtime auth for another supported provider; it does not mean that provider is active.
322
+ `Current` identifies the provider and credential used by Pi's selected model.
323
+ `Configured` identifies runtime auth for another supported provider, not an active provider.
259
324
 
260
325
  The extension does not enumerate multiple accounts inside one provider and does not switch accounts.
261
326
  Account selection remains owned by Pi or an account-management extension.
@@ -268,9 +333,12 @@ After the active runtime credential changes, the next command, turn, or schedule
268
333
 
269
334
  The `usage` status item is active only for selected providers that publish statusline usage.
270
335
  It refreshes every five minutes while the session remains on such a provider and is cleared when the model changes to an unsupported or menu-only provider.
336
+ DeepSeek publishes each returned currency as a separate exact balance segment and reports when the API is unavailable.
337
+ Fireworks publishes exact per-currency rated spend totals and reports when no rated usage exists.
271
338
  xAI is always menu-only and never starts a scheduled status refresh.
339
+ Z.AI statusline usage refreshes every five minutes while the selected model remains on Z.AI.
272
340
 
273
- Manual another-provider and all-provider queries never publish to the statusline.
341
+ Queries for another provider or all providers never publish their results to the statusline.
274
342
  `@narumitw/pi-statusline` supplies the default `📊` icon; `pi-usage` publishes text-only values.
275
343
 
276
344
  ## 🔄 Migrating from pi-codex-usage
@@ -296,10 +364,13 @@ Behavior changes:
296
364
 
297
365
  Credential candidates are collected synchronously in memory and are not cached, persisted, logged, formatted, or appended to the Pi session.
298
366
  The protocol carries no account name or extension identity.
299
- Only the selected provider's exact runtime match is used, and secrets are sent only to the validated official provider origin.
367
+ Only the selected provider's exact runtime match is used, and secrets are sent only to its validated official origin.
368
+ DeepSeek balance requests require Bearer authentication, send only that resolved credential from Pi's runtime auth to `https://api.deepseek.com/user/balance`, and refuse redirects.
369
+ Fireworks spend requests send only that resolved credential to the official `https://api.fireworks.ai` account-listing and billing-summary endpoints and refuse redirects.
300
370
  Pi extensions run with the user's process privileges, so the shared event bus is not a security boundary between installed extensions.
301
- Install only trusted extensions because any installed extension may already read user files and process memory.
302
- Protocol v1 interoperability is characterized for the repository's supported Pi runtime; an absent or incompatible peer preserves standalone fallback and fail-closed mismatch behavior.
371
+ Install only trusted extensions because they can read user files and process memory.
372
+ Protocol v1 interoperability is characterized for the repository's supported Pi runtime.
373
+ An absent or incompatible peer preserves standalone fallback and fail-closed mismatch behavior.
303
374
 
304
375
  ## 🚧 Limitations
305
376
 
@@ -309,6 +380,8 @@ Protocol v1 interoperability is characterized for the repository's supported Pi
309
380
  - xAI usage supports only a uniquely matched Pi OAuth subscription credential; xAI API keys and Management API credentials are unsupported.
310
381
  - Credentials resolved for custom provider base URLs are never forwarded to the providers' official usage endpoints; effective auth origin validation requires Pi 0.81.0 or newer.
311
382
  - Provider reports are snapshots and may themselves be delayed by the provider.
383
+ - DeepSeek reports current API balance only; it does not expose historical usage, quota windows, reset times, or account-wide token totals through the balance endpoint.
384
+ - Fireworks reports rated 30-day spend only; credit balance and spend caps are visible only in the Fireworks web console, and keys that can see several accounts must set `fireworksAccountId` in `pi-usage.json`.
312
385
  - OpenRouter successful inference responses do not expose proactive request-rate counters; `/usage` reports the documented per-key credit/spend fields instead.
313
386
  - A provider may not return a safe human-readable account identity.
314
387
  In that case the provider and runtime credential state remain visible without exposing secrets.
@@ -351,7 +424,7 @@ The generated runtime is built from the authoritative `src/index.ts` graph and d
351
424
 
352
425
  ## 🔎 Keywords
353
426
 
354
- Pi extension, Pi coding agent, usage, quota, OpenAI Codex usage, ChatGPT subscription limits, Kimi For Coding, Kimi Coding Plan usage, GitHub Copilot AI credits, GitHub Copilot premium requests, OpenRouter credits, xAI OAuth usage, Grok subscription allowance, API-key spend limits, TypeScript Pi package, npm Pi extension.
427
+ Pi extension, Pi coding agent, usage, quota, DeepSeek API balance, DeepSeek balance, Fireworks API spend, Fireworks rated spend, OpenAI Codex usage, ChatGPT subscription limits, Kimi For Coding, Kimi Coding Plan usage, GitHub Copilot AI credits, GitHub Copilot premium requests, OpenRouter credits, xAI OAuth usage, Grok subscription allowance, API-key spend limits, TypeScript Pi package, npm Pi extension.
355
428
 
356
429
  ## 📄 License
357
430