pub struct TokenUsage {
pub input_tokens: Option<u64>,
pub cached_input_tokens: Option<u64>,
pub cache_write_input_tokens: Option<u64>,
pub output_tokens: Option<u64>,
pub reasoning_output_tokens: Option<u64>,
pub total_tokens: Option<u64>,
}Expand description
Token usage reported by the CLI for a single run.
Field names align with codex-wrapper’s TokenUsage so an adapter
can map the two directly (see the cross-crate design in issue #760).
Serde aliases accept the Anthropic key names the CLI actually emits
(cache_read_input_tokens, cache_creation_input_tokens), the same
keys the on-disk history accounting reads, so the live and read-side
paths agree.
Every field is Option because the CLI does not report all buckets
on every turn. A missing bucket means “not reported”, not zero;
Session::turns_missing_usage
exists so callers can tell a low total from an incomplete one.
Fields§
§input_tokens: Option<u64>Non-cached input tokens.
cached_input_tokens: Option<u64>Input tokens served from cache.
cache_write_input_tokens: Option<u64>Input tokens written to cache.
output_tokens: Option<u64>Output tokens.
reasoning_output_tokens: Option<u64>Output tokens spent on reasoning, where the CLI reports them separately.
total_tokens: Option<u64>Explicit total, where the CLI reports one.
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