pub struct UsageEntry {
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 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: u64§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