Antigravity gives you free Claude and Gemini Pro in OpenCode — but the setup has hidden traps. Here's every pitfall I hit and how to fix them.
What's Antigravity?
Pitfall 1: Antigravity Hijacks ALL Google SDK Requests
Json
// Provider 1: Antigravity OAuth (free Pro + Claude)
"google": {
"id": "google",
"api": "@ai-sdk/google",
"models": {
"antigravity-gemini-3-pro": { "name": "Gemini 3 Pro (AG)" },
"antigravity-gemini-3-flash": { "name": "Gemini 3 Flash (AG)" }
}
}
// Provider 2: Your API key (isolated from Antigravity)
"gemini": {
"id": "gemini",
"api": "@ai-sdk/google",
"apiKey": "AIzaSy...",
"models": {
"gemini-2.5-flash": { "name": "Gemini 2.5 Flash" }
}
}
Pitfall 2: Google Student Pro ≠ API Quota
| Model | Free API Quota | Paid API (Billing enabled) |
|---|---|---|
| Flash series | ✅ Yes | ✅ |
| Pro series | ❌ No | ✅ |
Pitfall 3: Gemini Rejects Complex MCP Tool Schemas
| MCP Server | Broken Schemas | Root Cause |
|---|---|---|
| Notion | 66 | anyOf/oneOf + $ref/$defs |
| Memory | 4 | oneOf (tags field accepts array or string) |
| Lark-MCP | Many | Complex API schemas |
Pitfall 4: Model Name Collisions + models.dev Pollution
- Prefix Antigravity models with antigravity- to avoid ID collisions with API key models
- Add a whitelist to every custom provider:
Json
"google": {
"whitelist": [
"antigravity-gemini-3-pro",
"antigravity-gemini-3-flash",
"antigravity-claude-opus-4-6-thinking"
],
"models": { ... }
}
- Clear the model cache after any config change:
Bash
rm ~/.cache/opencode/models.json
Pitfall 5: The Debug Command You Should Run First
Bash
opencode auth debug google
Troubleshooting Checklist
- opencode auth debug google — read the actual error
- Can you reach Google? (Proxy needed in China)
- Are you assuming Student Pro gives API quota? (It doesn't)
- Is your API key request being hijacked by Antigravity? (Check dual-provider config)
- Does your MCP tool use anyOf/oneOf in its schema? (Gemini can't handle it)
- Is the model cache stale? (rm ~/.cache/opencode/models.json)
This is a companion to my OpenCode provider setup guide. That post covers the full multi-provider configuration; this one digs into the auth-specific gotchas.
Antigravity 能让你在 OpenCode 里免费用 Claude 和 Gemini Pro——但配置过程暗坑不少。这篇记录我踩过的每一个坑和解法。
Antigravity 是什么?
坑 1:Antigravity 会劫持所有 Google SDK 请求
Json
// Provider 1: Antigravity OAuth(免费 Pro + Claude)
"google": {
"id": "google",
"api": "@ai-sdk/google",
"models": {
"antigravity-gemini-3-pro": { "name": "Gemini 3 Pro (AG)" },
"antigravity-gemini-3-flash": { "name": "Gemini 3 Flash (AG)" }
}
}
// Provider 2: API Key(独立通道,不过 Antigravity)
"gemini": {
"id": "gemini",
"api": "@ai-sdk/google",
"apiKey": "AIzaSy...",
"models": {
"gemini-2.5-flash": { "name": "Gemini 2.5 Flash" }
}
}
坑 2:Google Student Pro ≠ API 配额
| 模型 | 免费 API 配额 | 付费 API(需开 Billing) |
|---|---|---|
| Flash 系列 | ✅ 有 | ✅ |
| Pro 系列 | ❌ 没有 | ✅ |
坑 3:Gemini 不支持复杂的 MCP 工具 Schema
| MCP 服务 | 问题数 | 原因 |
|---|---|---|
| Notion | 66 | anyOf/oneOf + $ref/$defs |
| Memory | 4 | oneOf(tags 字段支持数组或字符串) |
| Lark-MCP | 多个 | 复杂 API schema |
坑 4:模型名冲突 + models.dev 模型灌入
- Antigravity 模型必须加 antigravity- 前缀,避免跟 API key provider 的模型 ID 冲突
- 每个自定义 provider 都加 whitelist:
Json
"google": {
"whitelist": [
"antigravity-gemini-3-pro",
"antigravity-gemini-3-flash",
"antigravity-claude-opus-4-6-thinking"
],
"models": { ... }
}
- 改完配置必须清模型缓存:
Bash
rm ~/.cache/opencode/models.json
坑 5:出问题第一步该跑的调试命令
Bash
opencode auth debug google
排查清单
- opencode auth debug google——看具体错误
- 能不能访问 Google?(国内需要代理)
- 是不是 Student Pro 订阅误以为有 Pro API 配额?(没有)
- API key 请求是不是被 Antigravity 劫持了?(检查双 provider 配置)
- MCP 工具的 schema 是不是用了 anyOf/oneOf?(Gemini 不兼容)
- 模型缓存是不是过期了?(rm ~/.cache/opencode/models.json)
这篇是我 OpenCode Provider 配置指南的姊妹篇。那篇讲完整的多 Provider 配置,这篇专挖认证环节的坑。