OpenClaw 中转 API 使用

如果你在国内网络环境下访问 Anthropic、OpenAI 等官方 API 不稳定,可以使用我们提供的中转服务。

什么是中转 API?

中转 API 是一个兼容 OpenAI 格式的代理服务,将你的请求转发到官方 API。 使用中转服务可以让 OpenClaw 更稳定地访问 AI 模型,同时保持完全兼容。

第一步:获取中转服务 API Key

访问我们的中转服务站点,注册账户并获取 API Key。

中转服务地址

中转服务地址:https://your-relay-domain.com(请替换为实际地址)


第二步:配置 OpenClaw 使用中转

OpenClaw 支持自定义模型端点,只需将 Base URL 替换为中转地址:

bash
# 方式一:通过配置文件修改
openclaw config set models.providers.anthropic.baseUrl https://your-relay-domain.com
openclaw config set models.providers.openai.baseUrl https://your-relay-domain.com

# 方式二:手动编辑配置文件
openclaw config file

在配置文件中,找到对应的 provider 配置,修改 baseUrl 字段:

json
{
"providers": {
  "anthropic": {
    "baseUrl": "https://your-relay-domain.com"
  },
  "openai": {
    "baseUrl": "https://your-relay-domain.com"
  }
}
}

请将 https://your-relay-domain.com 替换为实际的中转服务地址。


第三步:设置中转 API Key

将你的 API Key 配置到对应的提供商:

bash
# 为 Anthropic 提供商设置中转 API Key
openclaw infer auth setup-token --provider anthropic
# 输入从中转服务获取的 API Key

# 为 OpenAI 提供商设置中转 API Key
openclaw infer auth setup-token --provider openai
# 输入从中转服务获取的 API Key

API Key 替换

使用中转服务时,需要将原来的官方 API Key 替换为中转服务提供的 API Key。


第四步:验证配置

bash
# 查看当前模型配置
openclaw models status

# 启动聊天测试
openclaw chat

如果聊天正常响应,说明中转服务配置成功。

配置完成!

恭喜!OpenClaw 已通过中转服务连接 AI 模型,网络访问更加稳定。


切换回官方 API

如果想切换回官方 API,只需将 baseUrl 恢复为官方地址:

bash
# 恢复 Anthropic 官方 API
openclaw config set models.providers.anthropic.baseUrl https://api.anthropic.com

# 恢复 OpenAI 官方 API
openclaw config set models.providers.openai.baseUrl https://api.openai.com