Connect OpenClaw to AntSeed P2P Network
Set up AntSeed as a model provider for OpenClaw. This installs a local buyer proxy that connects to the AntSeed peer-to-peer network and routes LLM requests to available providers.
Architecture
CODEBLOCK0
The buyer proxy runs locally, discovers providers via DHT, and exposes an API-compatible HTTP endpoint.
Step 1: Install AntSeed CLI and buyer plugin
CODEBLOCK1
Verify: antseed --version (requires Node.js 20+).
Step 2: Start the buyer proxy
Run in a terminal or set up as a persistent service:
CODEBLOCK2
The proxy will:
- 1. Join the P2P network via DHT
- Discover available providers
- Listen on INLINECODE1
Persistent service (systemd)
To run the proxy as a background service that survives reboots:
CODEBLOCK3
Verify: INLINECODE2
Step 3: Configure OpenClaw model provider
Ask the user which model they want to use. Available models depend on what providers are active on the network.
Set the provider
CODEBLOCK4
Add a model
The model ID must match a model available on the network. Ask the user or suggest common options. Example for Kimi K2.5 via OpenRouter:
CODEBLOCK5
Replace MODEL_ID_HERE with the actual model (e.g., moonshotai/kimi-k2.5, anthropic/claude-sonnet-4-20250514).
Set as default model
CODEBLOCK6
The model reference format is antseed/<model-id> where antseed is the provider name.
Step 4: Restart and verify
CODEBLOCK7
If the proxy returns available models, the connection is working.
Bootstrap nodes (optional)
If the proxy can't find providers via DHT, add a known provider as a bootstrap node:
Edit ~/.antseed/config.json and add to the bootstrapNodes array:
CODEBLOCK8
Then restart the buyer proxy.
API format notes
- - Use
anthropic-messages API format. The AntSeed proxy translates between formats as needed. - The
apiKey value doesn't matter — set it to any non-empty string (e.g., antseed-p2p). The proxy doesn't validate it. - Streaming is supported. The proxy relays SSE streams from providers.
Verification checklist
- - [ ]
antseed --version prints a version - [ ]
antseed connect --router local-proxy --port 5005 starts without errors - [ ]
curl http://127.0.0.1:5005/v1/models returns available models - [ ] OpenClaw config has
models.providers.antseed configured - [ ]
agents.defaults.model.primary is set to INLINECODE18 - [ ] OpenClaw gateway responds to messages using the AntSeed model
Troubleshooting
- - "No sellers available on the network": No providers found via DHT. Add a bootstrap node (see above) or check that providers are running.
- "DHT returned 0 results": Check internet connectivity and firewall. DHT uses UDP on random high ports. Ensure inbound UDP is allowed.
- Slow first request: DHT discovery takes 5-10 seconds on the first request. Subsequent requests reuse cached peer connections.
- Timeouts on large requests: Some models take longer through P2P routing. Ensure the OpenClaw model config has adequate
maxTokens. - "502 Upstream error": The provider's upstream API (OpenRouter, Anthropic) returned an error. Check the provider logs.
- Empty responses: Verify the model ID matches what the provider allows. Mismatched model names result in 403 errors.
将OpenClaw连接到AntSeed P2P网络
将AntSeed设置为OpenClaw的模型提供商。这将安装一个本地买家代理,连接到AntSeed点对点网络,并将LLM请求路由到可用的提供商。
架构
OpenClaw → http://127.0.0.1:5005 (AntSeed买家代理) → P2P网络 → 提供商节点 → 上游API (OpenRouter, Anthropic等)
买家代理在本地运行,通过DHT发现提供商,并暴露一个API兼容的HTTP端点。
步骤1:安装AntSeed CLI和买家插件
bash
npm install -g @antseed/cli
antseed plugin add @antseed/router-local-proxy
验证:antseed --version(需要Node.js 20+)。
步骤2:启动买家代理
在终端中运行或设置为持久化服务:
bash
antseed connect --router local-proxy --port 5005
代理将:
- 1. 通过DHT加入P2P网络
- 发现可用的提供商
- 监听 http://localhost:5005
持久化服务(systemd)
要将代理作为后台服务运行并在重启后保持:
bash
sudo tee /etc/systemd/system/antseed-buyer.service > /dev/null <
[Unit]
Description=AntSeed买家代理
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=$USER
ExecStart=/usr/bin/env antseed connect --router local-proxy --port 5005
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=antseed-buyer
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now antseed-buyer
验证:sudo systemctl is-active antseed-buyer
步骤3:配置OpenClaw模型提供商
询问用户想要使用的模型。可用模型取决于网络上活跃的提供商。
设置提供商
bash
openclaw config set models.providers.antseed.baseUrl http://127.0.0.1:5005
openclaw config set models.providers.antseed.apiKey antseed-p2p
openclaw config set models.providers.antseed.api anthropic-messages
添加模型
模型ID必须与网络上可用的模型匹配。询问用户或建议常见选项。例如通过OpenRouter使用Kimi K2.5:
bash
cat ~/.openclaw/openclaw.json | python3 -c
import sys, json
cfg = json.load(sys.stdin)
providers = cfg.setdefault(models, {}).setdefault(providers, {})
providers[antseed] = {
baseUrl: http://127.0.0.1:5005,
apiKey: antseed-p2p,
api: anthropic-messages,
models: [{
id: MODELIDHERE,
name: MODELDISPLAYNAME,
reasoning: False,
input: [text],
contextWindow: 131072,
maxTokens: 8192
}]
}
json.dump(cfg, sys.stdout, indent=2)
> /tmp/ocantseed.json && mv /tmp/ocantseed.json ~/.openclaw/openclaw.json
将 MODELIDHERE 替换为实际模型(例如 moonshotai/kimi-k2.5、anthropic/claude-sonnet-4-20250514)。
设置为默认模型
bash
openclaw config set agents.defaults.model.primary antseed/MODELIDHERE
模型引用格式为 antseed/,其中 antseed 是提供商名称。
步骤4:重启并验证
bash
重启网关以加载新提供商
sudo systemctl restart openclaw # 或终止并重启网关进程
测试连接
curl -s http://127.0.0.1:5005/v1/models
如果代理返回可用模型,则连接正常。
引导节点(可选)
如果代理无法通过DHT找到提供商,添加一个已知提供商作为引导节点:
编辑 ~/.antseed/config.json 并添加到 bootstrapNodes 数组:
json
{
bootstrapNodes: [
{ host: PROVIDER_IP, port: 6882 }
]
}
然后重启买家代理。
API格式说明
- - 使用 anthropic-messages API格式。AntSeed代理会根据需要转换格式。
- apiKey 值不重要——设置为任何非空字符串即可(例如 antseed-p2p)。代理不会验证它。
- 支持流式传输。代理会中继来自提供商的SSE流。
验证清单
- - [ ] antseed --version 打印版本号
- [ ] antseed connect --router local-proxy --port 5005 无错误启动
- [ ] curl http://127.0.0.1:5005/v1/models 返回可用模型
- [ ] OpenClaw配置中包含 models.providers.antseed
- [ ] agents.defaults.model.primary 设置为 antseed/
- [ ] OpenClaw网关使用AntSeed模型响应消息
故障排除
- - 网络上没有可用的卖家:通过DHT未找到提供商。添加引导节点(见上文)或检查提供商是否正在运行。
- DHT返回0个结果:检查互联网连接和防火墙。DHT使用UDP随机高位端口。确保允许入站UDP。
- 首次请求缓慢:首次请求时DHT发现需要5-10秒。后续请求会重用缓存的节点连接。
- 大请求超时:某些模型通过P2P路由需要更长时间。确保OpenClaw模型配置中有足够的 maxTokens。
- 502上游错误:提供商的上游API(OpenRouter、Anthropic)返回错误。检查提供商日志。
- 空响应:验证模型ID是否与提供商允许的匹配。模型名称不匹配会导致403错误。