Gateway 是 OpenClaw 的核心进程,负责路由、控制平面和 Channel 连接。

5 分钟本地启动

# 启动 Gateway
openclaw gateway --port 18789
openclaw gateway --port 18789 --verbose  # 调试模式
openclaw gateway --force                  # 强制杀死端口监听器后启动
 
# 验证健康
openclaw gateway status
openclaw status
openclaw logs --follow
 
# 验证 Channel 就绪
openclaw channels status --probe

运行时模型

  • 单个常驻进程(路由/控制平面/Channel 连接)
  • 单个多路复用端口:
    • WebSocket 控制/RPC
    • HTTP API(OpenAI 兼容:/v1/models//v1/chat/completions//v1/responses)
    • Control UI 和 Hooks
  • 默认绑定模式:loopback
  • 默认需要认证

配置

配置文件:~/.openclaw/openclaw.json(JSON5 格式,支持注释和尾逗号)

# 交互式配置
openclaw onboard
openclaw configure
 
# CLI 一行命令
openclaw config get agents.defaults.workspace
openclaw config set agents.defaults.heartbeat.every "2h"
openclaw config unset plugins.entries.brave.config.webSearch.apiKey
 
# 查看配置 schema
openclaw config schema

热重载:Gateway 监视配置文件,自动应用变更(gateway.reload.mode="hybrid")。

严格验证:未知键、格式错误或无效值会导致 Gateway 拒绝启动。

最小配置

{
  agents: { defaults: { workspace: "~/.openclaw/workspace" } },
  channels: { whatsapp: { allowFrom: ["+15555550123"] } },
}

配置结构

配置分为多个子系统(各有专属参考页):

  • channels.* → gateway/config-channels
  • agents.defaults.*、session.*、messages.* → gateway/config-agents
  • tools.*、models.* → gateway/config-tools
  • gateway.* → 本页

关键 Gateway 配置

{
  gateway: {
    port: 18789,
    bind: "loopback",  // loopback | tailnet | all
    auth: {
      mode: "token",   // token | password | trusted-proxy | none
      token: "your-token",
    },
    controlUi: { enabled: true },
    tailscale: { mode: "serve" },  // serve | funnel | off
    tls: { enabled: false },
    reload: { mode: "hybrid" },
  },
}

相关

  • concepts/gateway-secrets — 密钥管理
  • concepts/gateway-sandboxing — 沙箱配置
  • concepts/gateway-heartbeat — 心跳配置
  • concepts/gateway-auth — 模型认证
  • concepts/gateway-local-models — 本地模型
  • concepts/web-ui — Control UI