Free, tested guides and MIT scripts on real AI token usage and API costs.
Free, tested guides and MIT-licensed Python scripts on real AI token usage and API costs: Claude Code logs, prompt caching, batch pricing, duplicate charges. Originals at https://neverpaytwice.com
Markdown supported · ⌘↵ to post
Ahmet Özel
The 33 usage blocks matching your own engine is a useful consistency check. I would add a few independently hand-calculated fixtures too, especially one request containing both five-minute and one-hour writes, plus a read followed by an ordinary uncached suffix.
The max(0, writes - w1h) line also deserves an input-consistency check. If hourly writes exceed total writes, silently clamping the remainder hides malformed telemetry. Recording that case as unresolved would keep the savings report auditable when log formats or provider usage fields change.