快速体验
一句话总结
不说废话,按你的操作系统一步步安装 OpenCode,5 分钟完成。
核心笔记
- ✅ OpenCode 是基于 LLM 的 Agent 运行时框架
- ✅ 支持 macOS、Linux、Windows 三大系统
- ✅ 自然语言交互,无需学习复杂命令
- ✅ 开箱即用
学完你能做什么
- 🚀 成功安装 OpenCode
- 💬 与 AI 对话完成任务
- 🛠️ 使用内置工具
核心思路
OpenCode 需要 Node.js 环境运行。
安装步骤:
安装 Node.js → 安装 OpenCode → 连接模型 → 开始使用
跟我做(分步骤)
macOS
一键安装(推荐)
执行以下命令:
curl -fsSL https://opencodeshare.oss-cn-shenzhen.aliyuncs.com/install-mac.sh | bash
API Key 去哪里获取
OpenCode 连接智谱模型需要 API Key,可通过以下方式免费获取:
🚀 速来拼好模,智谱 GLM Coding 超值订阅,邀你一起薅羊毛!Claude Code、Cline 等 20+ 大编程工具无缝支持,"码力"全开,越拼越爽!立即开拼,享限时惊喜价!
链接:
www.bigmodel.cn/glm-coding?…
一键安装失败?查看手动安装步骤
步骤 1:检查 Node.js
node -v
如果显示版本号(如 v20.x.x)说明已安装。
如果提示 command not found 需要安装 Node.js。
步骤 2:安装 Node.js
方法一:Homebrew(推荐)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install node
方法二:官网下载
- 访问 nodejs.org
- 下载 LTS 版本 (.pkg)
- 双击安装
步骤 3:安装 OpenCode
npm install -g @opencode-ai/cli
步骤 4:验证安装
opencode --version
如果显示版本号说明安装成功。
Linux
一键安装(推荐)
curl -fsSL https://opencodeshare.oss-cn-shenzhen.aliyuncs.com/install-linux.sh | bash
演示视频
安装演示:
opencodeshare.oss-cn-shenzhen.aliyuncs.com/mac-opencod…
API Key 获取
一键安装失败?查看手动安装
步骤 1:检查 Node.js
node -v
步骤 2:安装 Node.js
Ubuntu / Debian
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
CentOS / RHEL
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install -y nodejs
Arch Linux
sudo pacman -S nodejs npm
步骤 3:安装 OpenCode
sudo npm install -g @opencode-ai/cli
步骤 4:验证安装
opencode --version
Windows
一键安装(推荐)
PowerShell:
irm https://opencodeshare.oss-cn-shenzhen.aliyuncs.com/install-opencode.ps1 | iex
API Key 获取
一键安装失败?查看手动安装
步骤 1:检查 Node.js
node -v
如果提示不是内部命令说明未安装。
步骤 2:安装 Node.js
- 访问
nodejs.org - 下载 LTS Windows Installer (.msi)
- 双击安装
- 安装完成后 重启 PowerShell
步骤 3:安装 OpenCode
管理员 PowerShell:
npm install -g @opencode-ai/cli
步骤 4:验证安装
opencode --version
所有系统:连接模型
步骤 5:启动 OpenCode
opencode
步骤 6:连接模型
输入:
/connect
系统会提示:
请选择模型提供商:
1. OpenAI
2. Anthropic Claude
3. 国内模型
输入编号即可。
步骤 7:开始对话
你好
AI 回复即表示成功。
检查点
- Node.js 已安装
- OpenCode 已安装
- 可以与 AI 对话
- 运行简单任务
踩坑提醒
npm install 很慢
npm config set registry https://registry.npmmirror.com
Windows opencode 找不到
重启 PowerShell。
Linux 需要 sudo
sudo npm install -g @opencode-ai/cli
API Key 获取
OpenAI
本课小结
1️⃣ 安装 Node.js
2️⃣ 安装 OpenCode CLI
3️⃣ 连接模型 API
4️⃣ 开始对话