pub struct Usage {
pub input_tokens: Option<u64>,
pub output_tokens: Option<u64>,
pub reasoning_tokens: Option<u64>,
pub cached_input_tokens: Option<u64>,
pub total_tokens: Option<u64>,
}Expand description
Token accounting reported by a provider response.
Fields stay None when the provider did not report that exact value.
The Kit does not derive aggregate totals or request counts from other
fields.
§Examples
let usage = providers_kit::generation::Usage {
input_tokens: Some(12),
output_tokens: Some(34),
reasoning_tokens: None,
cached_input_tokens: Some(5),
total_tokens: Some(46),
};
assert_eq!(usage.cached_input_tokens, Some(5));
assert_eq!(usage.total_tokens, Some(46));Fields§
§input_tokens: Option<u64>Input tokens billed or counted for the request.
output_tokens: Option<u64>Output tokens generated by the provider.
reasoning_tokens: Option<u64>Reasoning or thinking tokens reported separately by the provider.
cached_input_tokens: Option<u64>Input tokens served from prompt cache rather than recomputed.
total_tokens: Option<u64>Total token count when the provider reports an aggregate value.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.