Skip to main content

Module budget

Module budget 

Source
Expand description

Self-tracked per-provider budget (RFC-031 §4, Phase 1).

Reuses the crate::budget::BudgetManager sliding-window+reset pattern but re-keyed from AgentId to provider id. The cap is the subscription plan allocation; the reset window is the plan’s reset cadence.

§Why self-tracked

ZAI / Minimax may not expose a remaining_percent / resets_at field on their usage APIs. The self-tracked counter is the primary mechanism precisely because it never depends on those fields. The crate::token_maxing::quota_tracker::QuotaTracker layers recalibration (where an endpoint exists) and reactive 429 cooldown on top.

§Drift

The counter only sees tokens oxios itself sent. If the same API key is used by another app/instance, the counter under-counts. That’s why QuotaTracker recalibrates from real provider state when available, and falls back to a 429 cooldown when a real request hits a hard limit.

Structs§

ProviderBudget
Per-provider budget manager.
ProviderSnapshot
Read-only view of a ProviderState at a moment in time.
ProviderState
Per-provider state.

Enums§

ReserveError
Errors from ProviderBudget::reserve.