🦞OpenClaw ClawBook

快速开始

从零开始,几分钟内启动 Gateway 并完成首次对话。

环境要求

  • Node.js 24(推荐),或 Node.js 22 LTS(22.16+)
  • macOS / Linux / Windows(PowerShell)
  • LLM API Key(推荐 Anthropic API Key,也支持 OpenAI、Google 等)

可用 node --version 检查 Node 版本。

1. 安装 OpenClaw

macOS / Linux
# 推荐方式:安装脚本
curl -fsSL https://openclaw.ai/install.sh | bash

# 或通过 npm
npm install -g openclaw@latest
Windows (PowerShell)
iwr -useb https://openclaw.ai/install.ps1 | iex

2. 运行引导向导

openclaw onboard --install-daemon

向导会引导你完成认证配置、Gateway 设置,并可选安装后台服务(launchd / systemd)。完成后 Gateway 应已在后台运行。

3. 验证 Gateway

# 如果安装了后台服务,应已在运行
openclaw gateway status

# 或前台手动启动
openclaw gateway --port 18789

4. 打开 Control UI

openclaw dashboard

浏览器会自动打开 http://127.0.0.1:18789/,在 Web 界面中即可开始对话——无需配置任何渠道。

5. 连接聊天渠道(可选)

如果想通过 WhatsApp、Telegram 等渠道与 Agent 对话:

# 登录渠道(如 WhatsApp 扫码配对)
openclaw channels login

# 检查渠道连接状态
openclaw channels status --probe

建议在配置中设置 channels.whatsapp.allowFrom 限制可发消息的号码。

配置文件

OpenClaw 配置文件位于 ~/.openclaw/openclaw.json(JSON5 格式)。不配置也可正常运行,OpenClaw 会使用安全默认值。

~/.openclaw/openclaw.json(最小配置示例)
{
  agents: { defaults: { workspace: "~/.openclaw/workspace" } },
  channels: { whatsapp: { allowFrom: ["+86138xxxx0000"] } },
}

也可通过 openclaw config set 或 Control UI 的 Config 标签页修改配置。Gateway 监听配置文件变化并自动热加载。

API Key 配置

# 方式一:环境变量
export ANTHROPIC_API_KEY="sk-ant-..."

# 方式二:写入 ~/.openclaw/.env(推荐,服务模式可读取)
echo 'ANTHROPIC_API_KEY=sk-ant-...' >> ~/.openclaw/.env

# 验证模型认证状态
openclaw models status

下一步

  • 核心概念 — 了解 Gateway、Channel、Agent、Session、Skill 的关系
  • 常用场景 — 多渠道对话、多 Agent 路由、自动化任务
  • 部署与安全 — 生产部署思路和安全配置