pub struct UsageEvent {Show 19 fields
pub person: String,
pub team: Option<String>,
pub project: String,
pub provider: String,
pub model: String,
pub routed_from: Option<String>,
pub input_tokens: i64,
pub output_tokens: i64,
pub cache_read_tokens: i64,
pub cache_write_tokens: i64,
pub reasoning_tokens: i64,
pub cost_usd: f64,
pub saved_tokens: i64,
pub saved_usd: f64,
pub uncompressed_input_tokens: i64,
pub reference_model: Option<String>,
pub reference_cost_usd: f64,
pub is_local: bool,
pub cost_source: &'static str,
}Expand description
One usage_events row, fully derived from a finalized RealUsage.
Fields§
§person: String§team: Option<String>§project: String§provider: String§model: String§routed_from: Option<String>§input_tokens: i64§output_tokens: i64§cache_read_tokens: i64§cache_write_tokens: i64§reasoning_tokens: i64§cost_usd: f64§saved_tokens: i64§saved_usd: f64§uncompressed_input_tokens: i64§reference_model: Option<String>§reference_cost_usd: f64§is_local: bool§cost_source: &'static strWhere cost_usd came from (#1179): provider (the response’s own
charge), shadow (local shadow rate), live (current provider price
list), list (embedded list price) or heuristic (estimate).
Implementations§
Source§impl UsageEvent
impl UsageEvent
Sourcepub fn from_usage(
usage: &RealUsage,
pricing: &ModelPricing,
baseline: &BaselineConfig,
) -> Self
pub fn from_usage( usage: &RealUsage, pricing: &ModelPricing, baseline: &BaselineConfig, ) -> Self
Derives the row from a measured turn, pricing both the actual cost and the compression saving with the shared pricing table, and stamping the counterfactual baseline (enterprise#15/#18):
cost_usd, in precedence order (#1179): the provider’s own reported charge (usage.cost, OpenRouter) — exceptis_local, which books the transparentlocal_shadow_rate(never $0; Doc 04 §6) — then the live/list price table.cost_sourcerecords which one applied.reference_cost_usd: the request’s uncompressed input tokens priced at the contract-frozenreference_model’s input rate (Doc 08 §2) — the counterfactual the avoided-cost ledger settles against.saved_usd: the SEE (compression) component only — saved request tokens at the served model’s input rate. Full mechanism attribution (routing/caching) is the signed ledger’s job (wave 4, enterprise#19).
Trait Implementations§
Source§impl Clone for UsageEvent
impl Clone for UsageEvent
Source§fn clone(&self) -> UsageEvent
fn clone(&self) -> UsageEvent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UsageEvent
impl Debug for UsageEvent
Source§impl PartialEq for UsageEvent
impl PartialEq for UsageEvent
impl StructuralPartialEq for UsageEvent
Auto Trait Implementations§
impl Freeze for UsageEvent
impl RefUnwindSafe for UsageEvent
impl Send for UsageEvent
impl Sync for UsageEvent
impl Unpin for UsageEvent
impl UnsafeUnpin for UsageEvent
impl UnwindSafe for UsageEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more