经过验证的配置,直接使用
基础配置
# ~/.openclaw/config.yaml
# 模型配置
model:
default: deepseek-chat
providers:
deepseek:
api_key: ${DEEPSEEK_API_KEY}
openai:
api_key: ${OPENAI_API_KEY}
anthropic:
api_key: ${ANTHROPIC_API_KEY}
# 记忆配置
memory:
max_turns: 20
summary_threshold: 10
# 缓存配置
cache:
enabled: true
type: redis
ttl: 3600
# 日志配置
logging:
level: info
file: ~/.openclaw/logs/openclaw.log
Telegram Bot 配置
# 完整 Telegram 配置
channels:
- name: telegram-bot
type: telegram
token: ${TELEGRAM_BOT_TOKEN}
# 权限控制
permissions:
allowed_users:
- 123456789 # 你的 Telegram ID
# 命令配置
commands:
- name: start
description: 开始使用
- name: help
description: 帮助信息
# 环境变量
# export TELEGRAM_BOT_TOKEN="123456:ABC-DEF"
飞书机器人配置
# 完整飞书配置
channels:
- name: feishu-bot
type: feishu
app_id: ${FEISHU_APP_ID}
app_secret: ${FEISHU_APP_SECRET}
# 权限
permissions:
- im:message
- im:message:send_as_bot
# 环境变量
# export FEISHU_APP_ID="cli_a1b2c3d4"
# export FEISHU_APP_SECRET="xxx"
Discord Bot 配置
# 完整 Discord 配置
channels:
- name: discord-bot
type: discord
token: ${DISCORD_BOT_TOKEN}
client_id: ${DISCORD_CLIENT_ID}
# 权限
intents:
- Guilds
- GuildMessages
- MessageContent
# 环境变量
# export DISCORD_BOT_TOKEN="xxx"
# export DISCORD_CLIENT_ID="123456789"
心跳任务配置
# 完整心跳配置
heartbeat:
enabled: true
interval: 5m
tasks:
# 每日简报
- name: daily-briefing
schedule: "0 8 * * *"
action: |
python3 ~/.openclaw/scripts/briefing.py
# 系统监控
- name: system-monitor
interval: 5m
action: |
~/.openclaw/scripts/monitor.sh
# 数据备份
- name: backup
schedule: "0 2 * * *"
action: |
pg_dump openclaw > ~/backups/openclaw_$(date +%Y%m%d).sql
# 清理日志
- name: cleanup-logs
schedule: "0 0 * * 0"
action: |
find ~/.openclaw/logs -mtime +30 -delete
Skills 配置
# Skills 配置
skills:
- name: weather
enabled: true
- name: todo
enabled: true
- name: github
enabled: true
config:
token: ${GITHUB_TOKEN}
- name: custom-skill
enabled: true
path: ~/.openclaw/skills/custom
知识库配置
# 知识库配置
knowledge:
sources:
- path: ~/.openclaw/workspace/MEMORY.md
type: memory
- path: ~/.openclaw/workspace/memory/
type: logs
- path: ~/Documents/notes/
type: external
# 向量搜索
vector_search:
enabled: true
embedding: openai/text-embedding-3-small
top_k: 5
API 配置
# API 配置
api:
enabled: true
port: 3000
# 认证
auth:
type: bearer
token: ${API_TOKEN}
# 速率限制
rate_limit:
enabled: true
requests_per_minute: 60
# CORS
cors:
enabled: true
origins:
- https://yourdomain.com
Webhook 配置
# Webhook 配置
webhooks:
enabled: true
port: 8080
routes:
- path: /github
handler: ~/.openclaw/webhooks/github.js
- path: /stripe
handler: ~/.openclaw/webhooks/stripe.js
# 安全
secret: ${WEBHOOK_SECRET}
监控配置
# 监控配置
monitoring:
enabled: true
# 健康检查
healthcheck:
enabled: true
endpoint: /health
interval: 30s
# 指标
metrics:
enabled: true
port: 9090
path: /metrics
# 告警
alerts:
- name: service-down
condition: health_check_failed
action: send-telegram
- name: high-cost
condition: daily_cost > 100
action: send-email
预算配置
# 成本控制
budget:
daily_limit: 100
monthly_limit: 2000
alert_threshold: 80
# 用户配额
user_quotas:
user1@example.com:
daily_tokens: 100000
monthly_cost: 100
安全配置
# 安全配置
security:
# HTTPS
https:
enabled: true
cert: /path/to/cert.pem
key: /path/to/key.pem
# IP 白名单
ip_whitelist:
- 127.0.0.1
- 192.168.1.0/24
# 数据脱敏
privacy:
redact_patterns:
- \b\d{16,19}\b
- \b1[3-9]\d{9}\b
数据库配置
SQLite
database:
type: sqlite
path: ~/.openclaw/data/openclaw.db
PostgreSQL
database:
type: postgresql
host: localhost
port: 5432
name: openclaw
user: ${DB_USER}
password: ${DB_PASSWORD}
# 连接池
pool:
min: 2
max: 10
Docker Compose 配置
# docker-compose.yml
version: '3.8'
services:
openclaw:
image: openclaw/openclaw:latest
container_name: openclaw
restart: unless-stopped
environment:
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY}
- TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
volumes:
- ./config:/root/.openclaw
- ./data:/root/.openclaw/data
- ./logs:/root/.openclaw/logs
ports:
- "3000:3000"
depends_on:
- redis
- postgres
redis:
image: redis:7
volumes:
- redis-data:/data
postgres:
image: postgres:16
environment:
- POSTGRES_DB=openclaw
- POSTGRES_USER=user
- POSTGRES_PASSWORD=pass
volumes:
- postgres-data:/var/lib/postgresql/data
volumes:
redis-data:
postgres-data:
环境变量模板
# ~/.openclaw/.env
# 模型 API
DEEPSEEK_API_KEY=sk-xxx
OPENAI_API_KEY=sk-xxx
ANTHROPIC_API_KEY=sk-xxx
# 渠道
TELEGRAM_BOT_TOKEN=123456:ABC-DEF
FEISHU_APP_ID=cli_xxx
FEISHU_APP_SECRET=xxx
DISCORD_BOT_TOKEN=xxx
# 数据库
DB_USER=openclaw
DB_PASSWORD=xxx
# 安全
API_TOKEN=xxx
WEBHOOK_SECRET=xxx
使用方法
1. 创建配置
# 创建配置目录
mkdir -p ~/.openclaw
# 复制模板
cp config.yaml ~/.openclaw/
# 编辑配置
openclaw config edit
2. 设置环境变量
# 复制环境变量模板
cp .env ~/.openclaw/
# 编辑
nano ~/.openclaw/.env
# 加载
source ~/.openclaw/.env
3. 启动
openclaw start
💬 你的配置是什么?评论区分享!
🎯 需要配置服务?微信:yang1002378395