pub struct UsageSnapshot {
pub source: UsageSourceKind,
pub fetched_at: SystemTime,
pub five_hour: Option<UsageWindow>,
pub seven_day: Option<UsageWindow>,
pub seven_day_opus: Option<UsageWindow>,
pub seven_day_sonnet: Option<UsageWindow>,
pub extra_usage: Option<ExtraUsage>,
pub spend: Option<ApiSpend>,
pub balance: Option<f64>,
}Expand description
Snapshot of the user’s Anthropic plan utilization at a point in time. Composed by the forge-gateway backends and rendered by a view.
Fields§
§source: UsageSourceKind§fetched_at: SystemTime§five_hour: Option<UsageWindow>§seven_day: Option<UsageWindow>§seven_day_opus: Option<UsageWindow>§seven_day_sonnet: Option<UsageWindow>§extra_usage: Option<ExtraUsage>§spend: Option<ApiSpend>Per-key spend for an API-billed account. None for every
window-billed source, and for every row written before this
field existed - serde decodes a missing key on an Option to
None, which is what keeps the cached rows readable.
balance: Option<f64>The OpenRouter account’s remaining credit pool, in USD:
total_credits - total_usage from /v1/credits. Account-wide -
every key on the account draws on the same pool - unlike the
per-key figures in ApiSpend. None when the credits fetch
failed, when the 200 carried no data envelope, and for every
cached row written before this field existed, decoded as absent
like spend above.
Implementations§
Source§impl UsageSnapshot
impl UsageSnapshot
Sourcepub fn five_hour_util(&self) -> Option<f64>
pub fn five_hour_util(&self) -> Option<f64>
None when the snapshot carries no five-hour window, which is a
documented steady state on the lenient mapper rather than a zero.
Sourcepub fn seven_day_util(&self) -> Option<f64>
pub fn seven_day_util(&self) -> Option<f64>
Binding 7-day utilisation: max across the three 7-day windows
(seven_day, seven_day_opus, seven_day_sonnet). Whichever
is most-used is the binding constraint for “is this account
7-day rate-limited.”
None when all three are absent, which a 200 carrying only the
session window produces.
Sourcepub fn binding_reset_at(&self) -> Option<SystemTime>
pub fn binding_reset_at(&self) -> Option<SystemTime>
When a rate-limited account unlocks: the latest resets_at among
windows currently at-or-over the cap (per is_currently_limited).
None when no window is currently capped, so a reset ETA is shown
only on rate-limited rows.
Sourcepub fn same_usage(&self, other: &UsageSnapshot) -> bool
pub fn same_usage(&self, other: &UsageSnapshot) -> bool
Whether two snapshots say the same thing, fetched_at aside.
Derived PartialEq cannot answer this: fetched_at moves on
every probe, so two successful polls that found an unchanged pool
compare unequal and every poll reads as news. The field says when a
reading was taken, not what it says, and it is the only one excluded
here - a new usage field belongs in the comparison below.
Trait Implementations§
Source§impl Clone for UsageSnapshot
impl Clone for UsageSnapshot
Source§fn clone(&self) -> UsageSnapshot
fn clone(&self) -> UsageSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more