Monitor and analyze OpenClaw token usage across sessions. Shows models used, token counts (input/output/cache), daily trends, and hourly breakdowns. Use when the user asks about token usage, API consumption, cost tracking, model usage stats, token trends, or how many tokens have been used. Triggers: token usage, 用量, token统计, 消耗, cost, 花费, model usage, API usage.
Monitor and analyze OpenClaw token usage across sessions. Shows models used, token counts (input/output/cache), daily trends, and hourly breakdowns. Use when the user asks about token usage, API consumption, cost tracking, model usage stats, token trends, or how many tokens have been used. Triggers: token usage, 用量, token统计, 消耗, cost, 花费, model usage, API usage.
Mike
未分类communityv1.0.01 版本100000Key: 无需
★ 1
Stars
📥 164
下载
💾 1
安装
1
版本
#latest
概述
Token Usage Monitor
Analyze OpenClaw session token usage from JSONL session files.
# Last 7 days (default)
python3 scripts/analyze_tokens.py
# Last 30 days
python3 scripts/analyze_tokens.py --days 30
# All time, JSON output
python3 scripts/analyze_tokens.py --days 0 --json
# Top 5 models
python3 scripts/analyze_tokens.py --top 5
What It Shows
Overview — Total API calls, input/output/cache tokens, average per call
By Model — Token breakdown per model with percentage share
Daily Trend — Day-by-day token consumption with visual bars
Hourly Breakdown — Usage distribution for the latest active day
Data Source
Reads from ~/.openclaw/agents//sessions/.jsonl — all agent session files. Each assistant message includes a usage object with input, output, cacheRead, cacheWrite, totalTokens, and cost fields.
Notes
Cost is $0.00 if the provider doesn't return pricing (e.g., some local/custom providers)
The script aggregates across ALL agents (main, sub-agents, etc.)
Timestamps are in UTC; daily grouping uses UTC dates