🦞 ClawRouter:智能 LLM 路由器,自动省 78% 推理成本
你是否在多个 AI 模型之间纠结?用 Claude 太贵,用便宜模型又怕质量不够?ClawRouter 来解决这个问题——它会根据你的请求自动选择最便宜且能胜任的模型,号称能帮你省下 78% 的 LLM 推理成本。
📌 项目简介
ClawRouter 是一个智能 LLM 路由器,核心功能是:根据请求复杂度,自动将请求路由到最便宜且能处理的模型。它支持 30+ 个模型(OpenAI、Anthropic、Google、DeepSeek、xAI、Moonshot),使用 x402 微支付协议,一个钱包搞定所有模型,无需管理多个 API Key。
🔗 开源地址:https://github.com/BlockRunAI/ClawRouter
📦 NPM 包:@blockrun/clawrouter
🎯 核心亮点
- ✅ 100% 本地路由:14 维加权评分,本地运行 <1ms,无外部 API 调用
- ✅ 30+ 模型支持:OpenAI、Anthropic、Google、DeepSeek、xAI、Moonshot
- ✅ x402 微支付:一个钱包搞定所有模型,按请求付费,非托管
- ✅ 零 API Key:钱包即身份,无需管理多个 API 密钥
- ✅ 开源透明:MIT 协议,路由逻辑完全可审计
💡 路由示例
看看 ClawRouter 如何根据请求复杂度选择模型:
| 请求 | 路由模型 | 成本 | 节省 |
|---|---|---|---|
| "2+2 等于多少?" | DeepSeek | $0.27/M | 99% |
| "总结这篇文章" | GPT-4o-mini | $0.60/M | 99% |
| "写一个 React 组件" | Claude Sonnet | $15.00/M | 80% |
| "证明这个定理" | o3 | $10.00/M | 87% |
| "运行 50 个并行搜索" | Kimi K2.5 | $2.40/M | 76% |
📥 快速开始(2 分钟)
1. 安装插件
# 安装 ClawRouter(会自动生成 Base 链钱包)
openclaw plugins install @blockrun/clawrouter
2. 充值钱包
安装时会打印钱包地址,向该地址充值 USDC(Base 链):
- Coinbase:购买 USDC,发送到 Base
- 跨链桥:从其他链转 USDC 到 Base
- 交易所:提现 USDC 到 Base 网络
💡 $5 USDC 足够几千次请求
3. 启用智能路由
# 启用自动路由
openclaw config set model blockrun/auto
搞定!现在每个请求都会自动路由到最便宜的合适模型。
已有钱包?
# 导入已有钱包
export BLOCKRUN_WALLET_KEY=0x...
想用特定模型?
# 指定模型(仍然使用 x402 支付)
openclaw config set model openai/gpt-4o
🧠 路由原理
ClawRouter 使用 14 维加权评分系统,100% 本地运行,<1ms 完成决策:
请求 → 加权评分器(14维)
│
├── 高置信度 → 选择对应层级模型 → 完成
│
└── 低置信度 → 默认 MEDIUM 层级 → 完成
14 维评分维度
| 维度 | 权重 | 检测内容 |
|---|---|---|
| 推理标记 | 0.18 | "证明"、"定理"、"逐步" |
| 代码存在 | 0.15 | "function"、"async"、"import" |
| 简单指标 | 0.12 | "什么是"、"定义"、"翻译" |
| 多步骤模式 | 0.12 | "首先...然后"、"步骤1" |
| 技术术语 | 0.10 | "算法"、"kubernetes"、"分布式" |
| Token 数量 | 0.08 | 短 (<50) vs 长 (>500) 提示 |
| 创意标记 | 0.05 | "故事"、"诗歌"、"头脑风暴" |
| 问题复杂度 | 0.05 | 多个问号 |
| 约束数量 | 0.04 | "最多"、"O(n)"、"最大" |
| 命令式动词 | 0.03 | "构建"、"创建"、"实现" |
| 输出格式 | 0.03 | "json"、"yaml"、"schema" |
| 领域专业性 | 0.02 | "量子"、"fpga"、"基因组学" |
层级 → 模型映射
| 层级 | 默认模型 | 成本/M | vs Opus 节省 |
|---|---|---|---|
| SIMPLE | deepseek-chat | $0.27 | 99.6% |
| MEDIUM | gpt-4o-mini | $0.60 | 99.2% |
| COMPLEX | claude-sonnet-4 | $15.00 | 80% |
| REASONING | o3 | $10.00 | 87% |
📊 支持的模型
30+ 模型,6 个提供商,一个钱包搞定:
OpenAI
| 模型 | 输入 $/M | 输出 $/M | 上下文 |
|---|---|---|---|
| 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
| 模型 | 输入 $/M | 输出 $/M | 上下文 |
|---|---|---|---|
| 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 |
其他
| 模型 | 输入 $/M | 输出 $/M | 上下文 |
|---|---|---|---|
| gemini-2.5-pro (Google) | $1.25 | $10.00 | 1M |
| gemini-2.5-flash (Google) | $0.15 | $0.60 | 1M |
| deepseek-chat | $0.14 | $0.28 | 128K |
| grok-3 (xAI) | $3.00 | $15.00 | 131K |
| kimi-k2.5 (Moonshot) | $0.50 | $2.40 | 128K |
💳 支付机制
ClawRouter 使用 x402 微支付协议:
请求 → 402 响应(价格: $0.003)→ 钱包签名 USDC → 重试 → 返回结果
- 非托管:USDC 在你钱包里,只有使用时才扣款
- 透明定价:402 响应头中包含价格,签名前可见
- 无账户:钱包即身份,无需注册任何账号
⚙️ 高级配置
自定义层级模型
# 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"]
🔧 编程使用
不使用 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)}%`),
});
// 任何 OpenAI 兼容客户端都可以使用
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();
直接使用路由器
import { route, DEFAULT_ROUTING_CONFIG, BLOCKRUN_MODELS } from "@blockrun/clawrouter";
// 构建定价表
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: "openai/o3",
// tier: "REASONING",
// confidence: 0.97,
// method: "rules",
// savings: 0.87,
// costEstimate: 0.041,
// }
🆚 与 OpenRouter / LiteLLM 对比
| 特性 | OpenRouter / LiteLLM | ClawRouter |
|---|---|---|
| 设置方式 | 人工创建账号 | Agent 自动生成钱包 |
| 认证方式 | API Key(共享密钥) | 钱包签名(密码学) |
| 支付方式 | 预充值(托管) | 按请求付费(非托管) |
| 路由逻辑 | 闭源 / 不透明 | 开源,客户端运行 |
核心区别:ClawRouter 是为 AI Agent 设计的。Agent 不应该需要人类粘贴 API Key,它们应该自己生成钱包、接收资金、按请求付费——全程编程化。
🔗 相关链接
- GitHub:https://github.com/BlockRunAI/ClawRouter
- NPM:@blockrun/clawrouter
- 文档:https://blockrun.ai/docs
- 模型列表:https://blockrun.ai/models
- Telegram:https://t.me/blockrunAI
- X/Twitter:@BlockRunAI
🎯 总结
如果你每月的 LLM API 费用让你肉疼,ClawRouter 绝对值得一试。它的核心理念很简单:不是每个请求都需要最强的模型。简单问题用便宜模型,复杂问题用强模型——自动判断,自动路由,平均省 78%。
💡 立即体验:openclaw plugins install @blockrun/clawrouter







