opencode-antigravity-auth README

The project's README from github.com/NoeFabris/opencode-antigravity-auth. As one markdown file: README.md.

Antigravity + Gemini CLI OAuth Plugin for Opencode

npm version npm beta npm downloads License: MIT X (Twitter)

Enable Opencode to authenticate against Antigravity (Google's IDE) via OAuth so you can use Antigravity rate limits and access models like gemini-3.1-pro and claude-opus-4-6-thinking with your Google credentials.

What You Get


⚠️ Terms of Service Warning — Read Before Installing

[!CAUTION] Using this plugin (and any proxy for Antigravity) violates Google's Terms of Service. A number of users have reported their Google accounts being banned or shadow-banned (restricted access without explicit notification).

By using this plugin, you acknowledge:

  • This is an unofficial tool not endorsed by Google
  • Your account may be suspended or permanently banned
  • You assume all risks associated with using this plugin

Installation

For Humans

Option A: Let an LLM do it

Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):

Install the opencode-antigravity-auth plugin and add the Antigravity model definitions to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/NoeFabris/opencode-antigravity-auth/dev/README.md

Option B: Manual setup

  1. Add the plugin to ~/.config/opencode/opencode.json:

    {
      "plugin": ["opencode-antigravity-auth@latest"]
    }
    

    Want bleeding-edge features? Use opencode-antigravity-auth@beta instead.

  2. Login with your Google account:

    opencode auth login
    
  3. Add models — choose one:

    • Run opencode auth login → Google → OAuth with Google (Antigravity) → select "Configure models in opencode.json" (auto-configures all models)
    • Or manually copy the full configuration below
  4. Use it:

    opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max
    
For LLM Agents

Step-by-Step Instructions

  1. Edit the OpenCode configuration file at ~/.config/opencode/opencode.json

    Note: This path works on all platforms. On Windows, ~ resolves to your user home directory (e.g., C:\Users\YourName).

  2. Add the plugin to the plugin array

  3. Add the model definitions from the Full models configuration section

  4. Set provider to "google" and choose a model

Verification

opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max

Models

Model Reference

Antigravity quota (default routing for Claude and Gemini):

Model Variants Notes
antigravity-gemini-3-pro low, high Gemini 3 Pro with thinking
antigravity-gemini-3.1-pro low, high Gemini 3.1 Pro with thinking (rollout-dependent)
antigravity-gemini-3-flash minimal, low, medium, high Gemini 3 Flash with thinking
antigravity-claude-sonnet-4-6 — Claude Sonnet 4.6
antigravity-claude-opus-4-6-thinking low, max Claude Opus 4.6 with extended thinking

Gemini CLI quota (separate from Antigravity; used when cli_first is true or as fallback):

Model Notes
gemini-2.5-flash Gemini 2.5 Flash
gemini-2.5-pro Gemini 2.5 Pro
gemini-3-flash-preview Gemini 3 Flash (preview)
gemini-3-pro-preview Gemini 3 Pro (preview)
gemini-3.1-pro-preview Gemini 3.1 Pro (preview, rollout-dependent)
gemini-3.1-pro-preview-customtools Gemini 3.1 Pro Preview Custom Tools (preview, rollout-dependent)

Routing Behavior:

  • Antigravity-first (default): Gemini models use Antigravity quota across accounts.
  • CLI-first (cli_first: true): Gemini models use Gemini CLI quota first.
  • When a Gemini quota pool is exhausted, the plugin automatically falls back to the other pool.
  • Claude and image models always use Antigravity. Model names are automatically transformed for the target API (e.g., antigravity-gemini-3-flash → gemini-3-flash-preview for CLI).

Using variants:

opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max

For details on variant configuration and thinking levels, see docs/MODEL-VARIANTS.md.

Full models configuration (copy-paste ready)

Add this to your ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-antigravity-auth@latest"],
  "provider": {
    "google": {
      "models": {
        "antigravity-gemini-3-pro": {
          "name": "Gemini 3 Pro (Antigravity)",
          "limit": { "context": 1048576, "output": 65535 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
          "variants": {
            "low": { "thinkingLevel": "low" },
            "high": { "thinkingLevel": "high" }
          }
        },
        "antigravity-gemini-3.1-pro": {
          "name": "Gemini 3.1 Pro (Antigravity)",
          "limit": { "context": 1048576, "output": 65535 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
          "variants": {
            "low": { "thinkingLevel": "low" },
            "high": { "thinkingLevel": "high" }
          }
        },
        "antigravity-gemini-3-flash": {
          "name": "Gemini 3 Flash (Antigravity)",
          "limit": { "context": 1048576, "output": 65536 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
          "variants": {
            "minimal": { "thinkingLevel": "minimal" },
            "low": { "thinkingLevel": "low" },
            "medium": { "thinkingLevel": "medium" },
            "high": { "thinkingLevel": "high" }
          }
        },
        "antigravity-claude-sonnet-4-6": {
          "name": "Claude Sonnet 4.6 (Antigravity)",
          "limit": { "context": 200000, "output": 64000 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
        },
        "antigravity-claude-opus-4-6-thinking": {
          "name": "Claude Opus 4.6 Thinking (Antigravity)",
          "limit": { "context": 200000, "output": 64000 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
          "variants": {
            "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
            "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
          }
        },
        "gemini-2.5-flash": {
          "name": "Gemini 2.5 Flash (Gemini CLI)",
          "limit": { "context": 1048576, "output": 65536 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
        },
        "gemini-2.5-pro": {
          "name": "Gemini 2.5 Pro (Gemini CLI)",
          "limit": { "context": 1048576, "output": 65536 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
        },
        "gemini-3-flash-preview": {
          "name": "Gemini 3 Flash Preview (Gemini CLI)",
          "limit": { "context": 1048576, "output": 65536 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
        },
        "gemini-3-pro-preview": {
          "name": "Gemini 3 Pro Preview (Gemini CLI)",
          "limit": { "context": 1048576, "output": 65535 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
        },
        "gemini-3.1-pro-preview": {
          "name": "Gemini 3.1 Pro Preview (Gemini CLI)",
          "limit": { "context": 1048576, "output": 65535 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
        },
        "gemini-3.1-pro-preview-customtools": {
          "name": "Gemini 3.1 Pro Preview Custom Tools (Gemini CLI)",
          "limit": { "context": 1048576, "output": 65535 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
        }
      }
    }
  }
}

Backward Compatibility: Legacy model names with antigravity- prefix (e.g., antigravity-gemini-3-flash) still work. The plugin automatically handles model name transformation for both Antigravity and Gemini CLI APIs.


Multi-Account Setup

Add multiple Google accounts for a higher combined quota. The plugin automatically rotates between accounts when one is rate-limited.

opencode auth login  # Run again to add more accounts

Account management options (via opencode auth login):

For details on load balancing, dual quota pools, and account storage, see docs/MULTI-ACCOUNT.md.


Troubleshooting

Quick Reset: Most issues can be resolved by deleting ~/.config/opencode/antigravity-accounts.json and running opencode auth login again.

Configuration Path (All Platforms)

OpenCode uses ~/.config/opencode/ on all platforms including Windows.

File Path
Main config ~/.config/opencode/opencode.json
Accounts ~/.config/opencode/antigravity-accounts.json
Plugin config ~/.config/opencode/antigravity.json
Debug logs ~/.config/opencode/antigravity-logs/

Windows users: ~ resolves to your user home directory (e.g., C:\Users\YourName). Do NOT use %APPDATA%.

Custom path: Set OPENCODE_CONFIG_DIR environment variable to use a custom location.

Windows migration: If upgrading from plugin v1.3.x or earlier, the plugin will automatically find your existing config in %APPDATA%\opencode\ and use it. New installations use ~/.config/opencode/.


Multi-Account Auth Issues

If you encounter authentication issues with multiple accounts:

  1. Delete the accounts file:
    rm ~/.config/opencode/antigravity-accounts.json
    
  2. Re-authenticate:
    opencode auth login
    

403 Permission Denied (rising-fact-p41fc)

Error:

Permission 'cloudaicompanion.companions.generateChat' denied on resource 
'//cloudaicompanion.googleapis.com/projects/rising-fact-p41fc/locations/global'

Cause: Plugin falls back to a default project ID when no valid project is found. This works for Antigravity but fails for Gemini CLI models.

Solution:

  1. Go to Google Cloud Console
  2. Create or select a project
  3. Enable the Gemini for Google Cloud API (cloudaicompanion.googleapis.com)
  4. Add projectId to your accounts file:
    {
      "accounts": [
        {
          "email": "[email protected]",
          "refreshToken": "...",
          "projectId": "your-project-id"
        }
      ]
    }
    

Note: Do this for each account in a multi-account setup.


Gemini Model Not Found

Add this to your google provider config:

{
  "provider": {
    "google": {
      "npm": "@ai-sdk/google",
      "models": { ... }
    }
  }
}

Gemini 3 Models 400 Error ("Unknown name 'parameters'")

Error:

Invalid JSON payload received. Unknown name "parameters" at 'request.tools[0]'

Causes:

Solutions:

  1. Update to latest beta:

    { "plugin": ["opencode-antigravity-auth@beta"] }
    
  2. Disable MCP servers one-by-one to find the problematic one

  3. Add npm override:

    { "provider": { "google": { "npm": "@ai-sdk/google" } } }
    

MCP Servers Causing Errors

Some MCP servers have schemas incompatible with Antigravity's strict JSON format.

Common symptom:

Invalid function name must start with a letter or underscore

Sometimes it shows up as:

GenerateContentRequest.tools[0].function_declarations[12].name: Invalid function name must start with a letter or underscore

This usually means an MCP tool name starts with a number (for example, a 1mcp key like 1mcp_*). Rename the MCP key to start with a letter (e.g., gw) or disable that MCP entry for Antigravity models.

Diagnosis:

  1. Disable all MCP servers in your config
  2. Enable one-by-one until error reappears
  3. Report the specific MCP in a GitHub issue

"All Accounts Rate-Limited" (But Quota Available)

Cause: Cascade bug in clearExpiredRateLimits() in hybrid mode (fixed in recent beta).

Solutions:

  1. Update to latest beta version
  2. If persists, delete accounts file and re-authenticate
  3. Try switching account_selection_strategy to "sticky" in antigravity.json

Session Recovery

If you encounter errors during a session:

  1. Type continue to trigger the recovery mechanism
  2. If blocked, use /undo to revert to pre-error state
  3. Retry the operation

Using with Oh-My-OpenCode

Important: Disable the built-in Google auth to prevent conflicts:

// ~/.config/opencode/oh-my-opencode.json
{
  "google_auth": false,
  "agents": {
    "frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro" },
    "document-writer": { "model": "google/antigravity-gemini-3-flash" }
  }
}

Infinite .tmp Files Created

Cause: When account is rate-limited and plugin retries infinitely, it creates many temp files.

Workaround:

  1. Stop OpenCode
  2. Clean up: rm ~/.config/opencode/*.tmp
  3. Add more accounts or wait for rate limit to expire

OAuth Callback Issues

Safari OAuth Callback Fails (macOS)

Symptoms:

  • "fail to authorize" after successful Google login
  • Safari shows "Safari can't open the page"

Cause: Safari's "HTTPS-Only Mode" blocks http://localhost callback.

Solutions:

  1. Use Chrome or Firefox (easiest): Copy the OAuth URL and paste into a different browser.

  2. Disable HTTPS-Only Mode temporarily:

    • Safari > Settings (⌘,) > Privacy
    • Uncheck "Enable HTTPS-Only Mode"
    • Run opencode auth login
    • Re-enable after authentication
Port Conflict (Address Already in Use)

macOS / Linux:

# Find process using the port
lsof -i :51121

# Kill if stale
kill -9 <PID>

# Retry
opencode auth login

Windows (PowerShell):

netstat -ano | findstr :51121
taskkill /PID <PID> /F
opencode auth login
Docker / WSL2 / Remote Development

OAuth callback requires browser to reach localhost on the machine running OpenCode.

WSL2:

  • Use VS Code's port forwarding, or
  • Configure Windows → WSL port forwarding

SSH / Remote:

ssh -L 51121:localhost:51121 user@remote

Docker / Containers:

  • OAuth with localhost redirect doesn't work in containers
  • Wait 30s for manual URL flow, or use SSH port forwarding

Configuration Key Typo: plugin not plugins

The correct key is plugin (singular):

{
  "plugin": ["opencode-antigravity-auth@beta"]
}

Not "plugins" (will cause "Unrecognized key" error).


Migrating Accounts Between Machines

When copying antigravity-accounts.json to a new machine:

  1. Ensure the plugin is installed: "plugin": ["opencode-antigravity-auth@beta"]
  2. Copy ~/.config/opencode/antigravity-accounts.json
  3. If you get "API key missing" error, the refresh token may be invalid — re-authenticate

Known Plugin Interactions

For details on load balancing, dual quota pools, and account storage, see docs/MULTI-ACCOUNT.md.


Plugin Compatibility

@tarquinen/opencode-dcp

DCP creates synthetic assistant messages that lack thinking blocks. List this plugin BEFORE DCP:

{
  "plugin": [
    "opencode-antigravity-auth@latest",
    "@tarquinen/opencode-dcp@latest"
  ]
}

oh-my-opencode

Disable built-in auth and override agent models in oh-my-opencode.json:

{
  "google_auth": false,
  "agents": {
    "frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro" },
    "document-writer": { "model": "google/antigravity-gemini-3-flash" },
    "multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
  }
}

Tip: When spawning parallel subagents, enable pid_offset_enabled: true in antigravity.json to distribute sessions across accounts.

Plugins you don't need


Configuration

Create ~/.config/opencode/antigravity.json for optional settings:

{
  "$schema": "https://raw.githubusercontent.com/NoeFabris/opencode-antigravity-auth/main/assets/antigravity.schema.json"
}

Most users don't need to configure anything — defaults work well.

Model Behavior

Option Default What it does
keep_thinking false Preserve Claude's thinking across turns. Warning: enabling may degrade model stability.
session_recovery true Auto-recover from tool errors
cli_first false Route Gemini models to Gemini CLI first (Claude and image models stay on Antigravity).

Account Rotation

Your Setup Recommended Config
1 account "account_selection_strategy": "sticky"
2-5 accounts Default ("hybrid") works great
5+ accounts "account_selection_strategy": "round-robin"
Parallel agents Add "pid_offset_enabled": true

Quota Protection

Option Default What it does
soft_quota_threshold_percent 90 Skip account when quota usage exceeds this percentage. Prevents Google from penalizing accounts that fully exhaust quota. Set to 100 to disable.
quota_refresh_interval_minutes 15 Background quota refresh interval. After successful API requests, refreshes quota cache if older than this interval. Set to 0 to disable.
soft_quota_cache_ttl_minutes "auto" How long quota cache is considered fresh. "auto" = max(2 × refresh interval, 10 minutes). Set a number (1-120) for fixed TTL.

How it works: Quota cache is refreshed automatically after API requests (when older than quota_refresh_interval_minutes) and manually via "Check quotas" in opencode auth login. The threshold check uses `soft_quot

opencode-antigravity-auth (NoeFabris/opencode-antigravity-auth)

Searching Database…

这是什么?这是一个 OpenCode 插件,通过 Google OAuth 登录 Antigravity(Google 的 IDE),让 OpenCode 可以使用 Antigravity 的配额来运行 Gemini 3.1 Pro 和 Claude Opus 4.6-thinking 等模型。使用的是你自己的 Google 账号,无需单独的 API 密钥。
这是独立应用,还是只是 OpenCode 的附加组件?它只是一个插件,添加到 OpenCode 的配置数组中即可。它不能单独运行,设计上是与其他 OpenCode 插件一起使用的。
我该如何安装和配置它?在 ~/.config/opencode/opencode.json 的 plugin 数组中添加该插件,然后运行 'opencode auth login',选择 Google → OAuth with Google (Antigravity),再选择 'Configure models in opencode.json',即可自动添加所有模型定义。
我需要 Google Cloud API 密钥,还是只需要 Google 账号?正常使用时不需要单独的 API 密钥,通过 OAuth 用 Google 账号登录即可,还可以添加多个账号以合并更多配额。只有当你在 Gemini CLI 模型上遇到特定的 403 错误时,才需要创建一个启用了 Gemini API 的 Google Cloud 项目。
使用这个插件是否违反 Google 的服务条款?是的。README 明确警告这违反了 Google 的服务条款,有些用户因为使用它而导致 Google 账号被封禁或被暗中限制。
Windows、macOS 和 Linux 的设置有区别吗?配置路径在所有操作系统上都相同(~/.config/opencode/,包括 Windows,其中 ~ 仍指向用户的主文件夹),不过在 Safari/macOS、WSL2、SSH 和 Docker 中,OAuth 回调需要额外的设置步骤。
我的 Google 凭据存储在哪里?OAuth 账号数据以 JSON 文件的形式保存在本地的 OpenCode 配置文件夹中,插件不会将其发送到其他任何地方。
通过这个插件,我实际可以使用哪些模型?通过 Antigravity 配额可使用 Claude Opus 4.6 / Sonnet 4.6 以及 Gemini 3.1 Pro / Flash;通过单独的 Gemini CLI 配额可使用 Gemini 2.5 以及 Gemini 3 Pro/Flash。当其中一个资源池用完时,会自动在两个池之间切换。
多账号轮换是如何工作的?你可以添加多个 Google 账号,当某个账号被限速时,插件会自动切换到其他账号。根据账号数量的不同,它会采用粘性、混合或轮询(round-robin)策略。
这个项目还在积极维护吗?该仓库在 GitHub 上已被标记为已归档。虽然 README 描述的是一个仍在积极演进、并提供测试版(beta)通道的插件,但这个仓库已不再接收新的开发工作。
如果某个 MCP 服务器导致这个插件出错,怎么办?Antigravity 严格的 schema 校验可能会因格式错误的 MCP 工具 schema 而失败(例如工具名以数字开头)。解决办法是逐个禁用 MCP 服务器,或重命名有问题的工具键名,直到错误消失。
Creator
NoeFabris
Size
1.2 MB
Stars
10.9K
Age
10mo
Commits · 90 Days