Skip to Content
工具调用OpenClaw

OpenClaw 接入指南

OpenClaw 是一个开源的个人 AI 助理平台,支持连接多种聊天渠道和自定义 AI 模型后端。本指南介绍如何配置 AMAX Token Router 作为 OpenClaw 的模型提供商。

准备工作

安装 OpenClaw

# macOS / Linux curl -fsSL https://openclaw.ai/install.sh | bash # Windows iwr -useb https://openclaw.ai/install.ps1 | iex

配置步骤

1. 编辑配置文件

编辑 ~/.openclaw/openclaw.json(JSON5 格式,支持热重载):

{ models: { mode: "merge", providers: { amax: { baseUrl: "https://ai.amaxsmp.com/v1", apiKey: "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", api: "openai-completions", models: [ { id: "gpt-4o", name: "GPT-4o (via AMAX)", reasoning: false, input: ["text"], contextWindow: 128000, contextTokens: 96000, maxTokens: 16000, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } }, { id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6 (via AMAX)", reasoning: false, input: ["text"], contextWindow: 200000, contextTokens: 180000, maxTokens: 32000, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } }, { id: "deepseek-chat", name: "DeepSeek Chat (via AMAX)", reasoning: false, input: ["text"], contextWindow: 65536, contextTokens: 64000, maxTokens: 8192, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } } ] } } } }

注意baseUrl 必须包含 /v1 后缀。api 固定为 "openai-completions"

2. 通过命令行添加(可选)

也可以使用 CLI 添加提供商:

openclaw config set models.providers.amax '{ "baseUrl": "https://ai.amaxsmp.com/v1", "apiKey": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "api": "openai-completions", "models": [ { "id": "gpt-4o", "name": "GPT-4o (via AMAX)", "contextWindow": 128000, "contextTokens": 96000, "maxTokens": 16000, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 } } ] }' --strict-json --merge

3. 使用模型

在 OpenClaw 中引用模型时使用 provider/model 格式:

amax/gpt-4o amax/claude-sonnet-4-6 amax/deepseek-chat

智能路由

如需使用 AMAX Token Router 的智能模型路由,添加一个路由模型:

{ id: "amax-router", name: "AMAX Smart Router", reasoning: false, input: ["text"], contextWindow: 128000, contextTokens: 96000, maxTokens: 16000, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } }

然后在 OpenClaw 中引用 amax/amax-router,网关会根据你 Key 绑定的策略自动选择最优模型。

配置说明

字段说明
baseUrlAPI 端点地址,必须包含 /v1
apiKey从 AMAX 控制台获取的 Key,sk- 开头
api固定为 "openai-completions",对应 OpenAI Chat Completions 协议
models[].id模型标识符,与 API 请求中的 model 参数一致
models[].name在 OpenClaw 界面中显示的模型名称
models[].contextWindow模型总上下文窗口大小
models[].maxTokens单次请求最大输出 Token 数

常见问题

配置不生效

  • 检查 openclaw.json 是否为有效的 JSON5 格式(支持尾逗号和注释)
  • 确认 api 字段值为 "openai-completions"
  • 重启 OpenClaw Gateway

连接私有地址被拒绝

OpenClaw 默认阻止私有 IP 地址。如果 AMAX Token Router 部署在内网,需添加:

{ models: { providers: { amax: { baseUrl: "https://ai.amaxsmp.com/v1", // ... request: { allowPrivateNetwork: true } } } } }

诊断命令

# 检查配置有效性 openclaw doctor --fix # 查看日志 export OPENCLAW_LOG_LEVEL=debug openclaw gateway

参考