OpenClaw
配置指南6 分鐘閱讀

OpenClaw 設定範本:安全可用的基準配置

Model/Gateway/Channel/Skills 的最小設定範例,包含安全預設值與可直接複製的設定片段。

O

OpenClaw Guides

Tutorial Authors

最小設定

以下是經過驗證的最小設定範本,包含安全預設值:

json
// ~/.openclaw/openclaw.json
{
  "model": {
    "provider": "anthropic",
    "default": "claude-3-5-sonnet",
    "apiKey": "${ANTHROPIC_API_KEY}"
  },
  "gateway": {
    "port": 18789,
    "host": "127.0.0.1"
  },
  "channels": [
    { "type": "whatsapp", "enabled": false },
    { "type": "telegram", "enabled": false },
    { "type": "discord", "enabled": false }
  ],
  "security": {
    "rateLimiting": {
      "enabled": true,
      "maxRequests": 100,
      "windowMs": 60000
    }
  }
}

設定區段說明

模型設定

json
{
  "model": {
    "provider": "anthropic",
    "default": "claude-3-5-sonnet",
    "apiKey": "${ANTHROPIC_API_KEY}"
  }
}

可用模型:

  • claude-3-5-haiku - 快速、經濟實惠($0.25/1M 輸入,$1.25/1M 輸出)
  • claude-3-5-sonnet - 平衡的效能($3/1M 輸入,$15/1M 輸出)
  • claude-sonnet-4 - 最新一代,最佳品質($3/1M 輸入,$15/1M 輸出)

Gateway 設定

json
{
  "gateway": {
    "port": 18789,
    "host": "127.0.0.1",
    "timeout": 30000
  }
}

安全提示: 除非您已設定適當的防火牆規則,否則切勿將 host 設為 0.0.0.0

頻道設定

每個頻道可獨立設定:

json
{
  "channels": [
    {
      "type": "whatsapp",
      "enabled": true,
      "sessionPath": "~/.openclaw/whatsapp-session"
    },
    {
      "type": "telegram",
      "enabled": true,
      "botToken": "${TELEGRAM_BOT_TOKEN}"
    },
    {
      "type": "discord",
      "enabled": true,
      "botToken": "${DISCORD_BOT_TOKEN}",
      "intents": ["GUILDS", "GUILD_MESSAGES", "MESSAGE_CONTENT"]
    }
  ]
}

安全設定

json
{
  "security": {
    "rateLimiting": {
      "enabled": true,
      "maxRequests": 100,
      "windowMs": 60000
    },
    "quotas": {
      "daily": {
        "enabled": true,
        "maxTokens": 100000
      }
    }
  }
}

環境變數

在您的 OpenClaw 目錄建立 .env 檔案:

bash
# ~/.openclaw/.env
ANTHROPIC_API_KEY=sk-ant-xxxxx
TELEGRAM_BOT_TOKEN=123456:ABC-xxxxx
DISCORD_BOT_TOKEN=xxxxx.xxxxx.xxxxx

驗證

驗證您的設定:

bash
openclaw config validate

這會檢查:

  • 必要欄位
  • 有效的 API keys
  • 正確的格式

下一步