Case 02609
Track OpenClaw AI token usage and cost per model on Linux by parsing session JSONL files. Use when asked about: token usage, API cost, how much has been spent, which model was used most, usage summary, billing, cost breakdown. Linux replacement for the macOS-only model-usage/CodexBar skill.From its SKILL.md
npx -y skills add knownasnaffy/prompthound --skill case_02609Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
0.9 KB, 147 tokens by cl100k_base, as published. Nobody here has run it
Model Usage (Linux)
Parse OpenClaw session files to summarize token usage and cost per model.
Quick start
python3 {baseDir}/scripts/usage.py
Options
# JSON output
python3 {baseDir}/scripts/usage.py --format json
# Custom sessions dir
python3 {baseDir}/scripts/usage.py --sessions-dir ~/.openclaw/agents/main/sessions
Output
Shows per-model breakdown:
- Turns (assistant replies)
- Input / output tokens
- Cache read / write tokens
- Cost in USD
Sessions live at: ~/.openclaw/agents/main/sessions/*.jsonl
What ships with it: 1 file
4.1 KB alongside SKILL.md, 1 of them executable
scripts/
- usage.pyruns4.1 KB
Gives 0 of the 12 instructions most token cost skills give in 147 tokens
Counted across 84 of the 95 authors here whose files we hold, read 2026-09-06
- Set explicit budget limits before processing batchesin 14 of 84, across 9 files
- Define model names as constants or configin 14 of 84, across 9 files
- Route simple tasks to cheaper modelsin 14 of 84, across 9 files
- Log model selection decisionsin 14 of 84, across 9 files
- Retry only transient errorsin 14 of 84, across 9 files
- Track spend with immutable cost recordsin 13 of 84, across 8 files
- Cache system prompts over 1024 tokensin 12 of 84, across 7 files
- Check the budget before each API callin 12 of 84, across 7 files
- Start with the cheapest modelin 9 of 84, across 8 files
- Back off exponentially between retriesin 9 of 84, across 8 files
- Review costs weeklyin 8 of 84, across 6 files
- Use reserved capacity for steady workloadsin 8 of 84, across 6 files
Said here and by no other author read
- run the usage script with python3
- pass --format json for JSON output
- pass --sessions-dir to override the sessions directory
- report turns, token counts, and cost per model
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.