这篇文章教你如何快速搭建自己的 AI Agent。
前置要求
- Mac 电脑(Windows 用户需要先装 WSL)
- 基本的终端操作能力
- 一个 AI API Key(OpenAI / DeepSeek / Claude)
第一步:安装 Node.js
# 推荐用 nvm 安装
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.zshrc
nvm install 18
nvm use 18
第二步:安装 OpenClaw
npm install -g openclaw
第三步:初始化配置
# 创建工作目录
mkdir -p ~/.openclaw/workspace
cd ~/.openclaw/workspace
# 初始化配置文件
openclaw init
第四步:配置 API Key
编辑 ~/.openclaw/config.json:
{
"providers": {
"openai": {
"apiKey": "sk-xxx你的key"
}
},
"defaultProvider": "openai"
}
如果你想用 DeepSeek(更便宜):
{
"providers": {
"deepseek": {
"apiKey": "sk-xxx",
"baseURL": "https://api.deepseek.com/v1"
}
},
"defaultProvider": "deepseek"
}
第五步:创建第一个 Agent
创建文件 ~/.openclaw/workspace/SOUL.md:
# 我的第一个 AI 员工
## 身份
你是一个内容创作助手,擅长写技术文章。
## 任务
1. 每天搜索 AI 热点
2. 写一篇 1000 字左右的技术文章
3. 发布到掘金
第六步:启动 Agent
openclaw start
你的 AI 员工开始工作了!
进阶配置
添加定时任务
编辑 ~/.openclaw/workspace/HEARTBEAT.md:
# 心跳任务
## 每天 8:00
- 搜索 AI 热点
- 写文章
- 发布
添加消息通知
编辑 ~/.openclaw/workspace/USER.md:
# 用户信息
## Telegram
- Token: 你的 bot token
- Chat ID: 你的 chat id
常见问题
Q: 报错 "API key invalid"
A: 检查你的 API Key 是否正确,是否过期。
Q: Mac 提示"无法验证开发者"
A: 运行 xcode-select --install,然后重试。
Q: 怎么更新 OpenClaw?
A: 运行 npm update -g openclaw。
总结
OpenClaw 的核心理念是:让 AI 成为你的虚拟员工。
一旦配置好,它就会 24/7 为你工作。
如果你在安装过程中遇到问题,可以联系我。
联系方式:Telegram @ClawMartCN ClawHub Skills: clawhub.ai/j540