简介
14维加权路由智能选模,零依赖代理自动匹配最便宜可用模型,单次<1ms开销,为OpenClaw场景节省API成本。
原始描述
Cost-optimizing model router for OpenClaw. Automatically routes each request to the cheapest capable Claude model (Haiku/Sonnet/Opus) using weighted scoring....
通过你的 Agent 添加
安装目录:iblai-router/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
iblai-router 是面向 OpenClaw 生态的零依赖智能代理层,部署在客户端与 Anthropic API(或 OpenRouter 等兼容端点)之间。通过 systemd 服务常驻端口 8402,注册为 iblai-router/auto 模型后,所有请求经 14 维度加权评分器实时路由至 LIGHT/MEDIUM/HEAVY 三档最便宜可用模型。
关键配置入口:
config.json热重载,无需重启服务- 支持 Claude 全系原生及 OpenAI/Google 模型(经 OpenRouter 透传)
- 关键词列表与权重边界可自定义,适配特定业务负载
典型接入场景:
- 定时任务(Cron jobs):后台批量处理,成本敏感
- 子代理(Subagents):多步骤推理中自动降级非关键步骤
- 全局/会话级回退:与固定高端模型(如 Opus)主从搭配
显著优点
- 成本优化明确:自动降级策略可将背景任务 API 费用降低 60-90%,高频场景下节省显著
- 零侵入设计:标准 OpenAI 兼容 API 格式,下游无需改造
- 极低延迟开销:<1ms 评分决策,对实时交互无感知影响
- 热配置能力:保存即生效,支持 A/B 调参与渐进上线
- 多厂商兼容:通过 OpenRouter 聚合 Anthropic/OpenAI/Google 模型池,避免 vendor lock-in
潜在缺点与局限
- 关键词规则维护成本:14 维评分依赖人工定义的关键词列表,业务语义漂移后需持续调优
- 无自动反馈闭环:当前版本未集成响应质量回检,无法自优化路由决策
- 单点代理风险:本地 systemd 服务故障将导致路由层失效,需配合健康检查与降级策略
- 非 Anthropic 模型功能受限:经 OpenRouter 路由时,部分原生特性(如 tool use 细节、特定 system prompt 行为)可能存在兼容层损耗
- 安全边界模糊:作为本地代理,请求解密后重新签名,若配置不当可能扩大密钥暴露面
适合人群
- OpenClaw 重度用户:已构建复杂 agent 工作流,需规模化成本控制
- 多模型策略团队:希望统一接口管理 Claude/Haiku/GPT 混合池,简化客户端配置
- DevOps/SRE 运维者:具备 systemd 与本地服务治理能力,能维护路由层可用性
- 成本敏感型产品:后台任务占比高,可接受轻量规则维护换取费用优化
常规风险
| 风险类别 | 说明 | 缓解建议 |
|---|---|---|
| 配置漂移 | 热重载机制可能引入未经验证的配置错误 | 配置变更接入 git 版本控制,关键修改前执行 dry-run |
| 密钥管理 | systemd 环境变量存储 API key,多用户系统存在横向泄露风险 | 优先使用 secret management 工具(如 systemd-creds 或外部 KMS)注入 |
| 路由误判 | 关键词评分无法捕获复杂语义,可能导致简单任务误调重型模型或反之 | 建立采样审计机制,定期复盘路由决策与实际成本/质量匹配度 |
| 供应商锁定转移 | OpenRouter 作为中间层引入额外依赖与定价不确定性 | 保留原生 Anthropic 直连能力作为逃生通道 |
| 服务可用性 | 本地代理单点故障影响所有路由流量 | 配合进程监控(如 systemd watchdog)与客户端超时降级策略 |
技能正文
name: iblai-router description: Cost-optimizing model router for OpenClaw. Automatically routes each request to the cheapest capable Claude model (Haiku/Sonnet/Opus) using weighted scoring. Use when setting up smart model routing, reducing API costs, or configuring multi-tier LLM routing. Supports Anthropic models directly and OpenAI/Google models via OpenRouter.
iblai-router
A zero-dependency proxy that sits between OpenClaw and the Anthropic API, routing each request to the cheapest capable model using a 14-dimension weighted scorer (<1ms overhead).
Install
Run the install script to set up everything automatically:
bash "$(dirname "$0")/scripts/install.sh"
This will:
- Copy
server.jsandconfig.jsonto~/.openclaw/workspace/router/ - Create and start a systemd service (
iblai-router) on port 8402 - Register
iblai-router/autoas an OpenClaw model provider
After install, iblai-router/auto is available anywhere OpenClaw accepts a model ID.
Verify
curl -s http://127.0.0.1:8402/health | jq .
curl -s http://127.0.0.1:8402/stats | jq .
Use
Set iblai-router/auto as the model for any scope:
| Scope | How |
|---|---|
| Cron job | Set model to iblai-router/auto in job config |
| Subagents | agents.defaults.subagents.model = "iblai-router/auto" |
| Per-session | /model iblai-router/auto |
| All sessions | agents.defaults.model.primary = "iblai-router/auto" |
Tip: Keep the main interactive session on a fixed model (e.g. Opus). Use the router for cron jobs, subagents, and background tasks where cost savings compound.
Customize
All config lives in ~/.openclaw/workspace/router/config.json and hot-reloads on save — no restart needed.
Models
Change the models per tier:
{
"models": {
"LIGHT": "claude-3-5-haiku-20241022",
"MEDIUM": "claude-sonnet-4-20250514",
"HEAVY": "claude-opus-4-20250514"
}
}
Non-Anthropic models (OpenAI, Google)
Set apiBaseUrl to route through OpenRouter:
{
"models": {
"LIGHT": "openai/gpt-4.1-mini",
"MEDIUM": "openai/gpt-4.1",
"HEAVY": "openai/o3"
},
"apiBaseUrl": "https://openrouter.ai/api/v1"
}
Update the API key in the systemd service when switching providers, then systemctl daemon-reload && systemctl restart iblai-router.
Scoring
Keyword lists control which tier handles a request:
simpleKeywords,relayKeywords→ push toward LIGHT (cheap)imperativeVerbs,codeKeywords,agenticKeywords→ push toward MEDIUMtechnicalKeywords,reasoningKeywords,domainKeywords→ push toward HEAVY (capable)
Tune boundaries and weights in config.json to match your workload. See the full README for details.
Uninstall
bash "$(dirname "$0")/scripts/uninstall.sh"
Stops the service, removes the systemd unit, and deletes router files. Reminder: switch any workloads using iblai-router/auto back to a direct model first.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。