OpenClaw 安装与配置记录

尽管距离龙虾热已经过去好几个月了, 从最开始笔者对 AI 的抵触到现在对 AI 的好奇, 这驱使着我还是决定探索一下各个 AI 工具。

本文整理 OpenClaw 的 Linux/Windows 安装过程。

Notice: 本文侧重于探讨使用 openAI 的 key

1 OpenClaw 是什么

OpenClaw 是一个仍处于 beta 阶段的 agent/gateway 项目,可以接入 Telegram、Discord、微信、QQ、飞书等聊天渠道,也可以调用本机工具执行操作。

2 Linux 安装

OpenClaw 需要较新的 Node.js:

  • 推荐:Node.js 24
  • 最低:Node.js 22.19+
  • 不建议:Node.js 18

查看当前版本:

1
2
node -v
npm -v

如果版本太旧,推荐用 nvm 安装 Node 24:

1
2
3
4
5
6
7
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
source ~/.bashrc

nvm install 24

node -v
npm -v

安装 OpenClaw:

1
2
npm install -g openclaw@latest
openclaw --version

初始化:

1
openclaw onboard --install-daemon

常用检查:

1
2
3
4
openclaw status
openclaw doctor
openclaw models status
openclaw gateway status

3 Windows 安装

方式一: 直接安装 Node.js

  1. 访问 Node.js 官网:
1
https://nodejs.org/
  1. 安装 Node.js 24 LTS 或当前推荐版本。
  2. 打开 PowerShell,检查版本:
1
2
node -v
npm -v
  1. 安装 OpenClaw:
1
2
npm install -g openclaw@latest
openclaw --version
  1. 初始化:
1
openclaw onboard

方式二: 用 nvm-windows

如果你需要管理多个 Node 版本,可以安装 nvm-windows:

1
https://github.com/coreybutler/nvm-windows

安装后在 PowerShell 中:

1
2
3
4
5
6
7
8
nvm install 24
nvm use 24

node -v
npm -v

npm install -g openclaw@latest
openclaw --version

4 初始化向导选项说明

Channel

Select channel 是选择聊天入口,例如:

  • Telegram
  • Discord
  • Slack
  • Feishu/Lark
  • Weixin
  • QQ Bot
  • WhatsApp

第一次安装可以选:

1
Skip for now

之后再添加渠道:

1
2
openclaw channels add
openclaw channels status

Search Provider

搜索 provider 用于联网搜索。

首次安装可选:

1
Codex Hosted Search

如果有 Brave、Tavily、Exa、Perplexity、Gemini 等 API Key,也可以选择对应 provider。

Skill Dependencies

Install missing skill dependencies 是可选工具依赖安装,例如:

  • openai-whisper
  • gemini
  • 1password
  • himalaya
  • wacli
  • sonoscli

Hooks

Hooks 是自动化钩子,例如:

  • session-memory
  • command-logger
  • boot-md
  • compaction-notifier

首次安装建议全选。

5 配置文件位置

默认配置文件:

1
2
3
4
# Linux
~/.openclaw/openclaw.json
# Windows
# TODO

查看配置:

1
~/.openclaw/openclaw.json

修改后验证:

1
openclaw config validate

如果配置无效,不要重启 gateway。先修复 JSON 或运行:

1
openclaw doctor --fix

6 模型配置

如果使用的是官方的模型, 这里直接看本章, 否则直接跳转到中转站章节。

查看模型状态:

1
openclaw models status

修改模型配置建议优先使用:

1
openclaw configure

7 中转站配置

7.1 配置中转站

如果使用的是中转站 key,而不是 OpenAI 官方 key,必须同时配置:

  • 中转站 API Key
  • 中转站 Base URL

无论是什么系统, 我们仍然打开对应的配置文件。

这里在 Linux 环境下, 我们打开 ~/.openclaw/openclaw.json

参考: https://github.com/ai-api-gpt/openclaw-api

这里贴出我的配置结构, 对应的地方修改即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
"agents": {
"defaults": {
"workspace": "xxxxxxxx",
"models": {
"my_api/gpt-5.5": { // 取别名
"alias": "GPT"
},
},
"model": { // 这里需要修改为 <provider>/<id>
"primary": "my_api/gpt-5.5",
}
}
},
"models": {
"mode": "merge",
"providers": {
"my_api": { // 实际上这个字段的名称是自己定义的
"baseUrl": "https://xxxxxx/v1", // 中转站的 url
"apiKey": "${MY_API_KEY}",
"api": "openai-completions", // openai 兼容层
"models": [
{
"id": "gpt-5.5", // 这里的 id 需要和中转站支持的模型匹配
"name": "gpt5.5(self)", // 名称随意
"input": [
"text"
],
"contextWindow": 200000,
"maxTokens": 8192
},
{
"id": "gpt-4o", // 可以增加更多模型
"name": "GPT-4o(self)",
"input": [
"text",
"image"
],
"contextWindow": 128000,
"maxTokens": 4096
}
]
}
}
},
"gateway": {
// ......
},
"auth": {
// ......
},
"skills": {
// ......
},
"hooks": {
// ......
},
"wizard": {
// ......
},
"meta": {
// ......
},
// 新增一个字段, 这里是中转站的 keys
"env": {
"MY_API_KEY": "xxxxxx"
}
}

之后重启 gateway。

1
openclaw gateway restart

8 Gateway 重启

改完配置后先验证:

1
openclaw config validate

重启 gateway:

1
openclaw gateway restart

查看状态:

1
2
3
openclaw status
openclaw gateway status
openclaw models status

9 GUI 启动

两条指令即可。

1
2
3
4
# terminal 1
openclaw gateway run
# terminal 2
openclaw dashboard

alt text

9 安全建议

定期运行:

1
2
openclaw security audit --deep
openclaw security audit --fix

10 常用命令速查

1
2
3
4
5
6
7
8
9
10
11
12
13
14
openclaw --help
openclaw onboard
openclaw configure
openclaw status
openclaw doctor
openclaw doctor --fix
openclaw models status
openclaw models auth login --provider openai --force
openclaw channels add
openclaw channels status
openclaw gateway restart
openclaw logs
openclaw config validate
openclaw security audit --deep