pub struct Usage {
pub prompt_tokens: u32,
pub completion_tokens: u32,
pub total_tokens: u32,
pub cached_tokens: Option<u32>,
pub reasoning_tokens: Option<u32>,
}Expand description
Usage statistics for API calls
Fields§
§prompt_tokens: u32Number of tokens in the prompt
completion_tokens: u32Number of tokens in the completion
total_tokens: u32Total number of tokens used
cached_tokens: Option<u32>Number of cached tokens (if applicable)
reasoning_tokens: Option<u32>Reasoning tokens (for models with reasoning capabilities)
Implementations§
Source§impl Usage
impl Usage
Sourcepub fn with_cached_tokens(self, cached_tokens: u32) -> Self
pub fn with_cached_tokens(self, cached_tokens: u32) -> Self
Set cached tokens
Sourcepub fn with_reasoning_tokens(self, reasoning_tokens: u32) -> Self
pub fn with_reasoning_tokens(self, reasoning_tokens: u32) -> Self
Set reasoning tokens
Sourcepub fn effective_prompt_tokens(&self) -> u32
pub fn effective_prompt_tokens(&self) -> u32
Get effective prompt tokens (excluding cached)
Sourcepub fn total_cost(&self) -> u32
pub fn total_cost(&self) -> u32
Get total cost in tokens
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
Auto Trait Implementations§
impl Freeze for Usage
impl RefUnwindSafe for Usage
impl Send for Usage
impl Sync for Usage
impl Unpin 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