#[non_exhaustive]pub struct ModelUsage {
pub input_tokens: usize,
pub output_tokens: usize,
pub cache_read_tokens: Option<usize>,
pub cache_write_tokens: Option<usize>,
pub reasoning_tokens: Option<usize>,
}Expand description
Provider-reported token accounting for one model response.
Reports four non-overlapping raw counts with the same meaning across all
wire protocols. Any reasoning or thinking tokens are included in
Self::output_tokens.
Serializable for logs and tests; the serialized form is not part of the stable set and may change in any release.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.input_tokens: usizeInput tokens that neither hit nor were written to the prompt cache (uncached input).
The meaning is the same across all wire protocols. This count does not
overlap with Self::cache_read_tokens, Self::cache_write_tokens,
or Self::output_tokens.
output_tokens: usizeAll tokens generated by the model on the output side of the exchange, including any reasoning or thinking tokens.
The meaning is the same across all wire protocols. This count does not
overlap with Self::input_tokens, Self::cache_read_tokens, or
Self::cache_write_tokens.
cache_read_tokens: Option<usize>Tokens read from the prompt cache, if disclosed by the endpoint.
The meaning is the same across all wire protocols. None indicates the
endpoint did not report it (never fabricated as 0). This count does
not overlap with Self::input_tokens, Self::cache_write_tokens,
or Self::output_tokens.
cache_write_tokens: Option<usize>Tokens written to the prompt cache, if disclosed by the endpoint.
The meaning is the same across all wire protocols. None indicates the
endpoint did not report it (never fabricated as 0). This count does not
overlap with Self::input_tokens, Self::cache_read_tokens, or
Self::output_tokens.
reasoning_tokens: Option<usize>Reasoning or thinking tokens generated by the model, if disclosed by the endpoint.
The meaning is the same across all wire protocols. None indicates the
endpoint did not report it. When present, this count is a subset of
Self::output_tokens; hosts must not add it to output or total
sums.