Back to Home

ClawRouter: LLM routing to reduce API costs

ClawRouter — open source router for LLM API, classifying prompts by 15 parameters and selecting cheap models. Savings up to 95% with local operation. Support for fallbacks and session pinning.

Save 95% on LLM API with ClawRouter router
Advertisement 728x90

Optimizing LLM API Costs with ClawRouter: Intelligent Request Routing by Complexity

Developers often overpay for powerful models like Claude Sonnet when handling simple tasks: renaming variables, writing docstrings, or translating text. ClawRouter solves this by classifying prompts based on complexity and routing them to the appropriate model. During a week of testing, API costs dropped from $47 to $1.80 while maintaining response quality.

The router operates locally, without external calls for classification. Each request is evaluated across 15 parameters: prompt length, code presence, reasoning markers ("prove," "analyze"), tool use, and agent commands ("run," "edit"). Based on the scoring, the prompt is assigned to one of four tiers: SIMPLE, MEDIUM, COMPLEX, REASONING. A cost-effective model is then selected for that tier.

Routing examples:

Google AdInline article slot
Your request: "What is a mutex?"
  → Scorer: SIMPLE (0.92 confidence)
  → Model: NVIDIA gpt-oss-120b (free)
  → Savings: 100%

Your request: "Rewrite this React component using hooks and add error handling"
  → Scorer: COMPLEX (0.85 confidence)
  → Model: GPT-4o ($2.50/$10.00 per 1M)
  → Savings: ~60% vs Opus

Your request: "Prove that sqrt(2) is irrational"
  → Scorer: REASONING (0.97 confidence)
  → Model: DeepSeek Reasoner ($0.55/$2.19)
  → Savings: ~90% vs Opus

Installation and Payment

Install via script or npm:

curl -fsSL https://blockrun.ai/ClawRouter-update | bash

# Or
npm install -g @blockrun/clawrouter

Payment is via USDC on the Base network (Ethereum L2). A local wallet is created automatically; a $5 top-up covers thousands of requests. A key advantage for AI agents: no need for accounts or cards. For developers, the barrier is a 15–20 minute setup for a crypto wallet.

Four routing profiles:

Google AdInline article slot
  • auto: balance of price and quality.
  • eco: savings up to 95%.
  • premium: quality priority.
  • free: only free models like NVIDIA gpt-oss-120b.

Key Features

  • Fallbacks: automatic switch to the next model on errors (rate limit, 500).
  • Session pinning: model fixation for a dialogue session.
  • Fallback to free-tier: seamless switch to a free model if the wallet is empty.

The classifier is rule-based: fast (<1 ms), predictable, but may underperform on edge cases compared to ML routers (e.g., a short prompt with O(n log n) sorting classified as SIMPLE).

Alternative Comparisons

| Solution | Routing Type | Availability | Features |

|-------------|-----------------|----------------------|--------------------------------------|

Google AdInline article slot

| OpenRouter | Aggregator | Cloud, card payment | Manual model selection, low barrier |

| RouteLLM | ML classifier| Open source | Requires deployment and training |

| Martian | ML with quality prediction | Enterprise | Closed-source, for business |

| ClawRouter | Rule-based | Open source, local| Crypto payment, ready out-of-the-box |

According to ICLR 2025 data, RouteLLM maintains 95% of GPT-4 quality while routing only 14% of requests to it (saving 75–85%).

Limitations

  • Rule-based scorer: errors on edge cases.
  • Crypto-only payment: no card support.
  • No post-checking quality: a cheap model may provide a weak response without retry.
  • Young project: sparse documentation, support via Telegram.

Key Takeaways

  • Savings up to 95% by routing simple tasks to cost-effective models.
  • Local classification without delays or external API calls.
  • Automatic fallbacks and session-based model pinning.
  • Suitable for pet projects and AI agents with crypto wallets.
  • Rule-based approach: fast but requires tuning for edge cases.

— Editorial Team

Advertisement 728x90

Read Next