Multi-Agent OpenClaw Setup
Run a paid Anthropic agent and free OpenRouter agent side by side with separate Telegram bots.
Quick Start
- 1. Create two Telegram bots via @BotFather and extract chat IDs:
CODEBLOCK0
- 2. Authenticate agents:
openclaw onboard --anthropic-api-key "$ANTHROPIC_API_KEY"
# For free agent: create auth-profiles.json in its agentDir with OpenRouter key
> ⚠️ Passing keys on the CLI can expose them in shell history. Run
history -d $(history 1) after or use
openclaw onboard interactively. Credential files (
auth-profiles.json,
openclaw.json) should be
chmod 600.
- 3. Configure
openclaw.json with two agents, separate bindings, and Telegram accounts.
- 4. Verify setup:
CODEBLOCK2
Key Concepts
- - Agent isolation: Each agent has its own
agentDir, workspace, and model config. - Binding routing:
accountId in bindings directs Telegram messages to the correct agent. - Model refs: Use
provider/modelid format (e.g., anthropic/claude-sonnet-4-6). - Per-agent auth: OpenRouter requires
auth-profiles.json in each agent's directory.
Common Usage
Adding a free agent:
- - Create agentDir at INLINECODE11
- Add agent entry to
openclaw.json with INLINECODE13 - Create
auth-profiles.json with OpenRouter API key in agent's directory - Add binding with unique
accountId (e.g., "tg2") - Restart: INLINECODE17
Switching models:
Edit openclaw.json agent's model.primary and fallbacks with valid provider/id strings.
Masking secrets for logs:
CODEBLOCK3
References
- -
references/config-reference.md — Full openclaw.json, bindings, and auth-profiles.json examples - INLINECODE22 — Common errors, fixes, and Node.js compatibility notes
多智能体OpenClaw配置
通过独立的Telegram机器人,同时运行付费的Anthropic智能体和免费的OpenRouter智能体。
快速开始
- 1. 通过@BotFather创建两个Telegram机器人并提取聊天ID:
bash
curl https://api.telegram.org/bot{TOKEN}/getUpdates | jq .result[0].message.chat.id
- 2. 认证智能体:
bash
openclaw onboard --anthropic-api-key $ANTHROPIC
APIKEY
# 对于免费智能体:在其agentDir中创建包含OpenRouter密钥的auth-profiles.json
> ⚠️ 在命令行中传递密钥可能会将其暴露在shell历史记录中。之后运行history -d $(history 1)或使用openclaw onboard交互式操作。凭证文件(auth-profiles.json、openclaw.json)应设置为chmod 600。
- 3. 配置包含两个智能体、独立绑定和Telegram账户的openclaw.json。
- 4. 验证配置:
bash
openclaw doctor
openclaw sessions cleanup \
--store /Users/YOUR_USERNAME/.openclaw/agents/main/store \
--enforce --fix-missing
openclaw restart
关键概念
- - 智能体隔离: 每个智能体拥有独立的agentDir、工作区和模型配置。
- 绑定路由: 绑定中的accountId将Telegram消息路由到正确的智能体。
- 模型引用: 使用provider/modelid格式(例如anthropic/claude-sonnet-4-6)。
- 按智能体认证: OpenRouter需要在每个智能体的目录中包含auth-profiles.json。
常见用法
添加免费智能体:
- - 在/Users/YOUR_USERNAME/.openclaw/agents/free-agent/agent创建agentDir
- 在openclaw.json中添加智能体条目,设置model.primary: openrouter/...
- 在智能体目录中创建包含OpenRouter API密钥的auth-profiles.json
- 添加具有唯一accountId的绑定(例如tg2)
- 重启:openclaw restart
切换模型:
编辑openclaw.json中智能体的model.primary和fallbacks,使用有效的provider/id字符串。
日志中的密钥遮蔽:
bash
cat ~/.openclaw/openclaw.json | \
jq .channels.telegram.accounts |= map_values(.botToken = [REDACTED])
参考
- - references/config-reference.md — 完整的openclaw.json、绑定和auth-profiles.json示例
- references/troubleshooting.md — 常见错误、修复方法和Node.js兼容性说明