前言
随着Code Agent的发展 效率与可用性已经大幅上涨
部分mcp服务器 (例如content7或者是定向检索代码的mcp服务器) 可以明显提升效果
方案选型
目前有多种方案提供选择 本文选择的是 中转方案 CPA反代反重力 提供 APi 给opencode使用
模型选择: 推荐 主模型使用 opus 细节使用 gpt5.2-codex 干活模型使用 gpt5.2
直接使用 已有 code agent (命令行方式)
claude code (claude )
codex (open-ai)
ccb (桥接 cc和 codex )地址: https://github.com/bfly123/claude_code_bridge
opencode(开源)
…
直接使用现成的 ide
cursor
antigravity(gemimi pro 官方的ide)
Qoder
…
中转
Gemini Pro 未提供API 可以使用 CLIProxyAPI (CPA)等工具 反代antigravity (反重力)提供 api 给 opencode使用
第三方购买 codex接口(少搞一层反代) 直接配置到opencode, 即可给opencode使用
OpenCode 简介
OpenCode 是一个开源的 AI 编码代理。它提供终端界面、桌面应用和 IDE 扩展等多种使用方式。
安装
安装 opencode
使用熟悉的包管理方式安装opencode
curl -fsSL https://opencode.ai/install | bash
npm install -g opencode-ai
pnpm install -g opencode-ai
# mac上 安装方式一
brew install anomalyco/tap/opencode
# mac上 方式二(推荐)手动下载release 解压版最新版 (地址: https://github.com/anomalyco/opencode/releases) 然后 解压配置环境变量
## 根据自己的系统选择对应的安装包
# mac上 intel 芯片安装 示例
curl -O https://github.com/anomalyco/opencode/releases/download/v1.1.21/opencode-darwin-x64.zip
# 解压
unzip opencode-darwin-x64.zip
## 将解压后的二进制可执行文件,放到自定义目录 并配置环境变量
## 检查安装版本
opencode -v
1.1.21
遇到opencode 提示已经损坏 打不开 解决思路
# /usr/local/develop/OpenCode-1.2.27/opencode 替换为自己的opencode安装位置
sudo xattr -r -d com.apple.quarantine /usr/local/develop/OpenCode-1.2.27/opencode
安装包管理(可选,但是推荐 )
这里选择的是 nodejs 中的 npx
许多 mcp 服务器使用了npx来启动, 如果仅使用 opencode 的话 可以不进行安装
安装CPA (CLIProxyAPI ) (已经有API账号 可忽略)
有成品账号代理直连,中转等方案能拿到api可以忽略此章节
这里使用 CLIProxyAPI 来代理反重力 转换成api提供给opencode使用
注意 CLIProxyAPI 更新比较频繁,注意及时更新,会修复bug和优化功能
1、下载最新的 release (https://github.com/router-for-me/CLIProxyAPI/releases) 并解压
> tree
.
├── LICENSE
├── README.md
├── README_CN.md
├── cli-proxy-api
└── config.example.yaml
1 directory, 5 files
2、修改配置文件 config.example.yaml 并修改成 config.yaml
proxy-url: socks5://127.0.0.1:xxxx # 你需要改成你的, 这里proxy用于访问google 所以ip需要纯净
allow-remote: false # 如果你在服务器上搭建, 则需要允许
secret-key: xxxxxx # 管理端密钥 一定要配置不然进不去
3、启动, 并访问 webu]
访问地址: http://localhost:8317/management.html
主页地址如下,输入上面设置的管理密钥即可登录

登录成功后页面

4、常用配置
基础设置开启 调试模式,并启用使用统计 检查代理设置 后续可以在这里直接修改代理地址

新增/修改 密钥
这个密钥 opencode 访问cpa接口 要使用

5、OAuth 登录 反重力
注意 这里需要 CLIProxyAPI 与 浏览器 一起经过代理,每天都需要重新登录一次

认证成功就可以用了

这个时候已经可以用了
6、查看可用额度

7、查看可用模型

模型列表是:
gemini-2.5-flash
gemini-3-pro-image-preview
gemini-2.5-computer-use-preview-10-2025
gemini-3-pro-preview
gemini-3-flash-preview
gemini-2.5-flash-lite
gemini-claude-sonnet-4-5
gemini-claude-opus-4-5-thinking
gemini-claude-sonnet-4-5-thinking
gpt-oss-120b-medium
注意 因为羊毛被薅太多 这里claude与gpt模型用量非常少
cpa可用api 官方网站: https://help.router-for.me/management/api
配置
默认在用户目录 ~/.config/opencode文件夹下,新建 opencode.json,如果你希望json里面可以编写注释的话,可以把后缀名改成jsonc`(下文oh-my-opencode也支持这种格式)。
opencode配置
{
"plugin": [
"oh-my-opencode"
],
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"options": {
"baseURL": "官方的地址",
"apiKey": "分配的key "
},
"models": {
// 注意,GPT系列似乎必须有下面的 include 和 store 字段及其内容,否则只能发送一条消息
"gpt-5.2": {
"options": {
"include": [
"reasoning.encrypted_content"
],
"store": false,
"reasoningEffort": "high",
"textVerbosity": "high",
"reasoningSummary": "auto",
},
},
"gpt-5.3-codex": {
"options": {
"include": [
"reasoning.encrypted_content"
],
"store": false,
"reasoningEffort": "high",
"textVerbosity": "high",
"reasoningSummary": "auto",
},
},
"gpt-5.4":{
"options": {
"include": [
"reasoning.encrypted_content"
],
"store": false,
"reasoningEffort": "high",
"textVerbosity": "high",
"reasoningSummary": "auto",
},
}
},
},
"cpa-claude": {
"npm": "@ai-sdk/anthropic",
"name": "cpa-claude",
"options": { "baseURL": "http://localhost:8317/v1" },
"models": {
"gemini-claude-opus-4-5-thinking": {
"name": "claude opus 4.5 thinking",
"thinking": true,
"attachment": true,
"limit": { "context": 200000, "output": 64000 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
},
"claude-opus-4-5-20251101": {
"name": "muluo claude opus 4.5",
"thinking": true,
"attachment": true,
"limit": { "context": 200000, "output": 64000 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
}
}
},
"cpa-gemini": {
"npm": "@ai-sdk/google",
"name": "cpa-gemini",
"options": { "baseURL": "http://localhost:8317/v1beta" },
"models": {
"gemini-3-pro-preview": {
"name": "Gemini 3 Pro preview (Antigravity)",
"thinking": true,
"attachment": true,
"limit": { "context": 1048576, "output": 65535 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
},
"gemini-3-flash-preview": {
"name": "Gemini 3 Flash (Antigravity)",
"attachment": true,
"limit": { "context": 1048576, "output": 65536 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
},
"gemini-2.5-flash-lite": {
"name": "Gemini 2.5 Flash Lite (Antigravity)",
"attachment": true,
"limit": { "context": 1048576, "output": 65536 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
}
}
},
"Antigravity": {
"npm": "@ai-sdk/google",
"name": "Antigravity",
"options": {
"baseURL": "http://localhost:8317/v1"
},
"models": {
"gemini-3-pro-preview": {
"name": "Gemini 3 Pro preview (Antigravity)",
"thinking": true,
"attachment": true,
"limit": {
"context": 1048576,
"output": 65535
},
"modalities": {
"input": [
"text",
"image",
"pdf"
],
"output": [
"text"
]
}
},
"gemini-3-flash-preview": {
"name": "Gemini 3 Flash (Antigravity)",
"attachment": true,
"limit": {
"context": 1048576,
"output": 65536
},
"modalities": {
"input": [
"text",
"image",
"pdf"
],
"output": [
"text"
]
}
},
"gemini-2.5-flash-lite": {
"name": "Gemini 2.5 Flash Lite (Antigravity)",
"attachment": true,
"limit": {
"context": 1048576,
"output": 65536
},
"modalities": {
"input": [
"text",
"image",
"pdf"
],
"output": [
"text"
]
}
}
}
},
"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"
]
}
}
}
}
}
}
使用
配置了环境变量后 即可在任意位置使用,使用shell工具 cd到需要打开的项目 进入根路径 输入 opencode ,即可打开 opencode窗口

接下来就可以愉快的使用了
opencode 配置代理与中转 与认证
opencode 需要手动写配置文件 ~/config/opencode/opencode.json
如果这边是中转的 api, 那么仅需要修改 opencode.json 中 修改 provider 中的 options.baseURL 示例 http://localhost:8317/…
新版本的 opencode 不会创建这个配置文件, 需要手动配置配置好后去 opencode 中配置 api 即可
你可以通过ai来自动生成配置文件
重点说明的是,配置后 需要 验证provider 如果 没有配置apiKey的话
ctrl+p 出来如下页面

然后选择 切换模型

再使用ctrl+a 连接provider

选择需要连接的 provider 然后输入key (如果是cpa的代理地址 这个key 是cpa的key 如果是官方或者第三方的地址 是第三个分配给你的key) 这个过程会卡顿一下 需要等待, 认证完后,后续就可以通过切换provider ,来使用你想使用的模型了。
参考:
{
"plugin": [
"oh-my-opencode"
],
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"options": {
"baseURL": "http://localhost:8317/v1",
"apiKey": "cpa的key "
},
"models": {
// 注意,GPT系列似乎必须有下面的 include 和 store 字段及其内容,否则只能发送一条消息
"gpt-5.2": {
"options": {
"include": [
"reasoning.encrypted_content"
],
"store": false,
"reasoningEffort": "high",
"textVerbosity": "high",
"reasoningSummary": "auto",
},
},
"gpt-5.3-codex": {
"options": {
"include": [
"reasoning.encrypted_content"
],
"store": false,
"reasoningEffort": "high",
"textVerbosity": "high",
"reasoningSummary": "auto",
},
},
"gpt-5.4":{
"options": {
"include": [
"reasoning.encrypted_content"
],
"store": false,
"reasoningEffort": "high",
"textVerbosity": "high",
"reasoningSummary": "auto",
},
}
},
},
"cpa-claude": {
"npm": "@ai-sdk/anthropic",
"name": "cpa-claude",
"options": { "baseURL": "http://localhost:8317/v1" },
"models": {
"gemini-claude-opus-4-6-thinking": {
"name": "claude opus 4.5 thinking",
"thinking": true,
"attachment": true,
"limit": { "context": 200000, "output": 64000 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
},
"claude-opus-4-5-20251101": {
"name": "muluo claude opus 4.5",
"thinking": true,
"attachment": true,
"limit": { "context": 200000, "output": 64000 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
}
}
},
"cpa-gemini": {
"npm": "@ai-sdk/google",
"name": "cpa-gemini",
"options": { "baseURL": "http://localhost:8317/v1beta" },
"models": {
"gemini-3-pro-preview": {
"name": "Gemini 3 Pro preview (Antigravity)",
"thinking": true,
"attachment": true,
"limit": { "context": 1048576, "output": 65535 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
},
"gemini-3-flash-preview": {
"name": "Gemini 3 Flash (Antigravity)",
"attachment": true,
"limit": { "context": 1048576, "output": 65536 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
},
"gemini-2.5-flash-lite": {
"name": "Gemini 2.5 Flash Lite (Antigravity)",
"attachment": true,
"limit": { "context": 1048576, "output": 65536 },
"modalities": {
"input": ["text", "image", "pdf"],
"output": ["text"]
}
}
}
},
"Antigravity": {
"npm": "@ai-sdk/google",
"name": "Antigravity",
"options": {
"baseURL": "http://localhost:8317/v1"
},
"models": {
"gemini-3-pro-preview": {
"name": "Gemini 3 Pro preview (Antigravity)",
"thinking": true,
"attachment": true,
"limit": {
"context": 1048576,
"output": 65535
},
"modalities": {
"input": [
"text",
"image",
"pdf"
],
"output": [
"text"
]
}
},
"gemini-3-flash-preview": {
"name": "Gemini 3 Flash (Antigravity)",
"attachment": true,
"limit": {
"context": 1048576,
"output": 65536
},
"modalities": {
"input": [
"text",
"image",
"pdf"
],
"output": [
"text"
]
}
},
"gemini-2.5-flash-lite": {
"name": "Gemini 2.5 Flash Lite (Antigravity)",
"attachment": true,
"limit": {
"context": 1048576,
"output": 65536
},
"modalities": {
"input": [
"text",
"image",
"pdf"
],
"output": [
"text"
]
}
}
}
},
"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"
]
}
}
}
}
}
}
安装oh my opencode
使用opencode agent 安装
既然都安装了 opencode 不妨来试试
直接将 oh my opencode 项目地址发送给 opencode 来让他帮你安装吧
https://github.com/code-yeongyu/oh-my-opencode
注意 这里opencode 会自动帮你安装 bunx 来安装这个项目, 如果不想要的话 需要强调使用npx安装
oh my opencode 也可以用来登录反重力账号, 插件名称是 opencode-antigravity-auth, 将反重力支持模型到opencode中运行 但如果之前使用 CLIProxyAPI 来使用反重力, 则无需安装这个插件
手动
详见文档, 这里仅作记录
bunx oh-my-opencode install
# or use npx if bunx doesn't work
npx oh-my-opencode install
配置文件
之前使用我们自己的 opencode 配置文件 这里当然需要自行配置 oh-my-opencode 的配置文件, 当然你也可以让ai来做这件事情 详见文档
这里摘抄一下每个agent是干什么的
Sisyphus (anthropic/claude-opus-4-5):默认 Agent。 OpenCode 专属的强力 AI 编排器。指挥专业子 Agent 搞定复杂任务。主打后台任务委派和 Todo 驱动。用 Claude Opus 4.5 加上扩展思考(32k token 预算),智商拉满。
oracle (openai/gpt-5.2):架构师、代码审查员、战略家。GPT-5.2 的逻辑推理和深度分析能力不是盖的。致敬 AmpCode。
librarian (anthropic/claude-sonnet-4-5 或 google/gemini-3-flash):多仓库分析、查文档、找示例。配置 Antigravity 认证时使用 Gemini 3 Flash,否则使用 Claude Sonnet 4.5 深入理解代码库,GitHub 调研,给出的答案都有据可查。致敬 AmpCode。
explore (opencode/grok-code、google/gemini-3-flash 或 anthropic/claude-haiku-4-5):极速代码库扫描、模式匹配。配置 Antigravity 认证时使用 Gemini 3 Flash,Claude max20 可用时使用 Haiku,否则用 Grok。致敬 Claude Code。
frontend-ui-ux-engineer (google/gemini-3-pro-preview):设计师出身的程序员。UI 做得那是真漂亮。Gemini 写这种创意美观的代码是一绝。
document-writer (google/gemini-3-pro-preview):技术写作专家。Gemini 文笔好,写出来的东西读着顺畅。
multimodal-looker (google/gemini-3-flash):视觉内容专家。PDF、图片、图表,看一眼就知道里头有啥。
oh-my-opencode 配置示例
{
"$schema": "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json",
"google_auth": false,
"agents": {
"sisyphus": {
"model": "cpa-claude/gemini-claude-opus-4-6-thinking"
},
"librarian": {
"model": "cpa-gemini/gemini-3-flash"
},
"explore": {
"model": "cpa-gemini/gemini-3-flash"
},
"oracle": {
// openai/gpt-5.3-codex
"model": "openai/gpt-5.4"
},
"multimodal-looker": {
"model": "cpa-gemini/gemini-3-flash"
},
"prometheus": {
"model": "cpa-claude/gemini-claude-opus-4-6-thinking"
},
"metis": {
// gpt-5.2
"model": "openai/gpt-5.4"
},
"momus": {
"model": "openai/gpt-5.4"
},
"atlas": {
"model": "openai/gpt-5.4"
},
"Hephaestus": {
"model": "openai/gpt-5.4"
}
},
"categories": {
"writing": {
"model": "cpa-gemini/gemini-3-flash"
},
"quick": {
"model": "opencode/glm-4.7-free"
},
"visual-engineering": {
"model": "cpa-gemini/gemini-3.1-pro-low"
},
"ultrabrain": {
"model": "openai/gpt-5.4",
"variant": "xhigh"
},
"artistry": {
"model": "cpa-gemini/gemini-3.1-pro-high",
"variant": "max"
},
"unspecified-low": {
"model": "opencode/minimax-m2.5-free"
},
"unspecified-high": {
"model": "openai/gpt-5.4"
},
"deep": {
"model": "openai/gpt-5.4",
"variant": "xhigh"
}
}
}
魔法词语
oh my opencode 有一些魔法词 这里摘抄一下 在提示词里面出现这些词会激活特殊模式
关键词检测器:自动检测提示中的关键词并激活专门模式:
ultrawork / ulw:最大性能模式,带并行智能体编排
search / find / 찾아 / 検索:最大化搜索力度,带并行 explore 和 librarian 智能体
analyze / investigate / 분석 / 調査:深度分析模式,带多阶段专家咨询
问题
1、接口大面积 429
复活方案:打开Antigravity,使用Antigravity Cockpit插件,在自动唤醒(Auto Wake-up)下点击立即测试(Test Now)按钮,有几个号429就选几个号,每种模型勾一个。然后看一下历史里,有几个号正常返回就活了几个号。



参考: https://linux.do/t/topic/1461174
文档:
Opencode 文档: https://opencode.ai/docs/zh-cn
oh-my-opencode 中文文档: https://github.com/code-yeongyu/oh-my-opencode/blob/dev/README.zh-cn.md
Oh-my-opencode 文档: https://github.com/code-yeongyu/oh-my-opencode?tab=readme-ov-file#oh-my-opencode
https://linux.do/t/topic/1404993
good day!!!

1744

被折叠的 条评论
为什么被折叠?



