pub struct UsageInfo {
pub input_tokens: u32,
pub cache_creation_input_tokens: u32,
pub cache_read_input_tokens: u32,
pub output_tokens: u32,
pub server_tool_use: ServerToolUse,
pub service_tier: String,
pub cache_creation: Option<CacheCreationDetails>,
pub inference_geo: Option<String>,
pub iterations: Vec<UsageIteration>,
pub speed: Option<String>,
pub output_tokens_details: Option<OutputTokensDetails>,
}Expand description
Usage information for the request.
These counters are accumulated roll-ups, not snapshots. The CLI sums
usage field-by-field across every API call (“iteration”) in the turn’s
tool-use loop, so on a turn with N iterations each counter is the sum of
all N. This is the right number for cost, and the wrong number for
context occupancy: cache_read_input_tokens in particular re-counts
the cached context on every iteration and can exceed the model’s context
window several times over on tool-heavy turns. To estimate context
occupancy, use the last entry of iterations
instead (the CLI itself does exactly this).
Note: the result frame’s usage covers the main agent only — the
subagent (Task / sidechain) token rollup the CLI renders as
<subagent_tokens> / <agent_count> is not carried here or anywhere
else on the wire. Accumulate it from Task tool results with
SubagentUsageRollup.
Fields§
§input_tokens: u32Sum of fresh (uncached) input tokens across all iterations of the turn.
cache_creation_input_tokens: u32Sum of cache-write input tokens across all iterations of the turn.
cache_read_input_tokens: u32Sum of cache-read input tokens across all iterations of the turn. Re-counts the cached context every iteration — not a measure of context occupancy; see the type-level docs.
output_tokens: u32Sum of output tokens across all iterations of the turn.
server_tool_use: ServerToolUse§service_tier: String§cache_creation: Option<CacheCreationDetails>Cache creation breakdown
inference_geo: Option<String>Inference geography (e.g., “not_available”)
iterations: Vec<UsageIteration>Per-iteration usage breakdown within this turn — one entry per API call in the tool-use loop, in order. The last entry reflects the final API call and is what the CLI reads for context-size estimates.
speed: Option<String>Speed tier (e.g., “standard”)
output_tokens_details: Option<OutputTokensDetails>Output-token breakdown (CLI 2.1.232+): currently the thinking-token
share of output_tokens.