2.5 KiB
2.5 KiB
#n8n #openclaw #agents
OpenClaw API Server 配置
OpenClaw 的 Gateway 可以提供 OpenAI 兼容的 Fossies Chat Completions 端点,默认是关闭的,需要在配置中手动开启。
第一步:开启端点
编辑 ~/.openclaw/openclaw.json,添加:
json
{
"gateway": {
"port": 18789,
"mode": "local",
"bind": "lan",
"auth": {
"mode": "token",
"token": "fb97035a1b62a4f29e5cb2f9ac131bd37f021a10823f66b0"
},
"tailscale": {
"mode": "off",
"resetOnExit": false
},
"remote": {
"url": "ws://192.168.3.189:18789"
},
"nodes": {
"denyCommands": [
"camera.snap",
"camera.clip",
"screen.record",
"contacts.add",
"calendar.add",
"reminders.add",
"sms.send"
]
},
"controlUi": {
"allowInsecureAuth": true
},
"http": {
"endpoints": {
"chatCompletions": {
"enabled": true
}
}
}
}
}
host: "0.0.0.0"是为了让 Docker 容器能访问,和 Hermes 同理。
然后重启 Gateway:
bash
openclaw gateway restart
验证:
bash
curl http://localhost:18789/v1/health
与 Hermes 的关键区别
| 项目 | Hermes | OpenClaw |
|---|---|---|
| 默认端口 | 8642 |
18789 |
| Agent 指定方式 | "model": "hermes-agent" |
"model": "openclaw:main" |
| 默认是否开启 | ✅ 开启 | ❌ 需手动开启 |
OpenClaw 通过 model 字段来指定 Agent ID,格式为 "openclaw:<agentId>",例如 "openclaw:main" 或 "openclaw:beta"。 OpenClaw AI
在 n8n 中调用 OpenClaw
json
{
"model": "openclaw:main",
"messages": [
{"role": "user", "content": "{{ $json.input }}"}
]
}
| 字段 | 值 |
|---|---|
| URL | http://192.168.3.189:18789/v1/chat/completions |
| Authorization | Bearer your-secret-key |
最终架构总结
n8n (Docker)
│
├─ POST 192.168.3.189:8642 → Hermes Agent (port 8642)
│
└─ POST 192.168.3.189:18789 → OpenClaw Agent (port 18789)
两个都用同一个局域网 IP,只是端口不同,在 n8n 里分别建两个 HTTP Request 节点就可以了。你的 OpenClaw 现在是什么状态,已经安装好了吗?