pub struct TokenUsage {
pub prompt_tokens: Option<u32>,
pub completion_tokens: Option<u32>,
pub reasoning_tokens: Option<u32>,
pub total_tokens: Option<u32>,
}Expand description
Tokens a provider reported for one request.
Reported rather than estimated: a caller’s own token estimate decides what to send, and this says what it actually cost. Every field is optional because providers disagree on which they return, and a missing count must not read as zero.
Fields§
§prompt_tokens: Option<u32>Tokens in the request, including the system prompt and tool definitions.
completion_tokens: Option<u32>Tokens the model generated, excluding reasoning where a provider splits them out.
reasoning_tokens: Option<u32>Reasoning tokens, where the provider reports them separately. Billed, and
invisible in completion_tokens on most providers.
total_tokens: Option<u32>The provider’s own total. Not derived from the fields above — a provider that reports only this one is common, and a total that disagrees with the parts is the provider’s answer, not ours to correct.
Implementations§
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 more