#[non_exhaustive]pub struct TokenUsage {
pub input_tokens: u64,
pub output_tokens: u64,
pub cached_tokens: u64,
pub cache_write_tokens: Option<u64>,
pub cache_read_tokens: Option<u64>,
pub reasoning_tokens: u64,
}Expand description
Raw token counters, verbatim from the durable record. Not directly summable across providers — sum the counted-once derivations instead.
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: u64Provider-reported input tokens.
output_tokens: u64Provider-reported output tokens.
cached_tokens: u64Provider-reported cache tokens (inside or beside inputTokens,
provider-convention-dependent — the reason promptTokens exists).
cache_write_tokens: Option<u64>Cache write tokens, only when the provider distinguishes writes/reads.
cache_read_tokens: Option<u64>Cache read tokens, only when the provider distinguishes writes/reads.
reasoning_tokens: u64Output tokens spent on reasoning, when the provider reports it.
Trait Implementations§
Source§impl Clone for TokenUsage
impl Clone for TokenUsage
impl Copy for TokenUsage
Source§impl Debug for TokenUsage
impl Debug for TokenUsage
Source§impl<'de> Deserialize<'de> for TokenUsage
impl<'de> Deserialize<'de> for TokenUsage
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 TokenUsage
Source§impl PartialEq for TokenUsage
impl PartialEq for TokenUsage
Source§impl Serialize for TokenUsage
impl Serialize for TokenUsage
impl StructuralPartialEq for TokenUsage
Auto Trait Implementations§
impl Forget for TokenUsage
impl Freeze for TokenUsage
impl Move for TokenUsage
impl RefUnwindSafe for TokenUsage
impl Send for TokenUsage
impl Sync for TokenUsage
impl Unpin for TokenUsage
impl UnsafeUnpin for TokenUsage
impl UnwindSafe for TokenUsage
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