O
OpenClaw

配置详解

OpenClaw 的配置文件位于 ~/.openclaw/openclaw.json。本文档详细介绍所有配置选项。

配置文件位置

# macOS/Linux
~/.openclaw/openclaw.json

# Windows
%USERPROFILE%.openclawopenclaw.json

基础配置示例

{
  "gateway": {
    "host": "127.0.0.1",
    "port": 18789
  },
  "channels": {
    "webchat": {
      "enabled": true
    },
    "whatsapp": {
      "enabled": false,
      "allowFrom": ["+86138xxxxxxxx"]
    }
  },
  "agent": {
    "model": "anthropic/claude-3-5-sonnet-20241022"
  }
}

配置项说明

gateway(网关设置)

选项类型默认值说明
hoststring127.0.0.1网关监听地址
portnumber18789网关监听端口

channels(频道设置)

WebChat

"webchat": {
  "enabled": true,
  "host": "127.0.0.1",
  "port": 18789,
  "basePath": "/"
}

WhatsApp

"whatsapp": {
  "enabled": true,
  "allowFrom": ["+86138xxxxxxxx"],
  "groups": {
    "*": {
      "requireMention": true
    }
  }
}

Telegram

"telegram": {
  "enabled": true,
  "botToken": "YOUR_BOT_TOKEN",
  "allowFrom": ["your_telegram_id"],
  "webhook": {
    "enabled": false,
    "url": "https://your-domain.com/webhook"
  }
}

Discord

"discord": {
  "enabled": true,
  "botToken": "YOUR_BOT_TOKEN",
  "allowFrom": ["your_discord_id"]
}

agent(Agent 设置)

"agent": {
  "model": "anthropic/claude-3-5-sonnet-20241022",
  "thinking": "low",
  "reasoning": false,
  "systemPrompt": "你是一个有帮助的 AI 助手。"
}
选项说明
model使用的 AI 模型,支持 anthropic/* 和 openai/* 格式
thinking思考级别:low、medium、high 或 off
reasoning是否显示推理过程
systemPrompt系统提示词,定义 Agent 的行为

环境变量

以下环境变量可用于配置 API 密钥:

  • ANTHROPIC_API_KEY - Anthropic Claude API 密钥
  • OPENAI_API_KEY - OpenAI API 密钥
  • GEMINI_API_KEY - Google Gemini API 密钥
  • DEEPSEEK_API_KEY - DeepSeek API 密钥

配置验证

使用以下命令验证配置是否正确:

openclaw gateway config:validate