#[non_exhaustive]pub struct SessionUsage {
pub input_tokens: u64,
pub cached_input_tokens: u64,
pub output_tokens: u64,
pub reasoning_tokens: u64,
}Expand description
Exact cumulative token usage reported by a Foundation Models 27 session.
Returned by Session::usage. Unlike crate::estimate_tokens, these
counts are authoritative and include prompt caching and
extended-reasoning accounting.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.input_tokens: u64Total input tokens across all requests in this session.
cached_input_tokens: u64Input tokens that were served from the prompt cache.
output_tokens: u64Total output tokens across all responses in this session.
reasoning_tokens: u64Output tokens spent on extended reasoning.
Implementations§
Source§impl SessionUsage
impl SessionUsage
Sourcepub fn delta_since(&self, earlier: &SessionUsage) -> Result<SessionUsage>
pub fn delta_since(&self, earlier: &SessionUsage) -> Result<SessionUsage>
Returns the usage consumed since an earlier snapshot of this session.
§Errors
Returns Error::InvalidInput if any counter went backwards, which
indicates the snapshots came from different sessions or were taken
out of order.
Trait Implementations§
Source§impl Clone for SessionUsage
impl Clone for SessionUsage
impl Copy for SessionUsage
Source§impl Debug for SessionUsage
impl Debug for SessionUsage
impl Eq for SessionUsage
Source§impl PartialEq for SessionUsage
impl PartialEq for SessionUsage
impl StructuralPartialEq for SessionUsage
Auto Trait Implementations§
impl Freeze for SessionUsage
impl RefUnwindSafe for SessionUsage
impl Send for SessionUsage
impl Sync for SessionUsage
impl Unpin for SessionUsage
impl UnsafeUnpin for SessionUsage
impl UnwindSafe for SessionUsage
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