Logo
活死人の行知路

OpenClaw模型配置


📅 | 📝 352 字
#AI #openclaw

1背景

当部署完OpenClaw后,急不可耐的去找它聊天,结果热脸贴上冷屁股,给出下面回复:

这是因为还没有还没有给OpenClaw装上大脑。

2获取API Key

下面介绍接种获取大脑钥匙的方式:

2.1阿里云百炼

1、进入阿里云百炼,点击左下角的 秘钥管理,在页面创建一个API Key。

2.2DeepSeek

1、登录 deepseek开放平台

2、左侧选择 API keys,在页面中点击 创建 API key 按钮,接着取个名字,然后点击“创建”按钮。

3、你会得到一串字符,它就是 API key,保存好不要丢失,保存后可以关闭弹窗,Key会以部分密文的形式展示在页面中。

2.3智普AI

1、访问智谱AI,点击“控制台”,然后点击右上角的“API Key”。

2、点击“添加新的API Key”按钮,为key取个名字,点击“确定”按钮后会在列表展示刚添加的key。

2.4接口AI

3配置模型API Key

可以选择下面任意一种方式配置。

3.1交互终端配置

这是因为还没有配置API Key,可以执行下面命令通过可视化页面配置API Key,下面以智普AI的API Key为例:

  1. openclawer 根目录执行 make config

  2. Where will the Gateway run? 选项中通过上下方向按键选择 Local (this machine)

  3. 接着在 Select sections to configure 选项中继续使用上下方向按键选择 Model

  4. 接着在 Model/auth provider 选项中继续使用上下方向按键选择 Z.AI

  5. 接着在 Z.AI auth method 选项中继续使用上下方向按键选择 CN

  6. 接着在 How do you want to provide this API key? 选项中继续使用上下方向按键选择 Paste API key now

  7. 接着复制智普的API Key,然后粘贴到上一步中:

  8. 接着在 Models in /model picker (multi-select) 选项中继续使用上下方向按键选择自己想要的模型,然后回车

  9. 接着在 Select sections to configure 选项中继续使用上下方向按键选择 Continue 如果看到下面错误,不用担心,出现这个错误的原因是 OpenClaw 的内置安全机制。它检测到你的 WebSocket 连接 (ws://172.20.0.2:18789) 使用的是明文传输,而且目标 IP (172.20.0.2) 是一个 Docker 网桥 IP,不是本地回环地址 (127.0.0.1 或 localhost)。

    另外可以到最后它的输出是 Configure complete.,实际你的 API Key 其实已经配置成功并保存了(看日志中的 Config overwrite… Updated…)。

    如果要避免这个问题,可以采用配置反向代理提供 WSS (推荐用于局域网/公网访问)。

  10. 重新发起对话:

至此,OpenClaw的部署与配置完成。

3.2Web UI配置

打开OpenClaw,左侧选择「配置」,中间面板选择「Models」→「Raw」,在右侧区域配置Key,如:

{
  env: { ZAI_API_KEY: "sk-..." },
  agents: { defaults: { model: { primary: "zai/glm-4.7" } } },
}

3模型提供商(推荐)

➜ 修改 ~/.openclaw/openclaw.json 配置文件,字段值可根据需求修改。

{
  "models": {
    "mode": "merge",
    "providers": {
      "Jiekou": {
        "baseUrl": "https://api.jiekou.ai/openai/v1",
        "apiKey": "sk_xxxxxxxxxxxxxxxxxx",
        "api": "openai-completions",
        "models": [
          {
            "id": "gpt-5.4",
            "name": "gpt-5.4 (Custom Provider)",
            "reasoning": false,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 16000,
            "maxTokens": 4096
          },
          {
            "id": "claude-opus-4-6",
            "name": "claude-opus-4-6 (Custom Provider)",
            "reasoning": false,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 16000,
            "maxTokens": 4096
          }
        ]
      },
      "zhipu": {
        "baseUrl": "https://open.bigmodel.cn/api/paas/v4",
        "apiKey": "sk_xxx",
        "api": "openai-completions",
        "models": [
          {
            "id": "glm-4.5-air",
            "name": "GLM-4.5-Air",
            "reasoning": false,
            "input": ["text"],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 131072,
            "maxTokens": 8192
          },
          {
            "id": "glm-4.7",
            "name": "GLM-4.7",
            "reasoning": false,
            "input": ["text"],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 131072,
            "maxTokens": 8192
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "jiekou/claude-opus-4-6"
      },
      "models": {
        "Jiekou/gpt-5.4": {
          "alias": "gpt-5.4"
        },
        "zhipu/glm-4.7": {
          "alias": "glm4"
        },
        "zhipu/glm-4.5-air": {
          "alias": "glm4.5-air"
        }
      },
      "workspace": "/home/node/.openclaw/workspace",
      "compaction": {
        "mode": "safeguard"
      },
      "maxConcurrent": 4,
      "subagents": {
        "maxConcurrent": 8
      }
    }
  },

  ...
}