Opencode Antigravity Auth Setup
[Created by Codex: 019ba92d-c995-77c0-b090-e9109492f53b]
Overview
Enable OpenCode to call Antigravity-backed models (Gemini 3 + Claude) using Google OAuth tokens, without API keys, via the opencode-antigravity-auth plugin.
Key Findings (What Broke)
- OpenCode stores provider credentials in
~/.local/share/opencode/auth.json. - OpenCode only runs the plugin’s
auth.loaderforgoogleif agooglecredential already exists in that auth store. - If there is no
googlecredential, OpenCode uses bundled@ai-sdk/google, which requiresGOOGLE_GENERATIVE_AI_API_KEYand fails withAI_LoadAPIKeyError. opencode auth login googleis not a provider shortcut.opencode auth login [url]treats the arg as a URL and tries/.well-known/opencode(sogooglecausesERR_INVALID_URL).
Workflow (Verified)
1) Install/enable plugin + models
- Ensure
~/.config/opencode/opencode.jsoncontains:"plugin": ["opencode-antigravity-auth@beta"]- provider
"google"models using theantigravity-prefix (recommended).
- Confirm models are visible:
opencode models google
2) Create a google OAuth credential (required for plugin loader)
- Run
opencode auth login(no args). - Select provider:
Google. - Select method:
OAuth with Google (Antigravity). - Verify:
opencode auth listshowsGoogle oauth.
3) Bootstrap workaround (verified)
If ~/.config/opencode/antigravity-accounts.json already exists (refresh tokens saved) but opencode auth list shows no credentials, bootstrap the google OAuth entry:
python ~/.codex/skills/opencode-antigravity-auth-setup/scripts/bootstrap_opencode_google_oauth.py
This writes a minimal stub to ~/.local/share/opencode/auth.json:
google.type=oauthgoogle.refresh="<refreshToken>|<projectId>|<managedProjectId>"google.access="",google.expires=0(the plugin refreshes on first use)
4) Run a model
opencode run "hello" --model=google/antigravity-gemini-3-pro
Troubleshooting
Symptom: AI_LoadAPIKeyError / “Google Generative AI API key is missing”
- Cause: plugin loader not running (no
googlecredential in~/.local/share/opencode/auth.json) - Fix: run Workflow step (2) or (3)
Symptom: OpenCode shows “Waiting for authorization…” forever
- Use the manual fallback flow (CLI prompt), or use the bootstrap script above.
- Check whether OpenCode actually stored the credential:
opencode auth list
Symptom: opencode auth login google fails
- Expected. Use
opencode auth loginwithout args.
Reference (Investigation)
- Read the investigation handoff at
references/investigation-opencode-antigravity-auth.md.