pub struct Usage {
pub prompt: u32,
pub completion: u32,
pub total: u32,
pub prompt_tokens_details: Option<PromptTokensDetails>,
pub completion_tokens_details: Option<CompletionTokensDetails>,
}Expand description
Token usage statistics in OpenAI’s shape.
The cache and reasoning shares ride in OpenAI’s own breakdown objects, so
a stock client keeps reading the three counts and a cost-aware one finds
the shares where it already looks. A share the runner did not report is
absent, never a zero: None means “not measured”, Some(0) “measured zero”.
Reasoning is counted the opposite way on each side of this type. An
embacle TokenUsage keeps it out of completion_tokens (additive, the
way its pricing bills it); OpenAI’s completion_tokens includes it and
completion_tokens_details.reasoning_tokens is a breakdown of that count.
The From conversion folds reasoning into completion_tokens, so a
client pricing by completion_tokens bills the reasoning, and one taking
completion_tokens - reasoning_tokens gets the visible output.
Fields§
§prompt: u32Tokens in the prompt, cached reads and writes included
completion: u32Tokens in the completion, reasoning tokens included
total: u32Total tokens, never below prompt_tokens + completion_tokens
prompt_tokens_details: Option<PromptTokensDetails>The cached share of prompt_tokens, when the runner reported one
completion_tokens_details: Option<CompletionTokensDetails>The reasoning share of completion_tokens, when the runner reported one