pub struct UsageEntry {Show 14 fields
pub session_id: String,
pub timestamp_ms: u64,
pub model: String,
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_read_tokens: u64,
pub cache_write_tokens: u64,
pub cache_write_1h_tokens: u64,
pub web_search_requests: u64,
pub speed: Option<String>,
pub tool_uses: Vec<String>,
pub text_chars: u32,
pub activity: Activity,
pub entrypoint: Option<String>,
}Expand description
Flat row representing a single completed assistant turn.
One entry per unique message.id. Claude Code writes multiple JSONL
entries per assistant message as the stream progresses (typically 2-3),
all sharing the same id and final usage numbers — dedup keeps only the
first occurrence.
Token field semantics (inherited from Anthropic’s API):
input_tokens: fresh tokens in this turn’s prompt that were NOT served from cache. Small when conversation is reused, large on cache misses.cache_read_tokens: tokens served from the prompt cache (cheap).cache_write_tokens: tokens written into the prompt cache (~25% premium).output_tokens: tokens generated by the model.
“Total context sent” for a turn = input + cache_read + cache_write.
Fields§
§session_id: String§timestamp_ms: u64Unix epoch ms from the JSONL timestamp field. 0 if unparseable.
model: String§input_tokens: u64§output_tokens: u64§cache_read_tokens: u64§cache_write_tokens: u64Total cache-write (creation) tokens for this turn: max(legacy flat cache_creation_input_tokens, ephemeral_5m + ephemeral_1h). The 1-hour
subset is broken out separately in cache_write_1h_tokens for pricing;
this total still drives cache-hit % and token displays.
cache_write_1h_tokens: u64The 1-hour-TTL portion of cache_write_tokens (from
usage.cache_creation.ephemeral_1h_input_tokens). Billed at 2× input
vs the 5-minute tier’s 1.25×. The 5-minute portion is the remainder.
web_search_requests: u64Anthropic web-search server-tool requests this turn
(usage.server_tool_use.web_search_requests). Billed flat at $0.01 each.
speed: Option<String>usage.speed: "standard" or "fast". Some("fast") applies the
fast-mode cost multiplier (see fast_multiplier_for_model). None on
rows that predate the field.
tool_uses: Vec<String>Names of tools this turn invoked (from tool_use content blocks).
Empty for pure-text turns. Duplicates preserved when the model called
the same tool multiple times in one turn.
text_chars: u32Sum of text content block character counts for this turn. Zero means
a silent tool-only turn; non-zero means the model said something.
activity: ActivityClassified activity category (Coding, Debugging, Exploration, …).
See the crate::activity module for the decision tree.
entrypoint: Option<String>JSONL entrypoint field captured from the first row of each message id.
"cli" = interactive Claude Code session. "sdk-cli" = headless
claude -p spawn (any Agent SDK consumer lands here). None for legacy
rows that predate the field. Useful for distinguishing interactive vs.
headless usage; also load-bearing once Anthropic splits Agent SDK
billing from interactive plans (announced June 2026).
Trait Implementations§
Source§impl Clone for UsageEntry
impl Clone for UsageEntry
Source§fn clone(&self) -> UsageEntry
fn clone(&self) -> UsageEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more