openclaw-cost-tracker
✓Verified·Scanned 2/18/2026
Track OpenClaw usage costs and provide detailed reports by date and model. Supports daily, weekly, and monthly report formats for Discord and other messaging channels.
from clawhub.ai·veb88d56·25.9 KB·0 installs
Scanned from 1.0.2 at eb88d56 · Transparency log ↗
$ vett add clawhub.ai/vincentqiu/openclaw-cost-tracker
OpenClaw Cost Tracker
Accurately track OpenClaw usage costs with detailed reports by date and model.
Features
- ✅ Precisely parse API call costs from OpenClaw session logs
- ✅ Group costs by model type
- ✅ Support daily, weekly, and monthly reports
- ✅ Display cost changes (increase/decrease percentage)
- ✅ Compatible with macOS and Linux
- ✅ Beautiful Discord output format
- ✅ Can be set up as automated cron tasks
Installation
-
Make sure you have the required dependencies:
# macOS brew install jq # Ubuntu/Debian apt install jq bc -
Set script execution permissions:
chmod +x scripts/cost_report.sh
Usage
# Today's cost report
npm start
# Or run the script directly
./scripts/cost_report.sh --today
# Yesterday's cost report
./scripts/cost_report.sh --yesterday
# Weekly cost report
./scripts/cost_report.sh --week
# Date range report
./scripts/cost_report.sh --from 2026-01-01 --to 2026-01-31
# Generate Discord format report
./scripts/cost_report.sh --today --format discord
# Generate JSON format report
./scripts/cost_report.sh --today --format json
Automated Reports (Cron)
See the config/cron-examples.json file to learn how to set up automated report tasks. Use OpenClaw's cron functionality to easily set up daily/weekly cost reports.
Calculation Method
This tool extracts accurate API call cost data directly from OpenClaw session log files, ensuring precise and reliable report results:
- Scan all session JSONL files for records on the target date
- Use jq to parse the
message.usage.cost.totalfield in each record - Group by model and calculate totals
- Avoid data duplication or loss issues caused by session compaction
Notes
- Ensure you have read permissions for the OpenClaw sessions directory
- Processing large session files may take longer
- If costs are 0, it may be because the API provider did not provide cost data
Technical Details
- Uses jq to parse JSON data
- Compatible with macOS and Linux date handling
- Supports cost calculations grouped by model
- Chinese-style color indicators for changes (🔴up / 🟢down)