pub struct Usage {
pub requests: u64,
pub input_tokens: u64,
pub cache_write_tokens: u64,
pub cache_read_tokens: u64,
pub output_tokens: u64,
pub total_tokens: u64,
pub tool_calls: u64,
}Expand description
Token and request usage accumulated by model and runtime layers.
Fields§
§requests: u64Number of provider requests.
input_tokens: u64Input or prompt tokens.
Provider adapters should normalize this as total provider-billed input tokens for the request, including cache-write and cache-read tokens when those subtotals are present. Pricing helpers subtract the cache subtotals before applying cache-specific rates.
cache_write_tokens: u64Tokens written to a provider prompt cache.
cache_read_tokens: u64Tokens read from a provider prompt cache.
output_tokens: u64Output or completion tokens.
total_tokens: u64Total tokens.
tool_calls: u64Number of successful function tool calls executed by the runtime.
Implementations§
Source§impl Usage
impl Usage
Sourcepub fn add_assign(&mut self, other: &Self)
pub fn add_assign(&mut self, other: &Self)
Add another usage value into this one.
Sourcepub const fn with_additional_tool_calls(self, tool_calls: u64) -> Self
pub const fn with_additional_tool_calls(self, tool_calls: u64) -> Self
Return a copy with additional successful tool calls applied.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Usage
impl<'de> Deserialize<'de> for Usage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Usage
impl StructuralPartialEq for Usage
Auto Trait Implementations§
impl Freeze for Usage
impl RefUnwindSafe for Usage
impl Send for Usage
impl Sync for Usage
impl Unpin for Usage
impl UnsafeUnpin for Usage
impl UnwindSafe for Usage
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