pub struct ModelUsage {
pub requests: u64,
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_read_tokens: u64,
pub cache_write_tokens: u64,
pub reasoning_tokens: u64,
pub counterfactual_requests: u64,
pub counterfactual_input_tokens: u64,
pub counterfactual_billed_tokens: u64,
pub measured: MeasuredSlice,
pub response_observations: VecDeque<ResponseObservation>,
pub saved_tokens: u64,
}Expand description
Cumulative real token counts for one model. Cost is derived at read time so a pricing-table change re-values historical usage consistently.
Fields§
§requests: u64§input_tokens: u64§output_tokens: u64§cache_read_tokens: u64§cache_write_tokens: u64§reasoning_tokens: u64§counterfactual_requests: u64Requests whose free count_tokens probe answered (#701) — the rows the
verified-savings pair below covers. serde(default) keeps pre-#701
usage files loadable.
counterfactual_input_tokens: u64Provider-counted input tokens the covered requests would have billed WITHOUT lean-ctx (sum of probe answers on the original bodies).
counterfactual_billed_tokens: u64Input-side tokens those same requests actually billed (input + cache read + cache write) — same request, same moment, no confound.
measured: MeasuredSliceThe turns whose response carried the provider’s own USD charge
(OpenRouter usage accounting, #1179). Their tokens are inside the
totals above; pricing subtracts this slice and books its measured USD
instead of a table estimate. serde(default) keeps older files loadable.
response_observations: VecDeque<ResponseObservation>Recent factual response measurements, not quality/training labels. This local diagnostic history must not be pooled into private ranking: it has no verified actor/endpoint scope or user-accepted outcome yet.
saved_tokens: u64Input tokens the proxy’s wire compression removed before forwarding
(the request-body estimate, bytes / 4). An estimate, not a provider
count — the verified pair above is the measured one. serde(default)
keeps older files loadable.
Implementations§
Source§impl ModelUsage
impl ModelUsage
pub fn billable_tokens(&self) -> u64
pub fn add_observation(&mut self, observation: ResponseObservation)
Trait Implementations§
Source§impl Clone for ModelUsage
impl Clone for ModelUsage
Source§fn clone(&self) -> ModelUsage
fn clone(&self) -> ModelUsage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelUsage
impl Debug for ModelUsage
Source§impl Default for ModelUsage
impl Default for ModelUsage
Source§fn default() -> ModelUsage
fn default() -> ModelUsage
Source§impl<'de> Deserialize<'de> for ModelUsage
impl<'de> Deserialize<'de> for ModelUsage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ModelUsage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ModelUsage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ModelUsage
impl PartialEq for ModelUsage
Source§impl Serialize for ModelUsage
impl Serialize for ModelUsage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ModelUsage
Auto Trait Implementations§
impl Forget for ModelUsage
impl Freeze for ModelUsage
impl Move for ModelUsage
impl RefUnwindSafe for ModelUsage
impl Send for ModelUsagewhere
RawVecInner: Send,
impl Sync for ModelUsagewhere
RawVecInner: Sync,
impl Unpin for ModelUsage
impl UnsafeUnpin for ModelUsage
impl UnwindSafe for ModelUsagewhere
RawVecInner: UnwindSafe,
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
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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