Cost Tracking
Monitor, analyze, and optimize the cost of your OpenClaw agent operations.
/costOverview#
Cost Tracking gives you per-agent cost attribution with breakdowns by model, task type, and time period. Data is automatically synced from your OpenClaw gateway's session logs.
Features include 7-day trend visualization, rate anomaly alerts (when hourly cost exceeds 3x daily average), and multi-instance grouping for organizations running multiple OpenClaw gateways.
Prerequisites#
- At least one connector synced with agents
- Agents actively running tasks (generating cost data)
- Cost sync interval configured (automatic with connector)
OpenClaw Configuration#
OpenClaw stores per-call cost data in session log files. Each assistant message includes the actual USD cost from the model provider.
Session logs are stored at:
~/.openclaw/agents/{agentId}/sessions/*.jsonlEach JSONL entry contains message.usage.cost.total — the real cost in USD from the provider.
ClawButler Configuration#
Cost data syncs automatically when a connector is active. No manual configuration needed.
For date-based queries, ClawButler uses COALESCE(period_start, created_at) — where period_start holds the actual cost date from OpenClaw, and created_at is the sync timestamp.
Expected Results#
The Cost page displays four sections:
- -Stats Row: Today's cost, this week's total, this month's estimate (weekly × 4.3), and active alert count
- -Rate Anomaly Alerts: Amber banners when hourly cost spikes beyond 3x daily average
- -7-Day Cost Trend: Bar chart showing daily cost with max-height normalization
- -Breakdown Tables: Cost grouped by agent and by task type with horizontal progress bars
Multi-Instance: When connected to multiple OpenClaw gateways, costs are grouped by connector name. A Total row appears at the top showing aggregated costs across all instances.
Web Operations#
Navigate to Cost Tracking from the Insights section in the sidebar.
- -Stats row at the top for quick cost overview
- -Scroll down for the trend chart and breakdown tables
- -Rate anomaly alerts appear between stats and trend when triggered
- -Data refreshes automatically; no manual action needed
CLI Operations#
Show cost summary with optional date range
$ ap cost summary --date-from 2024-01-01 --date-to 2024-01-31Show cost grouped by agent
$ ap cost by-agentShow cost grouped by model
$ ap cost by-modelShow cost grouped by task type
$ ap cost by-task-typeShow cost trend (daily/weekly/monthly)
$ ap cost trend --granularity weekCheck cost data freshness
$ ap cost freshnessMobile Operations#
On mobile, cost data is in the Insights tab (third tab). Select the 'Cost' segment at the top.
- -By Agent / By Model / By Type toggle pills for different views
- -Sparkline chart for cost trends
- -Horizontal bar charts for breakdown views
- -Pull-to-refresh for data updates