Cost Optimizer
> Built by GetAgentIQ — [getagentiq.ai](https://getagentiq.ai)
Track, analyze, and optimize your OpenClaw API costs. Stop overpaying for simple tasks.
Quick Start
# Analyze current session costs
python3 scripts/cost-optimizer.py status
# Estimate cost for a task before running it
python3 scripts/cost-optimizer.py estimate --task "summarize a 2000-word article" --model claude-sonnet-4-20250514
# Get model recommendation for a task type
python3 scripts/cost-optimizer.py recommend --task-type simple
# Show cost comparison across models
python3 scripts/cost-optimizer.py compare
# Project monthly costs from current usage
python3 scripts/cost-optimizer.py project --days 7
# Set a budget alert
python3 scripts/cost-optimizer.py budget --daily 5.00 --monthly 150.00
How It Works
1. Track — Log token counts and model used per task
2. Analyze — Categorize tasks by complexity and map to optimal models
3. Recommend — Suggest the cheapest model that meets quality requirements
4. Alert — Warn before budget limits are hit
Task Complexity Classification
| Complexity | Examples | Recommended Model |
|------------|----------|-------------------|
| Simple | Formatting, search, short replies, reactions | Haiku / GPT-4o-mini / Gemini Flash |
| Medium | Summarization, code review, analysis | Sonnet / GPT-4o / Gemini Pro |
| Complex | Architecture, security audit, strategic planning | Opus / o1 / Gemini Ultra |
| Trivial | Heartbeats, status checks, file reads | Haiku / local Ollama |
Model Pricing (March 2026)
See references/model-pricing.md for full pricing table with input/output token rates.
Budget Management
Track spend against configurable limits. Integrates with SOUL.md budget caps if present.
# Check budget status
python3 scripts/cost-optimizer.py budget --status
# Output:
# Daily: $2.34 / $5.00 (46.8%) ██████████░░░░░░░░░░
# Monthly: $47.20 / $180.00 (26.2%) █████░░░░░░░░░░░░░░
# Trend: $4.71/day avg → projected $141.30/month ✅ Under budget
Parameters
| Command | Description |
|---------|-------------|
| status | Show current session/daily/monthly spend |
| estimate | Estimate cost for a described task |
| recommend | Get cheapest suitable model for task type |
| compare | Side-by-side model cost comparison |
| project | Project monthly cost from recent usage |
| budget | Set or check budget limits |
| log | Log a completed task's token usage |
| report | Generate cost report (text/json/markdown) |
Integration
- Reads SOUL.md for existing budget caps
- Works alongside
claw-api-manager(internal budget enforcement) - JSON output for cron-based monitoring
- Can recommend model switches mid-conversation