OpenClawCN 中文资料站开始 · 文档 · 进阶 · 动态 · 支持

参考

配置参考

OpenClaw 完整配置项参考文档,包含所有可配置选项的详细说明。

最后更新2026-03-12
来源类型official

AI 摘要

这页重点

核心结论

OpenClaw 完整配置项参考文档,包含所有可配置选项的详细说明。

适用主题

参考

高频关键词

configuration / reference / settings / options

可信信号

最后更新 2026-03-12

配置参考

这一页提供 OpenClaw 所有配置项的完整参考。配置文件默认位于 ~/.openclaw/openclaw.json

配置文件位置

文件用途
~/.openclaw/openclaw.json主配置文件
~/.openclaw/.env环境变量(敏感信息)
~/.openclaw/agents/Agent 配置目录
~/.openclaw/workflows/工作流配置目录
~/.openclaw/skills/技能配置目录

环境变量

可以通过环境变量覆盖配置:

OPENCLAW_HOME=~/.openclaw
OPENCLAW_STATE_DIR=~/.openclaw/state
OPENCLAW_CONFIG_PATH=~/.openclaw/custom-config.json
OPENCLAW_LOG_LEVEL=info

核心配置

基础设置

{
  "version": "1.0",
  "environment": "development",
  "logLevel": "info",
  "dataDir": "~/.openclaw/data",
  "stateDir": "~/.openclaw/state"
}
字段类型默认值说明
versionstring"1.0"配置文件版本
environmentstring"development"运行环境
logLevelstring"info"日志级别
dataDirstring~/.openclaw/data数据目录
stateDirstring~/.openclaw/state状态目录

Gateway 配置

{
  "gateway": {
    "host": "0.0.0.0",
    "port": 3000,
    "baseUrl": "http://localhost:3000",
    "auth": {
      "enabled": true,
      "type": "token",
      "token": "${GATEWAY_TOKEN}",
      "allowTailscale": true
    },
    "cors": {
      "enabled": true,
      "origins": ["http://localhost:3000"]
    },
    "rateLimit": {
      "enabled": true,
      "maxRequests": 100,
      "windowMs": 60000
    }
  }
}
字段类型默认值说明
hoststring"0.0.0.0"监听地址
portnumber3000监听端口
baseUrlstring-外部访问 URL
auth.enabledbooleantrue是否启用认证
auth.typestring"token"认证类型
auth.tokenstring-认证令牌
auth.allowTailscalebooleanfalse允许 Tailscale 认证

模型配置

默认模型

{
  "model": {
    "default": "gpt-4",
    "fallback": "gpt-3.5-turbo",
    "timeout": 60000,
    "maxRetries": 3
  }
}

提供商配置

{
  "providers": {
    "openai": {
      "enabled": true,
      "apiKey": "${OPENAI_API_KEY}",
      "models": ["gpt-4", "gpt-3.5-turbo"],
      "baseUrl": "https://api.openai.com/v1"
    },
    "anthropic": {
      "enabled": true,
      "apiKey": "${ANTHROPIC_API_KEY}",
      "models": ["claude-3-opus", "claude-3-sonnet"]
    },
    "local": {
      "enabled": false,
      "baseUrl": "http://localhost:11434",
      "models": ["llama2", "mistral"]
    }
  }
}
字段类型说明
enabledboolean是否启用此提供商
apiKeystringAPI 密钥(建议使用环境变量)
modelsarray可用模型列表
baseUrlstringAPI 基础 URL(可选)

模型策略

{
  "modelStrategy": {
    "chat": "gpt-4",
    "summarization": "gpt-3.5-turbo",
    "embedding": "text-embedding-3-small",
    "fallback": {
      "enabled": true,
      "order": ["openai", "anthropic", "local"]
    }
  }
}

Agent 配置

默认 Agent

{
  "agent": {
    "default": {
      "name": "Assistant",
      "model": "gpt-4",
      "systemPrompt": "你是一个有帮助的助手。",
      "temperature": 0.7,
      "maxTokens": 4096,
      "memory": {
        "enabled": true,
        "type": "conversation",
        "maxMessages": 50
      },
      "tools": {
        "enabled": true,
        "requireApproval": ["delete", "send"]
      }
    }
  }
}

Agent 配置项

字段类型默认值说明
namestring"Assistant"Agent 名称
modelstring-使用的模型
systemPromptstring-系统提示词
temperaturenumber0.7温度参数
maxTokensnumber4096最大 token 数
memory.enabledbooleantrue是否启用记忆
memory.typestring"conversation"记忆类型
memory.maxMessagesnumber50最大消息数
tools.enabledbooleantrue是否启用工具
tools.requireApprovalarray需要审批的工具

渠道配置

Web Chat

{
  "channels": {
    "webchat": {
      "enabled": true,
      "port": 3000,
      "path": "/webchat",
      "theme": "default",
      "title": "OpenClaw Chat",
      "welcomeMessage": "你好!有什么可以帮助你的?",
      "features": {
        "markdown": true,
        "codeHighlight": true,
        "fileUpload": false
      }
    }
  }
}

Telegram

{
  "channels": {
    "telegram": {
      "enabled": true,
      "botToken": "${TELEGRAM_BOT_TOKEN}",
      "allowedUsers": [],
      "allowedChats": [],
      "parseMode": "Markdown",
      "disableWebPagePreview": false
    }
  }
}

Discord

{
  "channels": {
    "discord": {
      "enabled": true,
      "botToken": "${DISCORD_BOT_TOKEN}",
      "clientId": "${DISCORD_CLIENT_ID}",
      "guilds": [],
      "intents": ["Guilds", "GuildMessages", "DirectMessages"],
      "prefix": "!"
    }
  }
}

WhatsApp

{
  "channels": {
    "whatsapp": {
      "enabled": true,
      "provider": "twilio",
      "accountSid": "${TWILIO_ACCOUNT_SID}",
      "authToken": "${TWILIO_AUTH_TOKEN}",
      "phoneNumber": "${WHATSAPP_PHONE_NUMBER}"
    }
  }
}

飞书

{
  "channels": {
    "feishu": {
      "enabled": true,
      "appId": "${FEISHU_APP_ID}",
      "appSecret": "${FEISHU_APP_SECRET}",
      "encryptKey": "${FEISHU_ENCRYPT_KEY}",
      "verificationToken": "${FEISHU_VERIFICATION_TOKEN}"
    }
  }
}

记忆配置

{
  "memory": {
    "enabled": true,
    "type": "conversation",
    "storage": "sqlite",
    "embedding": {
      "enabled": true,
      "model": "text-embedding-3-small",
      "dimensions": 1536
    },
    "search": {
      "enabled": true,
      "type": "semantic",
      "topK": 5
    },
    "retention": {
      "enabled": true,
      "maxAge": 30,
      "maxMessages": 10000
    }
  }
}
字段类型说明
typestring记忆类型:conversation, summary, vector
storagestring存储方式:sqlite, postgres, memory
embedding.enabledboolean是否启用向量嵌入
search.enabledboolean是否启用记忆搜索
retention.maxAgenumber记忆保留天数

工具配置

{
  "tools": {
    "enabled": true,
    "approvalMode": "selective",
    "requireApproval": ["delete", "send", "execute"],
    "timeout": 30000,
    "maxConcurrent": 5,
    "builtin": {
      "webSearch": {
        "enabled": true,
        "provider": "google"
      },
      "codeExecution": {
        "enabled": true,
        "sandbox": true
      },
      "fileOperations": {
        "enabled": true,
        "allowedPaths": ["~/Documents", "~/Downloads"]
      }
    }
  }
}

技能配置

{
  "skills": {
    "enabled": true,
    "autoUpdate": true,
    "registry": "https://skills.openclaw.ai",
    "installed": [
      "web-search",
      "weather",
      "calculator"
    ],
    "config": {
      "web-search": {
        "provider": "google",
        "apiKey": "${GOOGLE_API_KEY}"
      }
    }
  }
}

安全配置

{
  "security": {
    "encryption": {
      "enabled": true,
      "algorithm": "aes-256-gcm"
    },
    "audit": {
      "enabled": true,
      "logFile": "~/.openclaw/logs/audit.log"
    },
    "rateLimit": {
      "enabled": true,
      "maxRequests": 100,
      "windowMs": 60000
    },
    "contentFilter": {
      "enabled": true,
      "patterns": ["api-key", "password", "secret"]
    }
  }
}

日志配置

{
  "logging": {
    "level": "info",
    "format": "json",
    "outputs": ["console", "file"],
    "file": {
      "path": "~/.openclaw/logs/openclaw.log",
      "maxSize": "10m",
      "maxFiles": 5
    }
  }
}

完整配置示例

{
  "version": "1.0",
  "environment": "production",
  "logLevel": "info",
  
  "gateway": {
    "host": "0.0.0.0",
    "port": 3000,
    "auth": {
      "enabled": true,
      "token": "${GATEWAY_TOKEN}"
    }
  },
  
  "model": {
    "default": "gpt-4",
    "fallback": "gpt-3.5-turbo"
  },
  
  "providers": {
    "openai": {
      "apiKey": "${OPENAI_API_KEY}"
    }
  },
  
  "agent": {
    "default": {
      "model": "gpt-4",
      "memory": {
        "enabled": true
      }
    }
  },
  
  "channels": {
    "webchat": {
      "enabled": true
    },
    "telegram": {
      "enabled": true,
      "botToken": "${TELEGRAM_BOT_TOKEN}"
    }
  },
  
  "memory": {
    "enabled": true
  },
  
  "tools": {
    "enabled": true
  },
  
  "skills": {
    "enabled": true
  }
}

下一步

继续阅读

把文档串成一条阅读路径

如果你正在系统理解 OpenClaw,优先沿着文档顺序继续看;如果只是查某个点,也可以跳回文档中心按分类选择。

关联入口

同主题、同路径、同阶段