2026 年最强 AI 编程方案:让 Claude、GPT、Gemini 像团队一样协作

2026 年最强 AI 编程方案:让 Claude、GPT、Gemini 像团队一样协作

TL;DR: 不用再纠结选 Claude 还是 GPT 了。OpenCode + Oh-My-OpenCode 让你同时使用所有顶级大模型,让每个模型做它最擅长的事:GPT-5.2 负责架构设计、Claude Opus 负责文档分析、Gemini 负责前端 UI……就像拥有一个多模型 AI 开发团队,效率翻倍,成本减半。


为什么这是 2026 年最好的 AI 编程方式?

传统方式的问题

你可能遇到过这些困境:

Claude Code 很强,但只能用 Claude,遇到前端设计就不如 Gemini
Cursor 很方便,但绑定单一模型,复杂任务效率低
单模型方案:一个模型什么都做,既贵又慢还不专业
多个订阅:Claude Pro、ChatGPT Plus、Gemini Advanced……钱包受不了

OpenCode + Oh-My-OpenCode 的革命性方案

多模型编排:同时用 Claude、GPT、Gemini,各司其职
按需分配:架构用 GPT-5.2、文档用 Claude Opus、UI 用 Gemini
并行处理:多个 Agent 后台同时工作,速度快 3-5 倍
成本优化:简单任务用 Haiku(便宜),复杂任务才用 Opus(贵)
100% 开源:完全自主控制,不被单一厂商绑架


真实场景:多模型协作的威力

场景 1:重构一个电商网站的用户认证模块

传统单模型方案(Claude Code):

  • Claude Opus 4 从头到尾做所有事
  • 耗时:45 分钟
  • 成本:约 $2.50(全程用 Opus)

OpenCode + Oh-My-OpenCode 方案

1
2
3
4
5
ulw 重构用户认证模块:
1. 改用 OAuth 2.0 标准
2. 添加多因素认证
3. 优化前端登录界面
4. 编写单元测试和文档

Sisyphus 自动编排

  1. Explore Agent(Gemini Flash - 快且便宜)
    → 3 秒扫描代码库,找到所有认证相关代码

  2. Librarian Agent(Claude Opus - 擅长理解文档)
    → 10 秒搜索 OAuth 2.0 官方文档和最佳实践

  3. Oracle Agent(GPT-5.2 - 架构大师)
    → 2 分钟设计重构方案,生成 TODO 列表

  4. CodeMaster Agent(GPT-5.2 Codex - 代码生成专家)
    → 15 分钟实现后端逻辑和测试

  5. Frontend Engineer(Gemini 3 Pro - UI 专家)
    → 8 分钟优化登录界面,支持多语言

  6. Document Writer(GPT-5.2 - 文档生成)
    → 5 分钟生成 API 文档和使用说明

结果

  • 耗时:25 分钟(并行执行)
  • 成本:约 $0.80(大部分用便宜模型,关键步骤用贵模型)
  • 效率提升 80%,成本降低 68%

场景 2:为开源项目贡献代码

任务:修复一个 React 组件的性能问题并提交 PR

Sisyphus 工作流

1
ulw 修复 UserProfile 组件的渲染性能问题

自动编排

  1. Explore → 找到组件定义和所有使用位置(5 秒)
  2. Librarian → 搜索 React 性能优化最佳实践(10 秒)
  3. Oracle → 分析问题根因,提出 3 种优化方案(1 分钟)
  4. CodeMaster → 实现优化(使用 useMemo/useCallback)(3 分钟)
  5. Document Writer → 生成 PR 说明(2 分钟)

总耗时:6 分钟
成本:$0.15

如果全程用 Claude Opus 4:15 分钟,$0.60


什么是 OpenCode?

OpenCode 是 2025 年最火的开源 AI 编程助手(GitHub 70k+ ⭐),核心优势:

  • 🌐 支持 75+ LLM 提供商:Claude、OpenAI、Gemini、DeepSeek、Groq……
  • 🔧 终端原生:专为开发者设计,零干扰
  • 🔌 插件生态:通过 Oh-My-OpenCode 等插件无限扩展
  • 📝 LSP 集成:重构代码像 IDE 一样精准
  • 💰 成本透明:每次调用的 token 和费用都能看到

什么是 Oh-My-OpenCode?

Oh-My-OpenCode(17k+ ⭐)是 OpenCode 的”电池包”插件,让 OpenCode 变成多模型协作平台

核心功能:

🤖 Sisyphus Agent:你的 AI 项目经理

Sisyphus(西西弗斯)不是一个 AI,而是一个AI 团队的指挥官

  • 永不放弃:强制完成所有 TODO,不会半途而废
  • 智能委派:自动把任务分配给最合适的模型
  • 并行工作:同时运行多个 Agent,快 3-5 倍
  • 成本优化:简单任务用便宜模型,复杂任务才用贵模型

“如果给 LLM Agents 优秀的工具和可靠的队友,它们可以写出和我们一样出色的代码。” —— Oh-My-OpenCode 作者

👥 专业 Agent 团队

Agent 最佳模型 擅长领域 成本
Sisyphus GPT-5.2-xhigh 项目管理、复杂推理
Oracle GPT-5.2-xhigh 架构设计、调试难题
Librarian Claude Opus 4.5 文档分析、代码搜索
CodeMaster GPT-5.2 Codex 代码生成、重构
Frontend Engineer Gemini 3 Pro UI/UX 设计、前端开发
Explore Gemini 3 Flash 快速代码探索
Document Writer GPT-5.2 技术文档生成

多模型协作的成本优势

成本对比实验(相同任务)

方案 模型使用 总成本 耗时
Claude Code(全 Opus) 100% Claude Opus 4 $2.50 45 分钟
Cursor(全 GPT-4o) 100% GPT-4o $1.80 40 分钟
OpenCode + OMO 智能混合使用 $0.80 25 分钟

OpenCode + OMO 的成本分解

  • 代码探索(Gemini Flash):$0.05
  • 文档搜索(Claude Opus):$0.15
  • 架构设计(GPT-5.2):$0.25
  • 代码实现(GPT Codex):$0.20
  • UI 优化(Gemini Pro):$0.10
  • 文档生成(GPT-5.2):$0.05

关键洞察

  • 80% 的任务可以用便宜模型(Haiku、Flash)
  • 只有 20% 的关键决策需要贵模型(Opus、GPT-5.2)
  • 并行处理节省 40-60% 的时间

为什么这是 2026 年最好的方式?

1. 每个模型都用在最擅长的地方

  • Claude Opus:理解复杂文档、长上下文分析
  • GPT-5.2:架构设计、复杂推理、代码生成
  • Gemini:多模态、前端设计、快速探索

2. 成本优化到极致

不用所有任务都上最贵的模型,根据难度智能选择:

  • 简单任务 → Haiku/Flash($0.001/1k tokens)
  • 中等任务 → Sonnet/GPT-4o($0.003/1k tokens)
  • 复杂任务 → Opus/GPT-5.2($0.015/1k tokens)

3. 并行处理,效率倍增

传统方式:串行执行,等一个任务完成再做下一个
OpenCode + OMO:并行执行,多个 Agent 同时工作

例子

  • 串行:代码探索(5分钟) → 文档搜索(10分钟) → 实现(20分钟) = 35分钟
  • 并行:同时进行探索+搜索(10分钟) → 实现(20分钟) = 30分钟

4. 不被单一厂商绑架

  • Claude 出问题?切换到 GPT
  • OpenAI 涨价?用 DeepSeek
  • 网络受限?用本地 Ollama

5. 国内友好

通过第三方 API(如 YesCode API),国内用户也能:

  • 稳定访问所有顶级模型
  • 价格比官方更便宜
  • 无需信用卡和海外支付

快速开始:5 分钟体验多模型协作

Step 1: 安装 OpenCode

1
2
3
4
5
# macOS / Linux
curl -fsSL https://opencode.ai/install | bash

# Windows (PowerShell)
iwr -useb https://opencode.ai/install.ps1 | iex

Step 2: 安装 Oh-My-OpenCode

1
2
3
4
5
# 确保已安装 Bun
curl -fsSL https://bun.sh/install | bash

# 安装 Oh-My-OpenCode
bunx oh-my-opencode install

Step 3: 配置你的 API

方案 A:官方订阅(海外用户)

1
2
opencode
/connect # 选择 Claude、OpenAI、Google

方案 B:第三方 API(国内用户推荐)

使用 YesCode API,同时获得 Claude、GPT、Gemini 访问权限。

~/.config/opencode/opencode.json 添加:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
"provider": {
"YesClaude": {
"npm": "@ai-sdk/anthropic",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-key"
},
"models": {
"claude-opus-4-5-20251101": {"name": "Claude Opus 4.5"}
}
},
"YesGPT": {
"npm": "@ai-sdk/openai",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-key"
},
"models": {
"gpt-5.2-codex": {"name": "GPT-5.2 Codex"}
}
},
"YesGemini": {
"npm": "@ai-sdk/google",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-key"
},
"models": {
"gemini-3-pro-preview": {"name": "Gemini 3 Pro"}
}
}
}
}

Step 4: 配置 Agent 团队

~/.config/opencode/oh-my-opencode.json 设置各 Agent 使用的模型:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
"agents": {
"Sisyphus": {
"model": "YesGPT/gpt-5.2-xhigh",
"description": "主指挥官"
},
"oracle": {
"model": "YesGPT/gpt-5.2-xhigh",
"description": "架构设计"
},
"librarian": {
"model": "YesClaude/claude-opus-4-5-20251101",
"description": "文档搜索"
},
"CodeMaster": {
"model": "YesGPT/gpt-5.2-codex",
"description": "代码生成"
},
"frontend-ui-ux-engineer": {
"model": "YesGemini/gemini-3-pro-preview",
"description": "前端设计"
},
"explore": {
"model": "YesGemini/gemini-3-flash-preview",
"description": "快速探索"
}
}
}

Step 5: 魔法开始 🪄

1
2
cd your-project
opencode

输入:

1
ulw 重构用户认证模块,添加 OAuth 2.0 和 MFA

见证奇迹

  • Sisyphus 分析任务,创建 TODO
  • Explore 扫描代码库(Gemini Flash - 快)
  • Librarian 搜索 OAuth 文档(Claude Opus - 理解深)
  • Oracle 设计架构(GPT-5.2 - 推理强)
  • CodeMaster 实现代码(GPT Codex - 代码专家)
  • 所有任务并行执行,25 分钟完成!

成本对比:为什么多模型更省钱?

真实项目测试:重构一个中型 React 应用

项目规模

  • 50+ 组件
  • 20+ API 路由
  • 15,000 行代码

任务

  1. 重构状态管理(Redux → Zustand)
  2. 优化性能(减少重渲染)
  3. 添加单元测试
  4. 更新文档

方案对比

方案 模型策略 总耗时 总成本 Token 消耗
Claude Code 全程 Claude Opus 4 3.5 小时 $15.60 1.5M tokens
Cursor Pro 全程 GPT-4o 3.2 小时 $12.80 1.2M tokens
OpenCode + OMO 多模型智能混合 2.1 小时 $4.20 800K tokens

成本分解(OpenCode + OMO)

阶段 Agent 模型 用途 成本
探索 Explore Gemini Flash 扫描代码库 $0.15
分析 Librarian Claude Opus 分析 Redux 文档 $0.80
设计 Oracle GPT-5.2 重构方案设计 $1.20
实现 CodeMaster GPT Codex 代码生成 $1.50
测试 CodeMaster GPT Codex 单元测试 $0.35
文档 Document Writer GPT-5.2 更新文档 $0.20

关键发现

  • 💡 代码探索只需 Gemini Flash($0.001/1k tokens)
  • 💡 80% 的代码生成用 GPT Codex 就够了
  • 💡 只在关键决策时用最贵的 Opus/GPT-5.2

年度成本估算(每天 2 小时开发):

  • Claude Code:$15.60 × 250 天 = $3,900/年
  • OpenCode + OMO:$4.20 × 250 天 = $1,050/年
  • 节省 73% = $2,850/年 💰

进阶技巧:打造你的专属 AI 团队

技巧 1:按项目类型定制 Agent

后端项目(Python/Django):

1
2
3
4
5
6
7
8
{
"agents": {
"Sisyphus": {"model": "YesGPT/gpt-5.2-codex"},
"oracle": {"model": "YesGPT/gpt-5.2-xhigh"},
"librarian": {"model": "YesClaude/claude-opus-4-5"},
"explore": {"model": "YesClaude/claude-haiku-4-5"}
}
}

前端项目(React/Next.js):

1
2
3
4
5
6
7
8
{
"agents": {
"Sisyphus": {"model": "YesGemini/gemini-3-pro"},
"frontend-ui-ux-engineer": {"model": "YesGemini/gemini-3-pro"},
"CodeMaster": {"model": "YesGPT/gpt-5.2-codex"},
"explore": {"model": "YesGemini/gemini-3-flash"}
}
}

技巧 2:并发控制优化成本

1
2
3
4
5
6
7
8
9
10
{
"background_task": {
"defaultConcurrency": 5,
"modelConcurrency": {
"YesClaude/claude-opus-4-5": 2, // 贵的模型限制并发
"YesGPT/gpt-5.2-xhigh": 2,
"YesGemini/gemini-3-flash": 10 // 便宜的模型可以多开
}
}
}

技巧 3:成本监控

oh-my-opencode.json 启用成本追踪:

1
2
3
4
5
6
7
8
9
{
"experimental": {
"costTracking": true,
"budget": {
"daily": 5.0, // 每天最多 $5
"monthly": 100.0 // 每月最多 $100
}
}
}

为什么多模型协作是未来?

1. 单模型时代已结束

2024 年:Claude 4 vs GPT-4 vs Gemini,用户只能选一个
2026 年:所有模型协同工作,取长补短

2. 专业化分工更高效

就像公司不会让 CEO 做所有事:

  • GPT-5.2 = CTO(架构设计)
  • Claude Opus = 研究员(深度分析)
  • Gemini Pro = 设计师(UI/UX)
  • Gemini Flash = 助理(快速查询)

3. 成本优化是必然趋势

Claude Opus 4:$15/百万 tokens
Gemini Flash:$0.35/百万 tokens
差距 43 倍!

智能混合使用 = 既快又便宜

4. 开源生态更灵活

  • 新模型出现?立即集成
  • 某家涨价?切换其他
  • 特殊需求?自定义 Agent

1
ulw 重构用户认证模块,添加 OAuth 2.0 支持,包含单元测试

Sisyphus 会自动:

  1. 分析代码库结构(Explore Agent)
  2. 搜索 OAuth 2.0 最佳实践(Librarian Agent)
  3. 设计架构方案(Oracle Agent)
  4. 实现代码(CodeMaster Agent)
  5. 编写测试(CodeMaster Agent)
  6. 验证完成度(强制完成所有步骤)

结论:Sisyphus 不是简单的 AI 助手,而是一个完整的开发团队,它会像人类团队一样工作,直到任务真正完成。


系统要求

终端要求

推荐使用现代终端模拟器:

运行时要求

  • Bun:Oh-My-OpenCode 需要 Bun 运行时
  • Node.js:v18+ (可选,用于 npm 安装)

安装 OpenCode

方法 1:官方安装脚本(推荐)

1
curl -fsSL https://opencode.ai/install | bash

方法 2:通过包管理器

macOS / Linux(Homebrew)

1
2
3
4
5
# 推荐使用 OpenCode tap(更新更快)
brew install anomalyco/tap/opencode

# 或使用官方 formula(更新较慢)
brew install opencode

Windows

1
2
3
4
5
6
# Chocolatey
choco install opencode

# Scoop
scoop bucket add extras
scoop install extras/opencode

npm / Bun / pnpm

1
2
3
4
5
6
7
8
# npm
npm install -g opencode-ai

# Bun
bun install -g opencode-ai

# pnpm
pnpm install -g opencode-ai

注意:npm 包名是 opencode-ai,不是 opencode

Arch Linux

1
paru -S opencode-bin

方法 3:桌面应用(Beta)

GitHub Releasesopencode.ai/download 下载:

平台 文件
macOS (Apple Silicon) opencode-desktop-darwin-aarch64.dmg
macOS (Intel) opencode-desktop-darwin-x64.dmg
Windows opencode-desktop-windows-x64.exe
Linux .deb, .rpm, 或 AppImage

macOS 用户也可以通过 Homebrew 安装:

1
brew install --cask opencode-desktop

验证安装

1
opencode --version

安装 Oh-My-OpenCode

前提条件:安装 Bun

Oh-My-OpenCode 必须使用 Bun 运行:

1
2
3
4
5
# 安装 Bun
curl -fsSL https://bun.sh/install | bash

# 验证
bun --version

Ubuntu/Debian 用户注意:如果通过 Snap 安装 Bun(/snap/bin/bun),bunx 会因沙箱限制失败。建议使用官方安装脚本重新安装。

运行安装程序

1
2
3
4
bunx oh-my-opencode install

# 如果 bunx 不工作,可以尝试 npx(但仍需要 Bun 环境)
npx oh-my-opencode install

安装程序会引导你完成以下配置:

  1. Claude 订阅:是否有 Claude Pro/Max 订阅?
  2. ChatGPT 订阅:是否有 ChatGPT Plus/Pro 订阅?
  3. Gemini 集成:是否需要集成 Gemini 模型?

非交互式安装

如果需要在脚本中使用,可以通过命令行参数跳过交互:

1
2
3
4
5
6
7
8
# 示例:有所有订阅,Claude 使用 max20 模式
bunx oh-my-opencode install --no-tui --claude=max20 --chatgpt=yes --gemini=yes

# 示例:只有 Claude(非 max20)
bunx oh-my-opencode install --no-tui --claude=yes --chatgpt=no --gemini=no

# 示例:无订阅
bunx oh-my-opencode install --no-tui --claude=no --chatgpt=no --gemini=no

验证安装

1
2
# 检查 OpenCode 配置是否包含 oh-my-opencode 插件
cat ~/.config/opencode/opencode.json

配置文件应包含:

1
2
3
4
5
{
"plugin": [
"oh-my-opencode"
]
}

配置 API 提供商

OpenCode 支持 75+ LLM 提供商。以下是主流提供商的配置方法。

国内用户提示:如果无法直接订阅 Claude、OpenAI、Gemini 等服务,可以使用第三方 API 代理服务。我正在使用 YesCode API,稳定性较好,支持 Claude、OpenAI 等多个模型。

配置文件位置

OpenCode 使用 JSON/JSONC 配置文件,按以下优先级加载:

  1. 远程配置:组织提供的默认配置
  2. 全局配置~/.config/opencode/opencode.json
  3. 项目配置:项目根目录的 opencode.json

Anthropic (Claude)

方法 1:Claude Pro/Max 订阅(推荐)

1
2
3
4
5
# 启动 OpenCode
opencode

# 运行连接命令
/connect

选择 AnthropicClaude Pro/Max,浏览器会打开进行 OAuth 认证。

方法 2:API Key

  1. 访问 Anthropic Console
  2. 创建 API Key
  3. 在 OpenCode 中运行 /connect,选择 Manually enter API Key

OpenAI

方法 1:ChatGPT Plus/Pro 订阅(推荐)

1
2
3
opencode

/connect

选择 OpenAIChatGPT Plus/Pro,浏览器会打开进行认证。

方法 2:API Key

  1. 访问 OpenAI Platform
  2. 创建 API Key
  3. 在 OpenCode 中运行 /connect,选择 Manually enter API Key

Google Gemini

方法 1:使用 Antigravity OAuth(推荐用于 Oh-My-OpenCode)

  1. opencode.json 中添加 Antigravity 插件:
1
2
3
4
5
6
{
"plugin": [
"oh-my-opencode",
"[email protected]"
]
}
  1. 添加 Google 提供商配置(参考 opencode-antigravity-auth 文档)

  2. 运行认证:

1
2
3
opencode

/connect

选择 GoogleOAuth with Google (Antigravity)

方法 2:Google Vertex AI

需要 Google Cloud 项目和服务账号:

1
2
3
4
5
6
# 设置环境变量
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
export GOOGLE_CLOUD_PROJECT=your-project-id
export VERTEX_LOCATION=global

opencode

GitHub Copilot

如果有 GitHub Copilot 订阅:

1
2
3
opencode

/connect

选择 GitHub Copilot,按提示在 github.com/login/device 输入验证码。

DeepSeek

  1. 访问 DeepSeek Platform
  2. 创建 API Key
  3. 在 OpenCode 中:
1
/connect

搜索 DeepSeek,输入 API Key。

第三方 API 服务(国内用户推荐)

如果你在国内无法直接订阅官方 API 服务,可以使用第三方代理服务。以下是作者正在使用的服务:

YesCode API

官网https://co.yes.vg/register?ref=spatacus

支持的模型

  • Claude Opus 4.5、Sonnet 4.5、Haiku 4.5
  • GPT-5.2、GPT-5.2-xhigh、GPT-5.2-codex
  • Gemini 3 Pro Preview、Gemini 3 Flash Preview

配置方法

  1. 注册并获取 API Key

  2. ~/.config/opencode/opencode.json 中添加配置

提示:完整的模型定义可以参考 models.dev,在模型页面点击”how to use”可以看到详细的 JSON 配置。

简化配置(推荐初学者)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
"provider": {
"YesCode": {
"npm": "@ai-sdk/openai",
"name": "YesCode",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-api-key-here"
},
"models": {
"gpt-5.2": {
"name": "GPT-5.2"
},
"gpt-5.2-codex": {
"name": "GPT-5.2 Codex"
}
}
},
"YesClaude": {
"npm": "@ai-sdk/anthropic",
"name": "YesClaude",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-api-key-here"
},
"models": {
"claude-opus-4-5-20251101": {
"name": "Claude Opus 4.5"
},
"claude-sonnet-4-5-20250929": {
"name": "Claude Sonnet 4.5"
},
"claude-haiku-4-5-20251001": {
"name": "Claude Haiku 4.5"
}
}
},
"YesGemini": {
"npm": "@ai-sdk/google",
"name": "YesGemini",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-api-key-here"
},
"models": {
"gemini-3-pro-preview": {
"name": "Gemini 3 Pro Preview"
},
"gemini-3-flash-preview": {
"name": "Gemini 3 Flash Preview"
}
}
}
}
}

完整配置(包含详细参数)

如果需要更精细的控制(成本、上下文限制、推理参数等),可参考以下完整配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
"provider": {
"YesCode": {
"npm": "@ai-sdk/openai",
"name": "YesCode",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-api-key-here",
"setCacheKey": true
},
"models": {
"gpt-5.2-xhigh": {
"id": "gpt-5.2",
"name": "GPT-5.2-xhigh",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": false,
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"cost": {
"input": 1.75,
"output": 14,
"cache_read": 0.175
},
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"reasoningEffort": "xhigh",
"textVerbosity": "medium",
"reasoningSummary": "auto"
}
}
}
},
"YesClaude": {
"npm": "@ai-sdk/anthropic",
"name": "YesClaude",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-api-key-here"
},
"models": {
"claude-opus-4-5-20251101": {
"id": "claude-opus-4-5-20251101",
"name": "Claude Opus 4.5",
"attachment": true,
"reasoning": true,
"tool_call": true,
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
},
"cost": {
"input": 5,
"output": 25,
"cache_read": 0.5,
"cache_write": 6.25
},
"limit": {
"context": 200000,
"output": 64000
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 32000
}
}
}
}
},
"YesGemini": {
"npm": "@ai-sdk/google",
"name": "YesGemini",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "your-api-key-here"
},
"models": {
"gemini-3-pro-preview": {
"id": "gemini-3-pro-preview",
"name": "Gemini 3 Pro Preview",
"attachment": true,
"reasoning": true,
"tool_call": true,
"modalities": {
"input": ["text", "image", "video", "audio", "pdf"],
"output": ["text"]
},
"cost": {
"input": 2,
"output": 12,
"cache_read": 0.2
},
"limit": {
"context": 1048576,
"output": 65536
}
}
}
}
}
}
  1. 运行 /models 选择模型

配置参考

优势

  • 国内访问稳定
  • 支持多个主流模型(Claude、OpenAI、Gemini)
  • 价格相对官方 API 更经济
  • 无需信用卡和海外支付方式

注意:第三方服务的稳定性和隐私政策请自行评估。建议不要在生产环境处理敏感数据。


Oh-My-OpenCode 配置

Oh-My-OpenCode 的配置文件位于:

  • 全局:~/.config/opencode/oh-my-opencode.json
  • 项目:.opencode/oh-my-opencode.json

完整配置示例

~/.config/opencode/oh-my-opencode.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
"$schema": "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json",
"google_auth": false,
"background_task": {
"defaultConcurrency": 5,
"providerConcurrency": {
"anthropic": 3,
"openai": 5,
"google": 10,
"azure": 5
},
"modelConcurrency": {
"sssaicode/claude-opus-4-5-20251101": 3,
"sssaicode/claude-haiku-4-5-20251001": 3,
"YesCode/gpt-5.2": 5,
"YesCode/gpt-5.2-xhigh": 5,
"YesCode/gpt-5.2-codex": 5,
"google/antigravity-gemini-3-pro-high": 3,
"google/antigravity-gemini-3-flash": 10
}
},
"sisyphus_agent": {
"disabled": false,
"planner_enabled": true,
"replace_plan": true
},
"disabled_agents": [
"comment-checker"
],
"disabled_hooks": [
"comment-checker"
],
"disabled_mcps": [],
"hooks": {
"PostToolUse": [
{
"type": "playwright",
"command": "Run browser tests for UI responsiveness"
}
]
},
"agents": {
"Sisyphus": {
"model": "YesCode/gpt-5.2-xhigh",
"description": "Complex reasoning and analysis"
},
"oracle": {
"model": "YesCode/gpt-5.2-xhigh",
"description": "High complexity logic and problem solving"
},
"librarian": {
"model": "sssaicode/claude-opus-4-5-20251101",
"description": "Text understanding and literary style"
},
"Creative-Poet": {
"model": "sssaicode/claude-haiku-4-5-20251001",
"description": "Poetry and creative writing"
},
"document-writer": {
"model": "YesCode/gpt-5.2",
"description": "Daily text generation"
},
"CodeMaster": {
"model": "YesCode/gpt-5.2-codex",
"description": "Programming and code generation"
},
"frontend-ui-ux-engineer": {
"model": "google/antigravity-gemini-3-pro-high",
"description": "Multimodal creative tasks and design"
},
"explore": {
"model": "google/antigravity-gemini-3-flash",
"description": "Fast multimodal exploration"
},
"multimodal-looker": {
"model": "google/antigravity-gemini-3-flash",
"description": "Image, PDF, and text processing"
}
}
}

配置字段说明

基础配置

字段 说明 默认值
google_auth 是否使用 Google OAuth 认证 false
$schema JSON Schema 路径,用于 IDE 自动补全 -

Sisyphus Agent 配置

字段 说明 默认值
sisyphus_agent.disabled 禁用 Sisyphus 主 Agent false
sisyphus_agent.planner_enabled 启用任务规划器 true
sisyphus_agent.replace_plan 替换默认 plan Agent true

Hooks 配置

Hooks 允许在特定时机执行自定义操作:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"hooks": {
"PostToolUse": [
{
"type": "playwright",
"command": "Run browser tests for UI responsiveness"
}
],
"PreToolUse": [
{
"type": "custom",
"command": "Validate input before execution"
}
]
}
}

可用的 Hook 时机

  • PreToolUse:工具使用前
  • PostToolUse:工具使用后
  • UserPromptSubmit:用户提交提示后
  • Stop:任务停止时

禁用特定组件

1
2
3
4
5
{
"disabled_agents": ["comment-checker"],
"disabled_hooks": ["comment-checker"],
"disabled_mcps": []
}
字段 说明
disabled_agents 禁用的 Agent 列表
disabled_hooks 禁用的 Hook 列表
disabled_mcps 禁用的 MCP 服务列表

Agent 角色说明

Agent 推荐模型 用途
Sisyphus GPT-5.2-xhigh 主 Agent,复杂推理和分析
oracle GPT-5.2-xhigh 架构决策、调试、高复杂度问题
librarian Claude Opus 4.5 文档搜索、文学风格、上下文理解
Creative-Poet Claude Haiku 4.5 诗歌、创意写作
document-writer GPT-5.2 日常文本生成、技术文档
CodeMaster GPT-5.2 Codex 编程、代码生成、重构
frontend-ui-ux-engineer Gemini 3 Pro High 前端开发、UI/UX 设计、多模态创意
explore Gemini 3 Flash 快速代码库探索、多模态搜索
multimodal-looker Gemini 3 Flash 图像、PDF、文本处理

提示:你可以根据实际使用的提供商和模型调整配置。

后台任务并发控制

Oh-My-OpenCode 支持并行运行多个后台 Agent,通过 background_task 配置控制并发数量,防止 API 限流。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"background_task": {
"defaultConcurrency": 5,
"providerConcurrency": {
"anthropic": 3,
"openai": 5,
"google": 10,
"azure": 5
},
"modelConcurrency": {
"anthropic/claude-opus-4": 2,
"anthropic/claude-sonnet-4-5": 3,
"anthropic/claude-haiku-4-5": 5,
"openai/gpt-4o": 3,
"google/gemini-2.5-pro": 3,
"google/gemini-2.5-flash": 10
}
}
}

参数说明

参数 说明 推荐值
defaultConcurrency 默认并发数,当未指定提供商或模型时使用 5
providerConcurrency 按提供商设置的最大并发数 -
modelConcurrency 按具体模型设置的最大并发数(优先级最高) -

提供商并发建议

提供商 推荐并发 说明
anthropic 3 Claude API 限流较严格
openai 5 OpenAI 中等限流
google 10 Gemini 限流相对宽松
azure 5 Azure OpenAI 中等限流

模型并发建议

模型类型 推荐并发 说明
高端模型(Opus、GPT-4o) 2-3 成本高、响应慢,降低并发
标准模型(Sonnet、GPT-4-turbo) 3-5 平衡性能和成本
轻量模型(Haiku、Flash) 5-10 响应快、成本低,可提高并发

工作原理

  1. 优先级modelConcurrency > providerConcurrency > defaultConcurrency
  2. 队列管理:超出并发限制的任务会排队等待
  3. 自动切换:当某个提供商达到限制时,可能自动切换到备用提供商

禁用特定功能

1
2
3
4
5
{
"disabled_agents": ["comment-checker"],
"disabled_hooks": ["comment-checker"],
"disabled_mcps": []
}

使用 OpenCode

启动 OpenCode

1
2
3
# 在项目目录中启动
cd /path/to/your/project
opencode

初始化项目

首次使用时,运行初始化命令让 OpenCode 分析项目结构:

1
/init

这会在项目根目录创建 AGENTS.md 文件,帮助 AI 理解项目。

提示:建议将 AGENTS.md 提交到 Git。

基本操作

提问

1
How is authentication handled in @src/auth/index.ts

提示:使用 @ 键可以模糊搜索项目文件。

切换模式

Tab 键在两种模式间切换:

  • Build 模式(默认):可以修改文件
  • Plan 模式:只读模式,用于分析和规划

撤销/重做

1
2
/undo    # 撤销上一次更改
/redo # 重做

选择模型

1
/models

分享对话

1
/share

使用 Oh-My-OpenCode 的魔法关键词

安装 Oh-My-OpenCode 后,只需在提示中包含 **ultrawork**(或简写 ulw),即可自动启用所有高级功能:

  • 并行后台 Agent
  • 深度代码探索
  • 自动任务规划
  • 持续执行直到完成

示例:

1
ulw 重构这个模块的认证逻辑,添加 JWT 支持

OpenCode 配置详解

完整配置示例

~/.config/opencode/opencode.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"oh-my-opencode",
"opencode-antigravity-auth"
],
"provider": {
"sssaicode": {
"npm": "@ai-sdk/anthropic",
"name": "ssscode",
"options": {
"baseURL": "https://claude3.sssaicode.com/api/v1",
"apiKey": "sk-sssaicode-xxxxxxxx",
"headers": {
"authorization": "Bearer sk-sssaicode-xxxxxxxx"
},
"setCacheKey": true
},
"models": {
"claude-opus-4-5-20251101": {
"name": "claude-opus-4-5-20251101"
},
"claude-haiku-4-5-20251001": {
"name": "claude-haiku-4-5-20251001"
},
"claude-sonnet-4-5-20250929": {
"name": "claude-sonnet-4-5-20250929"
}
}
},
"YesClaude": {
"npm": "@ai-sdk/anthropic",
"name": "YesClaude",
"options": {
"baseURL": "https://co.yes.vg/v1",
"apiKey": "cr_xxxxxxxx",
"headers": {
"authorization": "Bearer cr_xxxxxxxx"
},
"setCacheKey": true
},
"models": {
"claude-opus-4-5-20251101": {
"name": "claude-opus-4-5-20251101"
},
"claude-haiku-4-5-20251001": {
"name": "claude-haiku-4-5-20251001"
},
"claude-sonnet-4-5-20250929": {
"name": "claude-sonnet-4-5-20250929"
}
}
},
"YesCode": {
"npm": "@ai-sdk/openai",
"name": "YesCode",
"api": "https://co.yes.vg/v1",
"options": {
"setCacheKey": true,
"baseURL": "https://co.yes.vg/v1",
"apiKey": "cr_xxxxxxxx"
},
"models": {
"gpt-5.2-xhigh": {
"id": "gpt-5.2",
"name": "GPT-5.2-xhigh",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": false,
"release_date": "2025-12-11",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"cost": {
"input": 1.75,
"output": 14,
"cache_read": 0.175
},
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false,
"reasoningEffort": "xhigh",
"textVerbosity": "medium",
"reasoningSummary": "auto",
"include": ["reasoning.encrypted_content"]
}
},
"gpt-5.2": {
"id": "gpt-5.2",
"name": "GPT-5.2",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": false,
"release_date": "2025-12-11",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"cost": {
"input": 1.75,
"output": 14,
"cache_read": 0.175
},
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false,
"reasoningEffort": "high",
"textVerbosity": "medium",
"reasoningSummary": "auto",
"include": ["reasoning.encrypted_content"]
}
},
"gpt-5.2-codex": {
"id": "gpt-5.2-codex",
"name": "GPT-5.2 Codex",
"family": "gpt-5-codex",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": false,
"release_date": "2025-12-19",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"cost": {
"input": 1.75,
"output": 14,
"cache_read": 0.175
},
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false,
"reasoningEffort": "xhigh",
"textVerbosity": "medium",
"reasoningSummary": "auto",
"include": ["reasoning.encrypted_content"]
}
}
}
},
"google": {
"name": "Google",
"models": {
"antigravity-gemini-3-pro-high": {
"name": "Gemini 3 Pro High (Antigravity)",
"thinking": true,
"attachment": true,
"limit": {
"context": 1048576,
"output": 65535
},
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
},
"antigravity-gemini-3-pro-low": {
"name": "Gemini 3 Pro Low (Antigravity)",
"thinking": true,
"attachment": true,
"limit": {
"context": 1048576,
"output": 65535
},
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
},
"antigravity-gemini-3-flash": {
"name": "Gemini 3 Flash (Antigravity)",
"attachment": true,
"limit": {
"context": 1048576,
"output": 65536
},
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
}
}
}
},
"tools": {
"lsp": true,
"grep": true,
"websearch": true,
"bash": true,
"write": true,
"edit": true
},
"permission": {
"edit": "allow",
"bash": "allow",
"write": "allow",
"read": "allow"
}
}

安全提示:请将示例中的 apiKey 替换为你自己的 API Key,不要泄露真实密钥。

Provider 配置说明

字段 说明
npm AI SDK 包名,如 @ai-sdk/anthropic@ai-sdk/openai
name 提供商显示名称
options.baseURL API 端点地址
options.apiKey API 密钥
options.headers 自定义请求头
options.setCacheKey 启用响应缓存
models 该提供商支持的模型列表

Model 配置说明

字段 说明
id 实际调用的模型 ID
name 模型显示名称
attachment 是否支持文件附件
reasoning 是否支持推理模式
tool_call 是否支持工具调用
temperature 是否支持温度参数
thinking 是否支持思考模式(Gemini)
modalities.input 支持的输入类型:textimagepdf
modalities.output 支持的输出类型
cost 成本配置(每百万 token)
limit.context 上下文窗口大小
limit.output 最大输出长度
options.reasoningEffort 推理强度:lowmediumhighxhigh

CLI 使用

OpenCode 也支持非交互式 CLI 模式:

1
2
3
4
5
6
7
8
9
10
11
# 单次运行
opencode run "解释这段代码的作用"

# 使用特定模型
opencode run --model anthropic/claude-sonnet-4-5 "写一个快速排序函数"

# 启动服务器模式
opencode serve

# 启动 Web 界面
opencode web

常见问题

Q: 安装后找不到 opencode 命令?

确保安装路径在 PATH 中。安装脚本会尝试以下位置(按优先级):

  1. $OPENCODE_INSTALL_DIR
  2. $XDG_BIN_DIR
  3. $HOME/bin
  4. $HOME/.opencode/bin

Q: Oh-My-OpenCode 安装失败?

  1. 确保已安装 Bun:bun --version
  2. 如果使用 Snap 安装的 Bun,请改用官方安装脚本
  3. 尝试使用 npx 替代 bunx

Q: 国内如何使用 Claude/OpenAI/Gemini?

方法 1:使用第三方 API 服务(推荐)

  • 使用如 YesCode API 等第三方服务
  • 配置方法见上文”第三方 API 服务”章节

方法 2:使用代理

  • 配置系统代理后,官方 API 可能可以访问
  • 需要有稳定的代理服务

方法 3:使用国内可访问的模型

  • DeepSeek(国内可直接访问)
  • 其他国产大模型

Q: API Key 存储在哪里?

API Key 通过 /connect 命令添加后,存储在:

1
~/.local/share/opencode/auth.json

Q: 如何更新 OpenCode?

1
2
3
4
5
6
# 如果启用了 autoupdate,会自动更新
# 或手动更新
npm update -g opencode-ai

# Homebrew
brew upgrade opencode

Q: 如何卸载 Oh-My-OpenCode?

1
bunx oh-my-opencode uninstall

Q: 第三方 API 服务安全吗?

需要注意的事项

  • ✅ 适用于个人项目和学习
  • ✅ 适用于非敏感数据处理
  • ⚠️ 不建议在生产环境使用
  • ⚠️ 不建议处理企业机密或用户隐私数据
  • ⚠️ 请仔细阅读服务商的隐私政策

建议

  • 使用环境变量而非硬编码 API Key
  • 定期更换 API Key
  • 避免在代码中包含敏感信息
  • 对重要项目使用官方 API 或自建模型

相关资源


最后更新: 2026 年 1 月 15 日
作者: 自由码农

支付宝打赏 微信打赏

如果文章对你有帮助,欢迎点击上方按钮打赏作者,更多功能请访问博客站



2026 年最强 AI 编程方案:让 Claude、GPT、Gemini 像团队一样协作
https://blog.fxcxy.com/2026/01/15/opencode-oh-my-opencoded的安装与使用/
作者
spatacus
发布于
2026年1月15日
许可协议