Install
openclaw skills install token-cost-monitorMonitor OpenClaw API costs in real-time, set budget alerts, and optimize model spending. Track token usage by session and model, get cost optimization tips,...
openclaw skills install token-cost-monitorMonitor OpenClaw API costs in real-time, set budget alerts, and optimize model spending.
Real user stories:
Check current session costs:
# View token usage and estimated cost
openclaw /status
openclaw /usage
Set up cost alerts:
# Alert when daily spend exceeds $10
echo "Alert if daily_cost > $10"
# Alert when monthly spend exceeds $100
echo "Alert if monthly_cost > $100"
Use cheaper models for simple tasks:
Routing rules:
Simple queries (weather, facts) → Haiku
Complex analysis → Sonnet
Creative writing → Opus (only if needed)
Reduce token waste:
Common mistake:
❌ Every 30 min: "Is it daytime yet?" → $18.75/night
✅ Every 6 hours: Check emails + calendar → $2/day
Best practices:
| Category | Tokens | Cost |
|---|---|---|
| Heartbeat checks | 50,000 | $0.50 |
| Web searches | 100,000 | $1.00 |
| Code generation | 200,000 | $2.00 |
| Document analysis | 150,000 | $1.50 |
| Total | 500,000 | $5.00/day |
Daily average: $5.00
Monthly projection: $150.00
Budget limit: $100.00
⚠️ Warning: Will exceed budget by $50
Daily limit: $1.00
Alert at: $0.80/day
Actions: Reduce heartbeat frequency, use Haiku more
Daily limit: $2.50
Alert at: $2.00/day
Actions: Optimize context, review model routing
Daily limit: $10.00
Alert at: $8.00/day
Actions: Audit all automations, implement strict routing
# Get current session stats
openclaw /status
# Get detailed usage breakdown
openclaw /usage --detailed
# Last 7 days cost trend
echo "Analyze spending trend for past 7 days"
# Identify most expensive tasks
echo "What are my top 5 most expensive task types?"
# Alert if spending is 2x normal
echo "Alert if hourly_cost > 2 * average_hourly_cost"
# Send daily cost summary to Slack
curl -X POST https://hooks.slack.com/services/YOUR/WEBHOOK/URL \
-d '{"text": "Daily OpenClaw cost: $5.00 (Budget: $10.00)"}'
# Send weekly cost report via email
echo "Weekly cost report: $35.00 total, $5.00/day average" | mail -s "OpenClaw Cost Report" user@example.com
#!/bin/bash
# Pause session if daily cost exceeds limit
DAILY_LIMIT=10
CURRENT_COST=$(get_current_cost)
if (( $(echo "$CURRENT_COST > $DAILY_LIMIT" | bc -l) )); then
echo "⚠️ Daily cost ($CURRENT_COST) exceeds limit ($DAILY_LIMIT)"
echo "Pausing non-essential automations..."
# Add pause logic here
fi
#!/bin/bash
# Route queries to appropriate model based on complexity
QUERY="$1"
WORD_COUNT=$(echo "$QUERY" | wc -w)
if [ $WORD_COUNT -lt 20 ]; then
echo "Using Haiku (simple query)"
MODEL="haiku"
elif [ $WORD_COUNT -lt 100 ]; then
echo "Using Sonnet (medium complexity)"
MODEL="sonnet"
else
echo "Using Opus (complex analysis)"
MODEL="opus"
fi
Agent keeps calling itself → 1000s of API calls → $100+ in hours
Fix: Implement loop detection and limits
Every tool output saved to context → Context grows → Each call costs more
Fix: Only store essential information
Using Opus for weather queries → 60x more expensive than needed
Fix: Implement model routing
Heartbeat every 5 minutes → 288 calls/day → $50+/day
Fix: Use 4-6 hour intervals
| Model | Input | Output | Best For |
|---|---|---|---|
| Haiku | $0.25/1M | $1.25/1M | Simple queries, facts |
| Sonnet | $3/1M | $15/1M | General tasks |
| Opus | $15/1M | $75/1M | Complex analysis |
| Model | Input | Output | Best For |
|---|---|---|---|
| GPT-4o Mini | $0.15/1M | $0.60/1M | Simple queries |
| GPT-4o | $2.5/1M | $10/1M | General tasks |
| o1 | $15/1M | $60/1M | Complex reasoning |
| Model | Input | Output | Best For |
|---|---|---|---|
| Flash | $0.075/1M | $0.30/1M | Simple queries |
| Pro | $1.25/1M | $5/1M | General tasks |
| Ultra | $7.5/1M | $30/1M | Complex analysis |
Calculate if automation is worth it:
Manual task time: 30 minutes
Your hourly rate: $50/hour
Manual cost: $25 per task
Automation cost:
- API calls: $0.50
- Setup time (amortized): $5.00
- Total: $5.50 per task
Savings: $25 - $5.50 = $19.50 per task
ROI: 355%