Skip to main content

Module usage

Module usage 

Source
Expand description

Canonical in-memory representation of “how much have I used my plan”.

Each vendor’s snapshot lives in its own variant — this is deliberate. Anthropic exposes three windows + extra credits; OpenAI Codex exposes two windows + credit balance + message-count ranges; OpenRouter is a single credit-balance number with daily/weekly/monthly totals; Z.AI is a list of token + MCP buckets. Forcing them into a shared shape would either drop information or paper over genuine differences.

Renderers (widget tooltip, TUI tab) consume a VendorSnapshot directly, not a flattened shape — so each vendor controls its own presentation while sharing the pacing math, color thresholds, and Pango primitives.

Structs§

AnthropicSnapshot
Anthropic-specific snapshot — three rolling windows plus optional pay-as-you-go credit balance.
Cents
Money expressed in cents to dodge float roundoff.
DeepseekSnapshot
DeepSeek — credit balance from /user/balance.
ExtraUsage
“Extra usage” pay-as-you-go block (claudebar’s extra_usage).
OpenAiCredits
OpenAiSnapshot
OpenAI Codex OAuth — mirrors Anthropic’s two-window + extras pattern.
OpenRouterSnapshot
OpenRouter — credit balance + lifetime/daily/weekly/monthly usage from /api/v1/credits and /api/v1/key.
UsageWindow
A single usage window — generic enough that every vendor with a notion of “% used vs. when does it reset” can express itself with it.
ZaiSnapshot
Z.AI / BigModel — list of buckets with discriminated types. We project the two we care about into named fields (5h tokens, weekly tokens, MCP).

Enums§

OpenAiSource
VendorSnapshot
Discriminated union of vendor-specific snapshots. The widget and TUI match on this to pick a renderer.

Functions§

anthropic_severity
Worst-of severity class for the Waybar bar text color. Mirrors claudebar:606-620 — “extra usage only matters when a rate limit hits 100%”.