Documentation
¶
Overview ¶
Package usage defines the normalized rate-limit usage model shared across providers. Readers translate each provider's raw API response into these types so the scheduler and CLI can treat every provider uniformly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credits ¶
Credits describes pay-as-you-go credits that may remain available even when the weekly window is exhausted.
type ResetCredit ¶ added in v0.7.0
type ResetCredit struct {
Status string
GrantedAt time.Time
ExpiresAt time.Time
RedeemedAt time.Time
}
ResetCredit is a banked Codex rate-limit reset credit.
type ResetCredits ¶ added in v0.7.0
type ResetCredits struct {
AvailableCount int
Credits []ResetCredit
}
ResetCredits summarizes account-backed Codex reset credits.
type Usage ¶
type Usage struct {
Provider string
FiveHour Window
Weekly Window
Plan string
Credits *Credits
ResetCredits *ResetCredits
LimitReached bool
FetchedAt time.Time
Raw []byte // raw JSON body, for `status -v`
}
Usage is a provider's full rate-limit snapshot at FetchedAt.
func (*Usage) CreditsUsable ¶
CreditsUsable reports whether credits can cover a request when the weekly window is exhausted.
func (*Usage) WeeklyExhausted ¶ added in v0.6.0
WeeklyExhausted reports whether the weekly window should block new work: its utilization is at/above threshold (0..1, e.g. cfg.WeeklyThreshold) and no usable credits remain. Shared by the scheduler's ping skip and the continue proxy's recovery gate so "weekly is spent" means the same thing everywhere.
type Window ¶
Window is a single rate-limit window (e.g. the 5h rolling window or the weekly window). UsedPercent is 0..100.
func (Window) Active ¶
Active reports whether the window currently has consumption recorded and has not yet reset. A freshly reset (or never-started) window is inactive, which is the signal the scheduler uses to decide whether to ping immediately.
func (Window) Missing ¶ added in v0.8.0
Missing reports whether the provider returned no data for this window at all, meaning the limit is not currently enforced (OpenAI temporarily removed Codex's 5h window on 2026-07-12, leaving only the weekly cap). Distinct from an inactive window, which is enforced but has no consumption yet.