Save 78% on LLM costs. Automatically.
Route every request to the cheapest model that can handle it. One wallet, 30+ models, zero API keys.
"What is 2+2?" → DeepSeek 0ドル.27/M saved 99%
"Summarize this article" → GPT-4o-mini 0ドル.60/M saved 99%
"Build a React component" → Claude Sonnet 15ドル.00/M best balance
"Prove this theorem" → DeepSeek-R 0ドル.42/M reasoning
"Run 50 parallel searches"→ Kimi K2.5 2ドル.40/M agentic swarm
- 100% local routing — 14-dimension weighted scoring runs on your machine in <1ms
- Zero external calls — no API calls for routing decisions, ever
- 30+ models — OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot through one wallet
- x402 micropayments — pay per request with USDC on Base, no API keys
- Open source — MIT licensed, fully inspectable routing logic
ClawRouter savings explanation
# 1. Install with smart routing enabled by default curl -fsSL https://raw.githubusercontent.com/BlockRunAI/ClawRouter/main/scripts/reinstall.sh | bash # 2. Fund your wallet with USDC on Base (address printed on install) # 5ドル is enough for thousands of requests # 3. Restart OpenClaw gateway openclaw gateway restart
Done! Smart routing (blockrun/auto) is now your default model.
- Use
/model blockrun/autoin any conversation to switch on the fly - Want a specific model? Use
blockrun/openai/gpt-4oorblockrun/anthropic/claude-sonnet-4 - Already have a funded wallet?
export BLOCKRUN_WALLET_KEY=0x...
The flow:
- Wallet auto-generated on Base (L2) — saved securely at
~/.openclaw/blockrun/wallet.key - Fund with 1ドル USDC — enough for hundreds of requests
- Request any model — "help me call Grok to check @hosseeb's opinion on AI agents"
- ClawRouter routes it — spawns a Grok sub-agent via
xai/grok-3, pays per-request
No API keys. No accounts. Just fund and go.
100% local, <1ms, zero API calls.
Request → Weighted Scorer (14 dimensions)
│
├── High confidence → Pick model from tier → Done
│
└── Low confidence → Default to MEDIUM tier → Done
No external classifier calls. Ambiguous queries default to the MEDIUM tier (DeepSeek/GPT-4o-mini) — fast, cheap, and good enough for most tasks.
| Dimension | Weight | What It Detects |
|---|---|---|
| Reasoning markers | 0.18 | "prove", "theorem", "step by step" |
| Code presence | 0.15 | "function", "async", "import", "```" |
| Simple indicators | 0.12 | "what is", "define", "translate" |
| Multi-step patterns | 0.12 | "first...then", "step 1", numbered lists |
| Technical terms | 0.10 | "algorithm", "kubernetes", "distributed" |
| Token count | 0.08 | short (<50) vs long (>500) prompts |
| Creative markers | 0.05 | "story", "poem", "brainstorm" |
| Question complexity | 0.05 | Multiple question marks |
| Constraint count | 0.04 | "at most", "O(n)", "maximum" |
| Imperative verbs | 0.03 | "build", "create", "implement" |
| Output format | 0.03 | "json", "yaml", "schema" |
| Domain specificity | 0.02 | "quantum", "fpga", "genomics" |
| Reference complexity | 0.02 | "the docs", "the api", "above" |
| Negation complexity | 0.01 | "don't", "avoid", "without" |
Weighted sum → sigmoid confidence calibration → tier selection.
ClawRouter's keyword-based routing works with prompts in:
| Language | Script | Examples |
|---|---|---|
| English | Latin | Full support (default) |
| Chinese (中文) | Han/CJK | 证明, 定理, 你好, 什么是 |
| Japanese (日本語) | Kanji + Kana | 証明, こんにちは, アルゴリズム |
| Russian (Русский) | Cyrillic | доказать, привет, алгоритм |
Mixed-language prompts are supported — keywords from all languages are checked simultaneously.
| Tier | Primary Model | Cost/M | Savings vs Opus |
|---|---|---|---|
| SIMPLE | gemini-2.5-flash | 0ドル.60 | 99.2% |
| MEDIUM | deepseek-chat | 0ドル.42 | 99.4% |
| COMPLEX | claude-opus-4 | 75ドル.00 | baseline |
| REASONING | deepseek-reasoner | 0ドル.42 | 99.4% |
Special rule: 2+ reasoning markers → REASONING at 0.97 confidence.
| Tier | % of Traffic | Cost/M |
|---|---|---|
| SIMPLE | ~45% | 0ドル.27 |
| MEDIUM | ~35% | 0ドル.60 |
| COMPLEX | ~15% | 15ドル.00 |
| REASONING | ~5% | 10ドル.00 |
| Blended average | 3ドル.17/M |
Compared to 75ドル/M for Claude Opus = 96% savings on a typical workload.
30+ models across 6 providers, one wallet:
| Model | Input $/M | Output $/M | Context | Reasoning |
|---|---|---|---|---|
| OpenAI | ||||
| gpt-5.2 | 1ドル.75 | 14ドル.00 | 400K | * |
| gpt-4o | 2ドル.50 | 10ドル.00 | 128K | |
| gpt-4o-mini | 0ドル.15 | 0ドル.60 | 128K | |
| o3 | 2ドル.00 | 8ドル.00 | 200K | * |
| o3-mini | 1ドル.10 | 4ドル.40 | 128K | * |
| Anthropic | ||||
| claude-opus-4.5 | 5ドル.00 | 25ドル.00 | 200K | * |
| claude-sonnet-4 | 3ドル.00 | 15ドル.00 | 200K | * |
| claude-haiku-4.5 | 1ドル.00 | 5ドル.00 | 200K | |
| gemini-2.5-pro | 1ドル.25 | 10ドル.00 | 1M | * |
| gemini-2.5-flash | 0ドル.15 | 0ドル.60 | 1M | |
| DeepSeek | ||||
| deepseek-chat | 0ドル.14 | 0ドル.28 | 128K | |
| deepseek-reasoner | 0ドル.55 | 2ドル.19 | 128K | * |
| xAI | ||||
| grok-3 | 3ドル.00 | 15ドル.00 | 131K | * |
| grok-3-mini | 0ドル.30 | 0ドル.50 | 131K | |
| Moonshot | ||||
| kimi-k2.5 | 0ドル.50 | 2ドル.40 | 128K | * |
Full list: src/models.ts
Kimi K2.5 from Moonshot AI is optimized for agent swarm and multi-step workflows:
- Agent Swarm — Coordinates up to 100 parallel agents, 4.5x faster execution
- Extended Tool Chains — Stable across 200-300 sequential tool calls without drift
- Vision-to-Code — Generates production React from UI mockups and videos
- Cost Efficient — 76% cheaper than Claude Opus on agentic benchmarks
Best for: parallel web research, multi-agent orchestration, long-running automation tasks.
No account. No API key. Payment IS authentication via x402.
Request → 402 (price: 0ドル.003) → wallet signs USDC → retry → response
USDC stays in your wallet until spent — non-custodial. Price is visible in the 402 header before signing.
Fund your wallet:
- Coinbase: Buy USDC, send to Base
- Bridge: Move USDC from any chain to Base
- CEX: Withdraw USDC to Base network
ClawRouter uses one environment variable: BLOCKRUN_WALLET_KEY
| Priority | Source | Behavior |
|---|---|---|
| 1st | Saved file (~/.openclaw/blockrun/wallet.key) |
Used if exists |
| 2nd | BLOCKRUN_WALLET_KEY env var |
Used if no saved file |
| 3rd | Auto-generate | Creates new wallet, saves to file |
Important: The saved file takes priority over the environment variable. If you have both, the env var is ignored.
# Check if a saved wallet exists ls -la ~/.openclaw/blockrun/wallet.key # Use your own wallet (only works if no saved file exists) export BLOCKRUN_WALLET_KEY=0x... # Force use of a different wallet rm ~/.openclaw/blockrun/wallet.key export BLOCKRUN_WALLET_KEY=0x... openclaw restart # See which wallet is active curl http://localhost:8402/health | jq .wallet
The saved file is checked first to ensure wallet persistence across sessions. Once a wallet is generated and funded, you don't want an accidentally-set env var to switch wallets and leave your funds inaccessible.
If you explicitly want to use a different wallet:
- Delete
~/.openclaw/blockrun/wallet.key - Set
BLOCKRUN_WALLET_KEY=0x... - Restart OpenClaw
┌─────────────────────────────────────────────────────────────┐
│ Your Application │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ ClawRouter (localhost) │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
│ │ Weighted Scorer │→ │ Model Selector │→ │ x402 Signer │ │
│ │ (14 dimensions)│ │ (cheapest tier) │ │ (USDC) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ BlockRun API │
│ → OpenAI | Anthropic | Google | DeepSeek | xAI | Moonshot│
└─────────────────────────────────────────────────────────────┘
Routing is client-side — open source and inspectable.
src/
├── index.ts # Plugin entry point
├── provider.ts # OpenClaw provider registration
├── proxy.ts # Local HTTP proxy + x402 payment
├── models.ts # 30+ model definitions with pricing
├── auth.ts # Wallet key resolution
├── logger.ts # JSON usage logging
├── dedup.ts # Response deduplication (prevents double-charge)
├── payment-cache.ts # Pre-auth optimization (skips 402 round trip)
├── x402.ts # EIP-712 USDC payment signing
└── router/
├── index.ts # route() entry point
├── rules.ts # 14-dimension weighted scoring
├── selector.ts # Tier → model selection
├── config.ts # Default routing config
└── types.ts # TypeScript types
# openclaw.yaml plugins: - id: "@blockrun/clawrouter" config: routing: tiers: COMPLEX: primary: "openai/gpt-4o" SIMPLE: primary: "google/gemini-2.5-flash"
routing: scoring: reasoningKeywords: ["proof", "theorem", "formal verification"] codeKeywords: ["function", "class", "async", "await"]
Use without OpenClaw:
import { startProxy } from "@blockrun/clawrouter"; const proxy = await startProxy({ walletKey: process.env.BLOCKRUN_WALLET_KEY!, onReady: (port) => console.log(`Proxy on port ${port}`), onRouted: (d) => console.log(`${d.model} saved ${(d.savings * 100).toFixed(0)}%`), }); // Any OpenAI-compatible client works const res = await fetch(`${proxy.baseUrl}/v1/chat/completions`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ model: "blockrun/auto", messages: [{ role: "user", content: "What is 2+2?" }], }), }); await proxy.close();
Or use the router directly:
import { route, DEFAULT_ROUTING_CONFIG, BLOCKRUN_MODELS } from "@blockrun/clawrouter"; // Build pricing map const modelPricing = new Map(); for (const m of BLOCKRUN_MODELS) { modelPricing.set(m.id, { inputPrice: m.inputPrice, outputPrice: m.outputPrice }); } const decision = route("Prove sqrt(2) is irrational", undefined, 4096, { config: DEFAULT_ROUTING_CONFIG, modelPricing, }); console.log(decision); // { // model: "deepseek/deepseek-reasoner", // tier: "REASONING", // confidence: 0.97, // method: "rules", // savings: 0.994, // costEstimate: 0.002, // }
- SSE heartbeat: Sends headers + heartbeat immediately, preventing upstream timeouts
- Response dedup: SHA-256 hash → 30s cache, prevents double-charge on retries
- Payment pre-auth: Caches 402 params, pre-signs USDC, skips 402 round trip (~200ms saved)
They're built for developers. ClawRouter is built for agents.
| OpenRouter / LiteLLM | ClawRouter | |
|---|---|---|
| Setup | Human creates account | Agent generates wallet |
| Auth | API key (shared secret) | Wallet signature (cryptographic) |
| Payment | Prepaid balance (custodial) | Per-request (non-custodial) |
| Routing | Proprietary / closed | Open source, client-side |
Agents shouldn't need a human to paste API keys. They should generate a wallet, receive funds, and pay per request — programmatically.
💬 Need help? Open a Discussion or check existing issues.
# 1. Check your version (should be 0.3.21+) cat ~/.openclaw/extensions/clawrouter/package.json | grep version # 2. Check proxy is running curl http://localhost:8402/health # 3. Watch routing in action openclaw logs --follow # Should see: gemini-2.5-flash 0ドル.0012 (saved 99%)
Plugin isn't loaded or outdated. Don't change the model name — blockrun/auto is correct.
Fix: Update to v0.3.21+ which handles both blockrun/auto and auto (OpenClaw strips provider prefix). See How to Update ClawRouter.
Auth profile is missing or wasn't created properly.
Fix: See How to Update ClawRouter — the reinstall script automatically injects the auth profile.
Plugin directory was removed but config still references it. This blocks all OpenClaw commands until fixed.
Fix: See How to Update ClawRouter for complete cleanup steps.
Wallet needs funding.
Fix:
- Find your wallet address (printed during install)
- Send USDC on Base network to that address
- 1ドル-5 is enough for hundreds of requests
- Restart OpenClaw
OpenClaw's security scanner may flag ClawRouter with:
[env-harvesting] Environment variable access combined with network send
This is a false positive. ClawRouter reads BLOCKRUN_WALLET_KEY to sign x402 payment transactions — this is required and intentional:
- The wallet key is used locally for cryptographic signing (EIP-712)
- The signature is transmitted, not the private key itself
- This is standard x402 payment protocol behavior
- Source code is MIT licensed and fully auditable
See openclaw.security.json for detailed security documentation.
lsof -i :8402
# Kill the process or restart OpenClawcurl -fsSL https://raw.githubusercontent.com/BlockRunAI/ClawRouter/main/scripts/reinstall.sh | bash
openclaw gateway restartThis removes the old version, installs the latest, and restarts the gateway.
openclaw logs --follow
You should see model selection for each request:
[plugins] [SIMPLE] google/gemini-2.5-flash 0ドル.0012 (saved 99%)
[plugins] [MEDIUM] deepseek/deepseek-chat 0ドル.0003 (saved 99%)
[plugins] [REASONING] deepseek/deepseek-reasoner 0ドル.0005 (saved 99%)
git clone https://github.com/BlockRunAI/ClawRouter.git cd ClawRouter npm install npm run build npm run typecheck # End-to-end tests (requires funded wallet) BLOCKRUN_WALLET_KEY=0x... npx tsx test-e2e.ts
- Smart routing — 14-dimension weighted scoring, 4-tier model selection
- x402 payments — per-request USDC micropayments, non-custodial
- Response dedup — prevents double-charge on retries
- Payment pre-auth — skips 402 round trip
- SSE heartbeat — prevents upstream timeouts
- Cascade routing — try cheap model first, escalate on low quality
- Spend controls — daily/monthly budgets
- Analytics dashboard — cost tracking at blockrun.ai
MIT
BlockRun — Pay-per-request AI infrastructure
If ClawRouter saves you money, consider starring the repo.