跳转到内容
免费注册
在 Coding Agent 接入

OpenClaw 安装与自定义模型配置

配置 OpenClaw 的 models.providers,填写 BetterToken API Key 和 Base URL,选择 Responses 或 Chat Completions 模型并验证连接。

openai-responses: /v1/responses; openai-completions: /v1/chat/completions. Base URL: https://bettertoken.ai/v1.

重点信息

字段填写内容
API KeyBetterToken API Key
Base URLhttps://bettertoken.ai/v1
ModelYOUR_MODEL_ID

准备工作

安装

macOS / Linux

终端窗口
curl -fsSL https://openclaw.ai/install.sh | bash

Windows

终端窗口
iwr -useb https://openclaw.ai/install.ps1 | iex

命令行配置

BetterToken Automatic setup 脚本会写入 OpenClaw 配置。脚本需要 Node.js;如果没有通过参数提供 API Key 或 Model ID,运行时会提示你输入。

macOS / Linux

终端窗口
curl -fsSL "https://bettertoken.ai/install-openclaw-provider.sh" | bash

Windows

终端窗口
iwr "https://bettertoken.ai/install-openclaw-provider.ps1" -OutFile "$env:TEMP\install-openclaw-provider.ps1"; powershell -ExecutionPolicy Bypass -File "$env:TEMP\install-openclaw-provider.ps1"

运行后确认 agents.defaults.model.primary 使用 Setup 弹窗中的 YOUR_MODEL_ID,再执行下方的验证与 Gateway 重启命令。

手动配置

配置 OpenClaw

从模型广场复制准确的 Model ID。

示例使用 API Key 占位符以便阅读。保存配置时,OpenClaw 建议为 models.providers.bettertoken.apiKey 使用 SecretRef 或环境变量替换;请按官方凭据说明设置,避免在共享文件中保存真实 Key。

Responses API

{
"models": {
"mode": "merge",
"providers": {
"bettertoken": {
"baseUrl": "https://bettertoken.ai/v1",
"apiKey": "YOUR_API_KEY",
"api": "openai-responses",
"models": [
{
"id": "YOUR_MODEL_ID",
"name": "YOUR_MODEL_ID"
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "bettertoken/YOUR_MODEL_ID"
}
}
}
}

Chat Completions

{
"models": {
"mode": "merge",
"providers": {
"bettertoken": {
"baseUrl": "https://bettertoken.ai/v1",
"apiKey": "YOUR_API_KEY",
"api": "openai-completions",
"models": [
{
"id": "YOUR_MODEL_ID",
"name": "YOUR_MODEL_ID"
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "bettertoken/YOUR_MODEL_ID"
}
}
}
}

openai-responses: /v1/responses; openai-completions: /v1/chat/completions. Base URL: https://bettertoken.ai/v1.

验证连接

依次执行:

终端窗口
openclaw config validate
openclaw gateway restart
openclaw models list
openclaw models status

配置校验通过、Gateway 重启成功,并且 bettertoken/YOUR_MODEL_ID 出现在模型列表和状态中,即表示配置生效。已有会话仍显示旧模型时,新建会话后再次检查状态。

切换模型

把新模型加入 models.providers.bettertoken.models,再将 agents.defaults.model.primary 改为 bettertoken/YOUR_MODEL_ID。保存后重新执行校验与 Gateway 重启命令。

常见错误

错误处理方式
config validate 失败检查 JSON 逗号、引号和括号。
401重新复制 apiKey,确认没有空格。
404openai-responses: /v1/responses; openai-completions: /v1/chat/completions. Base URL: https://bettertoken.ai/v1.
模型未显示检查模型是否同时存在于 provider 列表和 agents.defaults.model.primary。
旧会话仍用旧模型执行 openclaw gateway restart 并新建会话。

进阶配置

相关 FAQ

可选:使用 CC Switch 管理 provider

需要集中管理多个工具的 provider 时,可以查看 CC Switch 中的 OpenClaw 配置。

技术说明

Responses 与 Chat Completions

openai-responses: /v1/responses; openai-completions: /v1/chat/completions. Base URL: https://bettertoken.ai/v1.