Struct Usage Copy item path Source pub struct Usage {
pub input: Option <u64 >,
pub output: Option <u64 >,
pub cache_creation: Option <u64 >,
pub cache_creation_5m: Option <u64 >,
pub cache_creation_1h: Option <u64 >,
pub cache_read: Option <u64 >,
pub thinking: Option <u64 >,
}Expand description Token usage as reported by the agent.
Every field is Option: None means UNKNOWN, which is not the same as zero
(CLAUDE.md §8.5). Renderers must show unknowns as such.
Total cache-creation (write) tokens.
5-minute-TTL share of cache_creation, when the agent reports the split.
Priced differently from the 1h share (see pricing).
1-hour-TTL share of cache_creation (priced 2x input vs 1.25x for 5m).
Extended-thinking (reasoning) tokens, ONLY when the agent reports them as a
SEPARATE, disjoint count (Codex reasoning_output_tokens, kept out of
output). Claude Code does NOT report them separately — there, thinking is
already INCLUDED in output (verified v2.1.178), so this stays None to
avoid double-counting in Usage::known_total ; thinking is surfaced as a
char-measured attribution of output in analysis::dedup instead
(CLAUDE.md §8.2).
True when no field carries any information.
Sum of all KNOWN token counts (the 5m/1h fields are a breakdown of
cache_creation and are not added again).
Field-wise maximum, treating None as “no information” (not zero).
This is the dedup merge rule: lines of one request either repeat identical
usage or grow monotonically while streaming, so MAX recovers the final
per-request value in both cases.
Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more Returns the “default value” for a type.
Read more Deserialize this value from the given Serde deserializer.
Read more Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Serialize this value into the given Serde serializer.
Read more Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Instruments this type with the provided
Span, returning an
Instrumented wrapper.
Read more Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.