token-optimizerReduce OpenClaw AI costs by 97%. Haiku model routing, free Ollama heartbeats, prompt caching, and budget controls. Go from $1,500/month to $50/month in 5 min...
Install via ClawdBot CLI:
clawdbot install smartpeopleconnected/token-optimizerSlash your AI costs from $1,500+/month to under $50/month.
OpenClaw defaults prioritize capability over cost. You're burning expensive Sonnet/Opus tokens on tasks Haiku handles perfectly, paying for API heartbeats that could run free locally, and loading 50KB of context when 8KB suffices.
Four core optimizations plus powerful tooling:
Haiku by default, Sonnet/Opus only when needed
Route heartbeats to Ollama, LM Studio, Groq, or disable entirely. Not locked to one provider.
Load 8KB instead of 50KB context
Reuse prompts at 10% cost
| Period | Before | After |
|--------|--------|-------|
| Daily | $2-3 | $0.10 |
| Monthly | $70-90 | $3-5 |
| Yearly | $800+ | $40-60 |
All changes are written under ~/.openclaw/. A backup is created before any modification.
| Path | Purpose |
|------|---------|
| ~/.openclaw/openclaw.json | Main OpenClaw config (model routing, heartbeat, budgets) |
| ~/.openclaw/backups/ | Timestamped config backups (created automatically) |
| ~/.openclaw/workspace/ | Template files (SOUL.md, USER.md, IDENTITY.md) |
| ~/.openclaw/prompts/ | Agent prompt optimization rules |
| ~/.openclaw/token-optimizer-stats.json | Usage stats for savings reports |
Safe by default - All commands run in dry-run (preview) mode. Pass --apply to write changes.
# Install
clawhub install token-optimizer
# Analyze current setup
python cli.py analyze
# Preview changes (dry-run by default)
python cli.py optimize
# Apply all optimizations
python cli.py optimize --apply
# Verify setup
python cli.py verify
# Quick health check
python cli.py health
# Configure heartbeat provider (preview)
python cli.py setup-heartbeat --provider ollama
# Configure heartbeat provider (apply)
python cli.py setup-heartbeat --provider ollama --apply
# List and restore backups
python cli.py rollback --list
python cli.py rollback --to <backup-file>
{
"agents": {
"defaults": {
"model": { "primary": "anthropic/claude-haiku-4-5" },
"cache": { "enabled": true, "ttl": "5m" }
}
},
"heartbeat": {
"provider": "ollama",
"model": "ollama/llama3.2:3b"
},
"budgets": {
"daily": 5.00,
"monthly": 200.00
}
}
Smart People Connected
MIT License - Free to use, modify, and distribute.
5 minutes to setup. 97% cost reduction. Stop burning tokens. Start building.
Generated Mar 1, 2026
A tech startup uses OpenClaw for rapid prototyping and AI agent development, facing high API costs from frequent testing and iterations. This tool reduces expenses by routing tasks to cheaper models and caching prompts, enabling more experiments within a tight budget.
University researchers employ OpenClaw for data analysis and natural language processing experiments, struggling with token usage from large-scale simulations. By implementing model routing and free Ollama heartbeats, they cut costs significantly while maintaining research quality.
A small e-commerce business automates customer support and content generation with OpenClaw, but high token costs from daily operations strain their budget. The optimizer helps by setting daily spending limits and reusing cached responses, making automation affordable.
A freelance developer offers AI-powered services using OpenClaw for clients, where unpredictable token usage leads to variable costs. This package provides budget controls and efficient model selection, ensuring consistent profitability and client satisfaction.
A large corporation integrates OpenClaw into internal tools for tasks like report generation and data processing, facing escalating API bills from widespread use. The tool's session management and caching features optimize resource usage across departments, achieving major savings.
Offer a basic free version with core optimizations like model routing and caching, then charge for advanced features such as detailed analytics, priority support, and custom budget templates. This attracts users with cost savings and upsells value-added services.
Provide paid consulting services to help businesses integrate and customize the optimizer for their specific OpenClaw setups, including training and ongoing optimization audits. This leverages expertise to ensure maximum cost reduction and efficiency.
Distribute the tool as open-source under the MIT license to build a community, then generate revenue by offering enterprise support packages, including guaranteed updates, security patches, and dedicated assistance for large-scale deployments.
💬 Integration Tip
Start by running the analyze command to assess current costs, then use optimize with --apply only after reviewing changes in dry-run mode to ensure compatibility with existing workflows.
Transform AI agents from task-followers into proactive partners that anticipate needs and continuously improve. Now with WAL Protocol, Working Buffer, Autonomous Crons, and battle-tested patterns. Part of the Hal Stack 🦞
Use the ClawdHub CLI to search, install, update, and publish agent skills from clawdhub.com. Use when you need to fetch new skills on the fly, sync installed skills to latest or a specific version, or publish new/updated skill folders with the npm-installed clawdhub CLI.
Clawdbot documentation expert with decision tree navigation, search scripts, doc fetching, version tracking, and config snippets for all Clawdbot features
Interact with Moltbook social network for AI agents. Post, reply, browse, and analyze engagement. Use when the user wants to engage with Moltbook, check their feed, reply to posts, or track their activity on the agent social network.
OpenClaw CLI wrapper — gateway, channels, models, agents, nodes, browser, memory, security, automation.
MoltGuard — runtime security plugin for OpenClaw agents by OpenGuardrails. Helps users install, register, activate, and check the status of MoltGuard. Use wh...