The Problem: AI Agents Are Expensive When Every Request Goes to the Best Model
If you run an AI agent on OpenClaw, you know the pattern: cron jobs checking your inbox, subagents triaging issues, background tasks filing reports — all hitting the same top-tier model. But most of those requests are simple. A "check my inbox" cron job doesn't need the same horsepower as "architect a distributed system."
The result? You're paying Opus prices for Haiku-level work. Across hundreds of daily requests, that adds up fast.
The Solution: ibl.ai OpenClaw Router
Today we're open-sourcing the ibl.ai OpenClaw Router — a zero-dependency Node.js proxy that sits between OpenClaw and the Anthropic API, automatically routing each request to the cheapest Claude model that can handle it.
It works by scoring every request across 14 dimensions — token count, code presence, reasoning complexity, technical depth, and more — in under 1 millisecond. Based on that score, it routes to one of three tiers:
- LIGHT → Haiku ($1/$5 per 1M tokens) — simple queries, relays, status checks
- MEDIUM → Sonnet ($3/$15 per 1M tokens) — structured tasks, issue creation, triage
- HEAVY → Opus ($15/$75 per 1M tokens) — deep reasoning, architecture, analysis
Everything runs locally on your server. No data is sent to ibl.ai or any third party. The router is a localhost proxy that forwards directly to Anthropic using your own API key.
Real Cost Savings
Based on typical OpenClaw agent workloads over 30 days:
| Workload | Without Router | With Router | Saved |
|---|---|---|---|
| Cron jobs (alerts, inbox checks) | $121.63 | $24.33 | $97.31 (80%) |
| Subagent tasks (triage, comms) | $58.20 | $11.64 | $46.56 (80%) |
| Deep reasoning (strategy, analysis) | $25.00 | $25.00 | $0.00 |
| Total | $204.83 | $60.97 | $143.87 (70%) |
The key insight: roughly 85% of agent traffic is simple relays or structured tasks that don't need the most capable model. The router makes that distinction automatically, routing only the ~15% of genuinely complex requests to Opus.
How It Works
The router uses a 14-dimension weighted scoring system inspired by ClawRouter. It evaluates each request across dimensions like:
- Token count — longer contexts may need more capable models
- Code presence — code generation benefits from stronger models
- Reasoning markers — words like "analyze," "synthesize," "prove" push toward Opus
- Simple indicators — phrases like "what time" or "check status" push toward Haiku
- Agentic patterns — multi-step workflows route to capable models
The scoring is configurable through a config.json file that hot-reloads without restart. You can tune keyword lists, dimension weights, and tier boundaries to match your specific workload.
A critical design decision: the router scores only user messages, not the system prompt. OpenClaw sends a large, keyword-rich system prompt with every request — scoring it would inflate every request to the most expensive tier.
Install in 30 Seconds
The fastest way — just tell your OpenClaw agent:
Install iblai-router from the OpenClaw Router GitHub repository
Or from the command line:
git clone https://github.com/iblai/iblai-openclaw-router.git router
cd router && bash scripts/install.sh
That's it. iblai-router/auto is now available as a model in OpenClaw. Use it for cron jobs, subagents, and background tasks where cost savings compound:
/config set agents.defaults.subagents.model iblai-router/auto
Works Beyond Anthropic
While the default configuration routes between Claude models, the scoring engine is model-agnostic. You can swap in models from any provider via OpenRouter:
{
"models": {
"LIGHT": "google/gemini-2.0-flash-lite",
"MEDIUM": "anthropic/claude-sonnet-4-20250514",
"HEAVY": "openai/o3"
}
}
Mix and match providers to find the most cost-effective combination for your workload.
Built for the OpenClaw Community
We built this router because we use OpenClaw ourselves and wanted a simple, transparent way to manage costs without sacrificing quality where it matters. The entire router is ~250 lines of JavaScript with zero dependencies — easy to audit, fork, and extend.
The project is MIT-licensed and available on GitHub. We welcome contributions, whether that's new scoring dimensions, support for additional providers, or improvements to the routing logic.
If you're running OpenClaw agents in production, give the router a try. Check your savings anytime with:
curl -s http://127.0.0.1:8402/stats | python3 -m json.tool
Get Started
- GitHub: github.com/iblai/iblai-openclaw-router
- OpenClaw: openclaw.ai
- ibl.ai: ibl.ai
Stop paying Opus prices for Haiku-level work. Let the router handle it.