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:
CODEBLOCK0
This will:
- 1. Copy
server.js and config.json to INLINECODE2 - Create and start a systemd service (
iblai-router) on port 8402 - Register
iblai-router/auto as an OpenClaw model provider
After install, iblai-router/auto is available anywhere OpenClaw accepts a model ID.
Verify
CODEBLOCK1
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:
CODEBLOCK2
Non-Anthropic models (OpenAI, Google)
Set apiBaseUrl to route through OpenRouter:
CODEBLOCK3
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) - INLINECODE17 ,
codeKeywords, agenticKeywords → push toward MEDIUM - INLINECODE20 ,
reasoningKeywords, domainKeywords → push toward HEAVY (capable)
Tune boundaries and weights in config.json to match your workload. See the full README for details.
Uninstall
CODEBLOCK4
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.
iblai-router
一个零依赖代理,位于OpenClaw与Anthropic API之间,使用14维加权评分器(开销<1毫秒)将每个请求路由到最便宜的可用模型。
安装
运行安装脚本以自动完成所有设置:
bash
bash $(dirname $0)/scripts/install.sh
此操作将:
- 1. 将server.js和config.json复制到~/.openclaw/workspace/router/
- 创建并启动一个systemd服务(iblai-router),监听端口8402
- 将iblai-router/auto注册为OpenClaw模型提供者
安装完成后,iblai-router/auto可在任何OpenClaw接受模型ID的地方使用。
验证
bash
curl -s http://127.0.0.1:8402/health | jq .
curl -s http://127.0.0.1:8402/stats | jq .
使用
将iblai-router/auto设置为任何作用域的模型:
| 作用域 | 方法 |
|---|
| 定时任务 | 在任务配置中将model设置为iblai-router/auto |
| 子代理 |
agents.defaults.subagents.model = iblai-router/auto |
| 单次会话 | /model iblai-router/auto |
| 所有会话 | agents.defaults.model.primary = iblai-router/auto |
提示: 将主要交互会话保留在固定模型上(例如Opus)。将路由器用于定时任务、子代理和后台任务,这些场景下成本节省会不断累积。
自定义
所有配置位于~/.openclaw/workspace/router/config.json,保存后热重载——无需重启。
模型
按层级更改模型:
json
{
models: {
LIGHT: claude-3-5-haiku-20241022,
MEDIUM: claude-sonnet-4-20250514,
HEAVY: claude-opus-4-20250514
}
}
非Anthropic模型(OpenAI、Google)
设置apiBaseUrl以通过OpenRouter路由:
json
{
models: {
LIGHT: openai/gpt-4.1-mini,
MEDIUM: openai/gpt-4.1,
HEAVY: openai/o3
},
apiBaseUrl: https://openrouter.ai/api/v1
}
切换提供商时更新systemd服务中的API密钥,然后执行systemctl daemon-reload && systemctl restart iblai-router。
评分
关键词列表控制哪个层级处理请求:
- - simpleKeywords、relayKeywords → 推向LIGHT(便宜)
- imperativeVerbs、codeKeywords、agenticKeywords → 推向MEDIUM
- technicalKeywords、reasoningKeywords、domainKeywords → 推向HEAVY(能力强)
在config.json中调整边界和权重以匹配您的工作负载。详情请参阅完整README。
卸载
bash
bash $(dirname $0)/scripts/uninstall.sh
停止服务,移除systemd单元,并删除路由器文件。提醒:请先将任何使用iblai-router/auto的工作负载切换回直接模型。