pub struct RealUsage {
pub model: String,
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_read_tokens: u64,
pub cache_write_tokens: u64,
pub reasoning_tokens: u64,
pub provider_cost_usd: Option<f64>,
pub cohort: Cohorts,
pub wire: Option<Box<WireContext>>,
pub response_observation: Option<ResponseObservation>,
}Expand description
One LLM turn’s real, provider-reported usage, normalized to billable buckets.
output_tokens already includes reasoning/thinking tokens (they are billed at
the output rate); reasoning_tokens is retained only for display.
Fields§
§model: String§input_tokens: u64Input tokens billed at the input rate (cache reads/writes excluded).
output_tokens: u64Output tokens billed at the output rate (includes reasoning/thoughts).
cache_read_tokens: u64Input tokens served from the prompt cache (billed at the cache-read rate).
cache_write_tokens: u64Input tokens written to the prompt cache (Anthropic + OpenRouter models with explicit cache-write pricing; 0 elsewhere).
reasoning_tokens: u64Reasoning/thinking subset of output_tokens (display only).
provider_cost_usd: Option<f64>USD the provider actually charged for this turn, when the response
reports it. OpenRouter: usage.cost in credits (≡ USD); for BYOK
requests the separate cost_details.upstream_inference_cost is added
when it differs from cost (#746 — non-BYOK mirrors cost there).
The measured figure beats any price-table estimate wherever both exist.
None for providers that report tokens only (Anthropic/OpenAI/Gemini).
cohort: CohortsHoldout arms for this turn: output shaping (#895 Track B) and input
compression (#1905), each None when that holdout is off. Stamped from
the request, not parsed from the response.
wire: Option<Box<WireContext>>Request-side gateway context (enterprise#11/#17/#18): identity tags,
compression savings and baseline inputs, stamped from the request before
it left for the upstream. None outside the forward path (e.g. tests
that only parse response bodies).
response_observation: Option<ResponseObservation>Present only for measured upstream responses, never cache hits or synthetic parser inputs. Kept local in the existing usage meter.
Implementations§
Source§impl RealUsage
impl RealUsage
Sourcepub fn to_ocla_usage_record(&self) -> OclaResult<Option<UsageRecord>>
pub fn to_ocla_usage_record(&self) -> OclaResult<Option<UsageRecord>>
Projects measured proxy usage into the payload-free canonical OCLA record. Missing lineage is unmanaged; invalid data and arithmetic overflow fail closed for OCLA without disturbing the existing usage pipeline.
Trait Implementations§
impl StructuralPartialEq for RealUsage
Auto Trait Implementations§
impl Forget for RealUsage
impl Freeze for RealUsage
impl Move for RealUsage
impl RefUnwindSafe for RealUsage
impl Send for RealUsage
impl Sync for RealUsage
impl Unpin for RealUsage
impl UnsafeUnpin for RealUsage
impl UnwindSafe for RealUsage
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,
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