本文的配置环境是 macOS,已经预装好了 NodeJS 环境
安装 OpenClaw 很简单,首先本机需要有 npm 环境,然后一行命令就可以安装 OpenClaw :
$ sudo npm install -g openclaw
OpenClaw 默认读取的配置文件路径是 ~/.openclaw/openclaw.json,以下就是能让 OpenClaw 使用起来的最小配置:
{
"models": {
"providers": {
"aliyun": {
"baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"apiKey": "sk-a0fcd3e999b64ae5b10bd00727a7fca5",
"api": "openai-completions",
"models": [
{
"id": "kimi-k2.5",
"name": "Kimi K2.5",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 256000,
"maxTokens": 8192
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "aliyun/kimi-k2.5"
},
"workspace": "/tmp/.openclaw/workspace",
"heartbeat": { "every": "0m" }
}
},
"gateway": {
"port": 18789,
"mode": "local",
"bind": "loopback",
"auth": {
"mode": "token",
"token": "7f65a503bf530797074b8cd1e5084475aafde5da13c61d0c"
}
},
"session": {
"dmScope": "per-channel-peer"
}
}
以上配置中,禁用 heartbeat 可以有效减少 token 的消耗。
接下来还需再安装 OpenClaw 的 Gateway 服务:
$ sudo openclaw gateway install --force
Tips: LaunchAgents 是 macOS 的设置里面 “登录项与扩展” - “App 后台活动” 所显示的项目 OpenClaw Gateway 就是一个后台服务
如果你和我一样,没有使用 Homebrew 作为 macOS 的包管理,还需要手动调整配置文件 ~/Library/LaunchAgents/ai.openclaw.gateway.plist 中的 PATH 路径。
然后重启一下 OpenClaw Gateway 服务:
$ launchctl unload ~/Library/LaunchAgents/ai.openclaw.gateway.plist
$ launchctl load -w ~/Library/LaunchAgents/ai.openclaw.gateway.plist
OpenClaw Gateway 的控制命令:
openclaw gateway start # 启动服务
openclaw gateway stop # 停止服务
openclaw gateway restart # 重启服务
openclaw gateway install # 安装服务(仅需要执行一次)
在浏览器打开 http://127.0.0.1:18789/#token=7f65a503bf530797074b8cd1e5084475aafde5da13c61d0c 就可以和 OpenClaw 对话了:

其他问题
如果你更新 OpenClaw 到了 3.2 版本,发现无法调用 Tools,要在配置里显式的指定 Tools 的权限:
"tools": {
"profile": "full",
"sessions": {
"visibility": "all"
}
}
