pub struct ModelUsage {
pub cache_read_tokens: Option<u64>,
pub cache_write_tokens: Option<u64>,
pub context: Option<ContextFill>,
pub cost: Option<CostEstimate>,
pub input_tokens: u64,
pub model: String,
pub output_tokens: u64,
pub reasoning_tokens: Option<u64>,
pub requests: u32,
pub unreported_requests: u32,
}Expand description
Tokens and estimated charge of one model within one turn or isolated prompt.
The counts overlap: cache_read_tokens and cache_write_tokens are part
of input_tokens, and reasoning_tokens is part of output_tokens.
A request whose backend reported no input or output count is counted in
unreported_requests, which makes the token totals lower bounds.
Fields§
§cache_read_tokens: Option<u64>Input tokens served from the provider’s prompt cache, or None when
the backend does not report them.
cache_write_tokens: Option<u64>Input tokens written to the provider’s prompt cache, or None when
the backend does not report them.
context: Option<ContextFill>Context fill of this model’s requests, or None when no request
reported its input.
cost: Option<CostEstimate>Estimated charge, or None when no price is known for every request.
input_tokens: u64All input tokens, cache included.
model: StringModel identifier, as sessions record it.
output_tokens: u64Output tokens, reasoning included.
reasoning_tokens: Option<u64>Reasoning tokens, or None when the backend does not report them.
requests: u32Provider requests counted, including unreported ones.
unreported_requests: u32Requests whose backend reported no input or output count.
Implementations§
Source§impl ModelUsage
impl ModelUsage
Sourcepub fn new(model: impl Into<String>) -> Self
pub fn new(model: impl Into<String>) -> Self
Returns usage of model with no requests and every detail unknown.
Sourcepub fn unreported(model: impl Into<String>, requests: u32) -> Self
pub fn unreported(model: impl Into<String>, requests: u32) -> Self
Returns usage of model for requests whose backend reported nothing.
Trait Implementations§
Source§impl Clone for ModelUsage
impl Clone for ModelUsage
Source§impl Debug for ModelUsage
impl Debug for ModelUsage
impl Eq for ModelUsage
Source§impl Hash for ModelUsage
impl Hash for ModelUsage
Source§impl PartialEq for ModelUsage
impl PartialEq for ModelUsage
impl StructuralPartialEq for ModelUsage
Auto Trait Implementations§
impl Forget for ModelUsage
impl Freeze for ModelUsage
impl Move for ModelUsage
impl RefUnwindSafe for ModelUsage
impl Send for ModelUsage
impl Sync for ModelUsage
impl Unpin for ModelUsage
impl UnsafeUnpin for ModelUsage
impl UnwindSafe for ModelUsage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
key and return true if they are equal.