0准备工作(先看这个)
① 先确认你的系统行不行
| 系统 | 能跑 Pi 吗 | 说明 |
|---|---|---|
| Windows 11 | ✅ 可以 | 自带 winget,最省事 |
| Windows 10(2004 / 20H1 及以后) | ✅ 可以 | 需装 App Installer 才能用 winget |
| Windows 10(1809 ~ 1903) | ✅ 可以 | winget / Terminal 可能装不上,用系统自带终端即可 |
| Windows 7 / 8 / 8.1 | ❌ 不行 | Pi 需要 Node.js 22,而 Node 22 最低要求 Windows 10 / Server 2016 |
| macOS / Linux | ✅ 可以 | 见第 1 章对应标签页 |
Windows 7 用户请注意Pi Agent 依赖 Node.js 22,而 Node 22 不支持 Windows 7,因此 Win7 上无法运行 Pi。建议升级到 Windows 10 / 11,或换一台电脑。不过配套的《代理配置指南》在 Win7 上仍然可用(该页需要访问密码)。
② 装好前置软件(Windows)
Windows 用户建议先装好下面这些,后面的步骤会顺畅很多:
| 软件 | 作用 | 必需? | 最低系统 |
|---|---|---|---|
| Git for Windows (自带 Git Bash) | Pi 执行命令要用到 Git Bash | ✅ 必需 | Win7+ |
| Node.js 22 | Pi 的运行环境(官方安装脚本也会自动装) | ✅ 必需 | Win10 |
| Windows Terminal | 现代终端:多标签、好复制、界面清爽 | 推荐 | Win10 2004 (19041) |
| PowerShell 7 | 新版 PowerShell(系统自带的 5.1 也能用) | 可选 | Win10 |
方式 A:校内高速下载(推荐 🚀 校园网直连,不走公网)
- Git for Windows(含 Git Bash,必需)下载64 MB
- Node.js 22(必需)下载30 MB
- PowerShell 7(可选)下载112 MB
- Windows Terminal(推荐)下载23 MB
- Pi 安装脚本下载65 KB
校园网用户优先用这个以上安装包已托管在校内服务器(openclaw.dgcu.edu.cn),校内下载比公网快很多、也更稳定。
方式 B:有 winget(Win11 / 较新 Win10)
winget install --id Git.Git -e
winget install --id Microsoft.WindowsTerminal -e
winget install --id Microsoft.PowerShell -e方式 C:去官方站点下载
- Git for Windows:git-scm.com/download/win
- Node.js:nodejs.org/zh-cn/download(选 LTS,v22 及以上)
- Windows Terminal:Microsoft Store 或 GitHub Releases
- PowerShell 7:aka.ms/powershell
只有 Git Bash + Node 是必需的Pi 靠 Git Bash 执行命令、靠 Node 运行,缺一个都不行。Windows Terminal / PowerShell 7 只是用起来更舒服,不装也能用系统自带的 Windows PowerShell 5.1(本教程命令都兼容)。
macOS / Linux 用户跳过这步,系统自带终端即可。
1安装 Pi Agent
Pi 是一个运行在终端里的 AI 编程助手。选择你系统的安装方式:
Windows
macOS / Linux
npm(通用)
用 PowerShell 运行(脚本会顺便装好 Node.js):
powershell -c "irm https://pi.dev/install.ps1 | iex"前提需先装好 Git Bash(见第 0 章 ②),否则 Pi 无法执行命令。
校园网加速安装脚本也可从校内下载:pi-install.ps1,下载后在 PowerShell 里执行
powershell -ExecutionPolicy Bypass -File .\pi-install.ps1。一条命令搞定(脚本会顺便装好 Node.js):
curl -fsSL https://pi.dev/install.sh | sh如果你已经有 Node.js 22.19+,也可以直接用 npm:
npm install -g --ignore-scripts @earendil-works/pi-coding-agent验证安装
pi --version能打印出版本号就说明装好了。以后升级用 pi update。
启动 Pi
先进入你想让它工作的文件夹,再启动:
cd 你的项目文件夹
pi你会看到一个终端界面:中间是对话区,底部是输入框和状态栏。
2获取 DeepSeek API Key
- 打开 DeepSeek 开放平台:https://platform.deepseek.com/
- 注册 / 登录账号(手机号或邮箱)。
- 进入左侧菜单的 「API keys」 页面。
- 点击 「创建 API Key」,随便起个名字(例如
pi)。 - 立刻复制生成的 Key(形如
sk-xxxxxxxx)。 - 去 「充值」 页面给账户充点余额(API 按用量计费)。
重要:Key 只显示一次关闭弹窗后就再也看不到明文了。如果没保存,只能删掉重建。请把 Key 存到安全的地方,不要提交到 Git 仓库。
费用参考
deepseek-flash(DeepSeek-V4.1-Flash)价格很低,日常写代码、跑 agent 很划算。最新价格以官方为准:Models & Pricing。
3配置 deepseek-flash 模型
deepseek-flash 是 Pi 内置支持的模型(对应 DeepSeek-V4.1-Flash,支持思考模式、100 万 token 上下文),配置非常简单。
方式 A:登录(推荐)
方式 B:环境变量
- 启动 Pi:
pi - 输入斜杠命令
/login,回车。 - 在列表里选择 DeepSeek。
- 把第 2 步复制的 API Key 粘贴进去,回车。
- 凭证会保存到
~/.pi/agent/auth.json,下次不用再输。
适合 CI / 不想把 Key 写进磁盘的场景。先设置环境变量,再启动 Pi:
# macOS / Linux
export DEEPSEEK_API_KEY=sk-你的Key
# Windows PowerShell(永久生效,需重开终端)
setx DEEPSEEK_API_KEY "sk-你的Key"选择模型
- 在 Pi 里输入
/model,回车。 - 搜索框输入
deepseek-flash。 - 选中它,按 Ctrl+S 可把它设为新会话的默认模型。
- 用
/thinking可以调整思考等级(该模型支持low / high / max)。
找不到这个模型?说明 DeepSeek 的凭证没配好。先确认
/login 成功,或 DEEPSEEK_API_KEY 已在启动 Pi 的那个终端里设置好。4验证 & 常见问题
成功的样子
pi --version有输出pi启动后,状态栏显示模型是deepseek-flash- 随便让它读一个文件 / 写个函数,能正常回答
curl -I https://www.google.com返回 200
常见问题
| 症状 | 原因与解决 |
|---|---|
| Windows 7 能装吗? | 不能。Pi 需要 Node.js 22.19+,而 Node 22 最低要求 Windows 10 / Server 2016。请升级系统,或换一台电脑。 |
安装脚本报错 / pi 找不到 | Node 版本太低或没装。装 Node.js 22.19+,或重开终端让 PATH 生效。 |
| Windows 下命令执行失败 | 缺 Git Bash,装 Git for Windows。 |
/model 里找不到 deepseek-flash | DeepSeek 凭证没配好。重新 /login,或确认 DEEPSEEK_API_KEY 在启动 Pi 的终端里已设置。 |
| API 报 401 Authentication Fails | Key 错误 / 未生效 / 没余额。检查 Key 拼写,确认已充值。 |
| API 报额度不足 | 去平台充值。 |
还需要配置代理?
配套页面如果这台机器需要翻墙(访问 Google / GitHub 等),请查看配套的
《代理配置指南》(该页面需要访问密码)。