token-burn

Calculate token usage and costs from pi and OpenClaw session JSONL files.

Updated Nov 7, 2024
One-click install
npx skills add https://github.com/jeremysball/dotfiles --skill token-burn-jeremysball
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: token-burn
Source: https://github.com/jeremysball/dotfiles/tree/main/.pi/skills-archive/token-burn
Command: npx skills add https://github.com/jeremysball/dotfiles --skill token-burn-jeremysball

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? LLM session logs accumulate across many JSONL files with no easy way to see total token consumption or estimate API costs. This Skill aggregates token usage (including cached tokens) across sessions and models, producing readable reports and cost estimates. ## Core Features & Use Cases - Token Aggregation: Streams JSONL session files line-by-line and sums input, output, cacheRead, and cacheWrite tokens grouped by model. - OpenClaw Event Support: Handles model_change, thinking_level_change, and model-snapshot events to correctly attribute tokens across model switches. - Cost Estimation: Applies built-in per-model pricing tables (Claude, GPT, Gemini, Kimi, GLM, DeepSeek) to compute dollar costs, with JSON output for automation. - Use Case: Run it against ~/.pi/agent/sessions recursively to see that one model consumed 251M tokens and estimate the associated spend. ## Quick Start Ask the assistant to run the token-burn script on your session directory to generate a token usage and cost report.

Frequently Asked Questions about token-burn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I calculate token usage from OpenClaw session files?

Run the token_burn.py script against a session file or directory of JSONL files. It streams each line, extracts usage data from message events, and reports totals per model plus grand totals.

How to estimate LLM API costs from token counts?

The script includes a built-in pricing table for Claude, GPT, Gemini, Kimi, GLM, and DeepSeek models with separate rates for input, output, cache read, and cache write. It multiplies token counts by per-million-token prices to produce dollar estimates.

Does token-burn support cached tokens like cacheRead and cacheWrite?

Yes, it extracts cacheRead and cacheWrite fields from message usage metadata alongside standard input and output tokens. Cache read is priced at roughly 90% off and cache write at about 25% above regular input rates.

Can token-burn process large JSONL files without running out of memory?

Yes, it streams files line-by-line using buffered reads instead of loading entire files into memory. The --recursive flag also lets it process whole directory trees of session files.

What output formats does token-burn support?

It produces an emoji-formatted terminal report by default and a structured JSON output via the --json flag. The JSON includes per-model token counts, cost breakdowns, and grand totals for automation pipelines.