pub struct TokenUsage {
pub provider: Option<String>,
pub model: Option<String>,
pub input_tokens: Option<u64>,
pub output_tokens: Option<u64>,
pub total_tokens: Option<u64>,
pub reasoning_tokens: Option<u64>,
pub cached_input_tokens: Option<u64>,
}Expand description
A numeric-only token usage summary for one (provider, model) pair.
Deliberately carries nothing identifying or content-bearing — no prompts, completions, message text, or thread/run/user ids. Only provider and model labels plus counts, so usage can be logged and aggregated in places where conversation content must not go.
Every count is optional and every count is a non-negative integer: None
means the provider did not report it, which is distinct from zero.
Fields§
§provider: Option<String>The inference provider, for example "anthropic".
model: Option<String>The model id, for example "claude-opus-5".
input_tokens: Option<u64>Tokens consumed by the prompt.
output_tokens: Option<u64>Tokens produced by the model.
total_tokens: Option<u64>Total tokens, as reported by the provider (not necessarily the sum of the other fields).
reasoning_tokens: Option<u64>Output tokens spent on reasoning.
cached_input_tokens: Option<u64>Input tokens served from the provider’s prompt cache.
Implementations§
Source§impl TokenUsage
impl TokenUsage
Sourcepub const fn has_counts(&self) -> bool
pub const fn has_counts(&self) -> bool
Whether any count is present. A labels-only entry reports nothing and should be omitted rather than emitted.
Trait Implementations§
Source§impl Clone for TokenUsage
impl Clone for TokenUsage
Source§fn clone(&self) -> TokenUsage
fn clone(&self) -> TokenUsage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ComposeSchema for TokenUsage
impl ComposeSchema for TokenUsage
Source§impl Debug for TokenUsage
impl Debug for TokenUsage
Source§impl Default for TokenUsage
impl Default for TokenUsage
Source§fn default() -> TokenUsage
fn default() -> 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>,
impl Eq for TokenUsage
Source§impl JsonSchema for TokenUsage
impl JsonSchema for TokenUsage
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for TokenUsage
impl PartialEq for TokenUsage
Source§fn eq(&self, other: &TokenUsage) -> bool
fn eq(&self, other: &TokenUsage) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for TokenUsage
impl Serialize for TokenUsage
impl StructuralPartialEq for TokenUsage
Auto Trait Implementations§
impl Freeze 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§
impl<T> AgentState for T
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.