Skip to content

OpenClaw

OpenClaw 通过 ~/.openclaw/openclaw.json 配置模型供应商。添加 Trinity provider 后,用 xh-... Key 调用 模型广场 中的模型。


获取 API Key

  1. 控制台 · API 密钥 创建 Key(xh-...)。
  2. 管理 API 密钥

模型 ID 见 模型广场


快速配置

写入 ~/.openclaw/openclaw.jsonapi 按模型协议写入:anthropic-messages | openai-responses | openai-completions。Anthropic 不带 /v1;Responses / Completions 带 /v1

bash
npx -y trinity-config@latest --type openclaw -k xh-你的key --model gpt-5.4

修改配置后重启 OpenClaw Gateway。


手动配置

编辑 ~/.openclaw/openclaw.json。Provider id 为 trinity,默认模型为 trinity/<model_code>

协议baseUrlapi
Anthropic Messageshttps://api.trinitydesk.aianthropic-messages
Responseshttps://api.trinitydesk.ai/v1openai-responses
Chat Completionshttps://api.trinitydesk.ai/v1openai-completions

Responses 示例(gpt-5.4):

json
{
  "models": {
    "mode": "merge",
    "providers": {
      "trinity": {
        "baseUrl": "https://api.trinitydesk.ai/v1",
        "apiKey": "xh-你的key",
        "api": "openai-responses",
        "models": [
          {
            "id": "gpt-5.4",
            "name": "gpt-5.4"
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "trinity/gpt-5.4"
      },
      "models": {
        "trinity/*": {}
      }
    }
  }
}

保存后重启 Gateway,再发起请求。

故障排查

问题排查
401 Unauthorized确认 API Key 以 xh- 开头且未过期
403 model_not_allowed在控制台确认 Key 有该模型的调用权限
连接超时确认 Base URL 正确(Anthropic 不带 /v1,其余带 /v1
模型未找到模型广场 核对模型 ID

WARNING

不要将 API Key 提交到 Git 仓库。使用环境变量或配置文件管理 Key,定期轮换。

© Trinity AI