@byokit/usage has 1,768 recorded weekly downloads on npm.
About @byokit/usage
@byokit/usage
Read subscription quota windows per provider and per account on Node 22.18 or later. React Native also supports local call/token accounting and pure quota parsing. The app owns sign-in, token renewal, account labels and selection. The kit reads room left, estimates cost only from app-supplied prices and never rotates an account.
import { usage, roomOf } from '@byokit/usage';
const reader = usage({ stateDir: '/app/state/usage' });
// Pass the token and account id from your app-owned sign-in store.
declare const token: string;
declare const account: { id: string };
const source = { provider: 'codex' as const, access: token, accountId: account.id };
const reading = await reader.read(source);
const room = roomOf(reading, Date.now());
Sources:
{ provider: 'codex', access, accountId }reads ChatGPT'swham/usage.{ provider: 'claude', access, accountUuid?, accountId? }reads Claude plan usage.{ provider: 'copilot' | 'grok' | 'minimax' | 'kimi', access, accountId? }reads the corresponding subscription quota. MiniMax'saccessis the plan key.{ provider: 'gemini', access, project?, accountId? }reads Code Assist quota. Without a project, the kit discovers it throughloadCodeAssistfirst.{ provider: 'opencode' | 'zai', key, accountId? }reads plan-key quota.{ provider: 'codex', bin, home, env? }retains the explicit local app-server source.{ provider: 'cursor', folder }reads the dashboard's current-period usage (GetCurrentPeriodUsageonapi2.cursor.sh) with the folder's own login from<folder>/cursor/auth.json, parsed to one monthly window.{ provider: 'pi', folder, piProvider }reads the plan the selected Pi provider id names, from that folder's own login in<folder>/auth.json:openai-codexreads ChatGPT's Codex windows (wham/usage, addressed by the stored ChatGPT account id or the access token's own claim) andkimi-codingreads Kimi's windows (coding/v1/usages). Any other Pi provider id is refused as an invalid source. A missing or refused reading isunknown, never zero. The account cache fingerprint uses the sign-in file's metadata only, never its contents. A re-login or a refresh-only rewrite of<folder>/auth.jsonchanges its metadata and drops the last-good reading.{ provider: 'claude', credentialsFile, configFile?, statuslineFile? }is a read-only adapter for files the app explicitly supplies. It readsclaudeAiOauthand optionallyoauthAccount.accountUuid. A path carrying a.claude,.codexor.pisegment, lexically or through a symlink, is refused withUsageErrorbefore any file is opened, so the person's own default sign-in is never read. A statusline snapshot uses its bodyfetched_at(epoch milliseconds or ISO date), never file mtime. Known snapshots younger than five minutes precede the endpoint; undated/future snapshots remain visible with unknown/future age. An expired token is never sent.{ provider: 'claude', accountUuid, read, origin?, connected? }delegates to the app's reader.read({ nowMs, signal })returns{ raw?, code?, retryAfterMs?, at?, limited? }using the same Claude payload dialect. The host supplies the actual observationat; omitted means unknown age, including engine-cached figures.limited: truecan report an authoritative block without fabricating a window.originis the host reader's optional HTTP origin for pacing. It has a ten-second deadline, with the signal aborted at expiry. The optional synchronousconnected()hook controls whether last-good readings remain visible; exceptions count as disconnected.{ provider: 'claude', ephemeral: true, read, connected? }supports a host-owned opaque snapshot stream without an account UUID, email, folder or token. The sameClaudeReaderanswer and ten-second cancellable deadline apply. For a statusline body, return{ raw: snapshot, at: snapshot.fetched_at }when the host knows thatfetched_atis epoch milliseconds; otherwise omitatfor unknown age. The kit normalizesrate_limitsand quota rows; it never opens a snapshot or credential file, discovers credentials, copies tokens or makes a fallback request.connected()should reflect the host's sign-in status; false or a thrown error returnsnot-connected. An absent/invalid snapshot returnsincomplete, while timeout/cancellation returnsunavailable; the host can report other safe codes.account()andlastKnown()always return undefined. Successful readings are never retained, so each subsequent read invokes the callback again. Only retry metadata and concurrent operations are weakly held per source object in this reader: reuse an immutable source for one stream, and replace it when the host changes sign-in or stream. Failures never return earlier quota figures. Rate limits honor Retry-After with a five-minute default; transient failures use exponential backoff from one minute, capped at one hour.backoff.delayMsmay customize these delays with a one-minute minimum. Store and backoff get/set hooks and account-based pacing are never called; the host owns any pacing in its callback. No state is shared between source objects or reader instances.
read(source, { nowMs?, signal? }) returns { provider, windows, at?, limited?, poll?, code? }.
at is source observation time; it is absent when unavailable. poll contains
last attempt time, outcome (ok or a safe failure code) and optional retryAt.
All timestamps are epoch milliseconds. A failed poll keeps the figures and their
original observation time. Poll 429 (rate-limited), host renewal failure
(refresh-failed) and credential refusals are distinct; usage never changes
account health or renews credentials.…
Description from the npm listing.
- typescript
- ai
- ai-sdk
- react-native
- web
- privacy
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (1)Similar npm AI SDKs plugins
All 20 @byokit/usage alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@byokit/usage. First seen Oct 26, 2026; last successful collection Oct 26, 2026. See the methodology.