Cost evidence
Claude Code Token Usage Logs
How to read Claude Code token fields in transcripts and telemetry, estimate cost, and avoid treating local estimates as invoices.
Cost boundary
Usage fields are estimates
Per-turn usage fields are useful for review and anomaly detection, but official billing remains the source of truth.
Cache effect
Cache reads price differently
A cost review should separate base input, cache writes, cache reads, and output tokens instead of collapsing them into one number.
"MTok = Million tokens"
Where Token Usage Appears
Claude Code and Agent SDK workflows can expose token usage in several places: structured CLI output, SDK result messages, monitoring events, and local transcript records. The local JSONL transcript is useful because assistant message records often carry usage fields near the turn that produced them.
Do not assume every transcript line has usage. In real local samples checked for this build, usage appeared on assistant message records, while user messages, metadata, attachments, and queue records had different shapes. A parser should aggregate only numeric usage fields it actually finds.
Fields To Separate
A useful token review separates base input tokens, cache creation input tokens, cache read input tokens, and output tokens. It should also preserve model, timestamp, request ID, session ID, line number, and any unknown usage keys so later reviewers can trace the estimate back to raw evidence.
Cache fields matter because pricing differs by category. A session with heavy cache reads can look huge by raw token count while costing less than the same number of uncached input tokens. A session with repeated cache writes can have the opposite profile.
- Base input tokens: prompt and context charged at the model input rate.
- Cache creation tokens: context written into prompt cache, often priced above base input.
- Cache read tokens: cached context retrieved, priced below base input.
- Output tokens: model response tokens, usually the highest per-token category.
Estimate, Not Invoice
Use transcript-derived cost estimates for engineering questions: did a run loop, which turn was expensive, did cache behavior dominate, and did the session produce a useful result? Do not use local estimates to bill customers, charge departments, or make irreversible financial decisions.
Pricing can also vary by model release, provider, region, prompt caching duration, batch processing, data residency, and product plan. Record the pricing table date beside any exported analysis.
A Practical Review Workflow
Start with the free Claude Code token usage analyzer to find total tokens, estimated cost, and top expensive turns. Then open the raw transcript or session log viewer for those line numbers. Finally, compare the result with the work outcome, repository diff, CI output, and official billing portal if money is the decision point.
For dashboard-level monitoring, aggregate the same categories into OpenTelemetry metrics and logs. For one-off review, a local transcript plus an exported CSV is usually enough.
Primary sources
Sources behind this page
Anthropic
Track cost and usage
Explains per-step usage, model usage, session scoping, and the client-side nature of SDK cost estimates.
Anthropic
Claude pricing
Official model pricing table for input, output, cache write, and cache read tokens. Used by the token analyzer as a dated estimate table.
Anthropic
Claude Code monitoring
Reference for Claude Code metric names, event analysis, identity attributes, MCP audit detail, and retry analysis.
Anthropic
Manage sessions
Documents Claude Code transcript storage under ~/.claude/projects/<project>/<session-id>.jsonl and cautions that the entry format is internal and can change.
Cite this page
Claude Logs. "Claude Code Token Usage Logs." claudelogs.com, updated 2026-07-06. https://claudelogs.com/token-usage
FAQ
Can a Claude Code transcript prove the exact bill?
No. It can support an estimate and explain turn-level behavior. Official billing and provider invoices remain authoritative for money decisions.
Why does the analyzer ask for a pricing date?
Model pricing changes over time. A dated table lets a reviewer understand which rates were used for a local estimate.
Related evidence
Bibliography
Sources
Annotated source list for Claude Code session logs, Agent SDK session storage, hooks, telemetry, and general log-management guidance.
Foundation
Session Logs
A source-grounded explanation of Claude Code and Agent SDK session logs, what they contain, and what they do not prove.
Field guide
Transcript Anatomy
How to read Claude JSONL transcript artifacts, hook transcript paths, subagent transcript paths, and stream-json output without mixing them up.
Free tool
Log Viewer
Drop a Claude Code JSONL transcript and turn it into a readable local timeline of messages, tool calls, tool results, and token fields.
Free tool
Token Analyzer
Estimate Claude Code transcript token usage and cost by turn with a dated model pricing table and CSV export.
Free tool
Audit Checklist
Run an interactive agent-session audit checklist and export a concise Markdown note for PRs, incidents, and handoffs.