pub struct Usage {
pub input_tokens: Option<u64>,
pub cache: Option<Box<InputCacheUsage>>,
pub output_tokens: Option<u64>,
pub total_tokens: Option<u64>,
pub reasoning_tokens: Option<u64>,
}Expand description
Normalized token usage counts.
Fields§
§input_tokens: Option<u64>Non-cached input tokens. Provider codecs normalize aggregate OpenAI input counts by subtracting the cache detail fields.
cache: Option<Box<InputCacheUsage>>Cache-read and cache-creation token detail, when reported.
output_tokens: Option<u64>Generated output tokens, excluding reasoning detail when the provider reports it separately.
total_tokens: Option<u64>Provider-reported or codec-computed total token count.
Codecs normalize OpenAI aggregate input counts before computing totals, so this may equal non-cached input plus cache detail plus output.
reasoning_tokens: Option<u64>Reasoning output tokens, when reported separately.
Implementations§
Source§impl Usage
impl Usage
Sourcepub fn cache_details(
cached_input_tokens: Option<u64>,
cache_creation_input_tokens: Option<u64>,
) -> Option<Box<InputCacheUsage>>
pub fn cache_details( cached_input_tokens: Option<u64>, cache_creation_input_tokens: Option<u64>, ) -> Option<Box<InputCacheUsage>>
Builds cache detail when at least one count is present.
Sourcepub fn cached_input_tokens(&self) -> Option<u64>
pub fn cached_input_tokens(&self) -> Option<u64>
Returns the cache-read input-token count.
Sourcepub fn cache_creation_input_tokens(&self) -> Option<u64>
pub fn cache_creation_input_tokens(&self) -> Option<u64>
Returns the cache-creation input-token count.
Sourcepub fn set_cached_input_tokens(&mut self, value: u64)
pub fn set_cached_input_tokens(&mut self, value: u64)
Sets the cache-read count, allocating cache detail when needed.
Sourcepub fn set_cache_creation_input_tokens(&mut self, value: u64)
pub fn set_cache_creation_input_tokens(&mut self, value: u64)
Sets the cache-creation count, allocating cache detail when needed.