#[non_exhaustive]pub struct Usage {
pub input_tokens: u32,
pub output_tokens: u32,
pub cached_input_tokens: u32,
pub cache_creation_input_tokens: u32,
pub cache_creation_5m_tokens: u32,
pub cache_creation_1h_tokens: u32,
}Expand description
Token counters reported by the provider for a turn.
Aggregated to the run level by the engine and surfaced on
StreamChunk::RunFinished / StreamChunk::TurnFinished. Fields
not surfaced by a given provider stay at 0.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.input_tokens: u32Total prompt tokens charged this turn (cached + uncached).
output_tokens: u32Tokens generated by the model this turn.
cached_input_tokens: u32Subset of input_tokens that were served from prompt cache
rather than recomputed. Zero when the provider does not
support prompt caching or when this turn missed the cache.
cache_creation_input_tokens: u32Total tokens written to a cache during this turn. When the
provider reports a TTL breakdown (Anthropic), this equals the sum
of Self::cache_creation_5m_tokens + Self::cache_creation_1h_tokens.
When only the legacy flat field is reported, the breakdown stays
at zero and only this total is populated.
cache_creation_5m_tokens: u32Cache writes with a 5-minute TTL (Anthropic ephemeral default). Zero when the provider does not surface a TTL breakdown.
cache_creation_1h_tokens: u32Cache writes with a 1-hour TTL (Anthropic explicit ttl=“1h”). Zero when the provider does not surface a TTL breakdown.
Trait Implementations§
Source§impl AddAssign for Usage
impl AddAssign for Usage
Source§fn add_assign(&mut self, other: Usage)
fn add_assign(&mut self, other: Usage)
+= operation. Read more