Skip to content

About

Google Antigravity OAuth plugin for OpenCode (Revived & Extended) - Unlocks Gemini 3.8 Flash, 3.7 Flash, 3.1 Pro & Claude 4.6

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

51 stars

Watchers

1 watching

Forks

Repository files navigation

Antigravity OAuth Plugin for OpenCode (Revived & Extended)

English | Español

License: MIT CI

Note

Community Revival & Extended Edition: This repository is an active, open-source continuation of the archived project by NoeFabris (and earlier work by @jenslys and CLIProxyAPI). It fixes critical upstream bugs and unlocks the newest Google Antigravity models.

Important

Project Status (October 2026) - Gemini 4 ("Argon") Compatibility Enabled.

  • Gemini 4 ("Argon") is supported for accounts with an entitled plan. Google offers Argon in the Antigravity ecosystem for Google AI Pro (paid, non-trial), Ultra and Enterprise. The plugin automatically handles official CLI signature headers for gemini-4 / argon and surfaces it via model_discovery.
  • Use Argon moderately: Frontier models like Argon consume account quota and burst windows significantly faster than Flash models. We invite users entitled to Argon to utilize it for complex architectural and reasoning tasks, but recommend keeping Gemini 3.8 Flash as the default workhorse for everyday high-volume tasks.
  • Plan matrix (October 2026): Argon and Claude Sonnet/Opus 5.5 require paid Google AI Pro, Ultra or Enterprise. Gemini 3.7 Flash, 3.6 Flash and 3.1 Pro are Enterprise-only. Consumer tiers retain Gemini 3.8 Flash, Claude Sonnet/Opus 4.6 and GPT-OSS 120B (with the latter two scheduled for sunset across all tiers on 2026-11-02).

What's New & Changed in this Fork (v2.0.0)

Release notes for the v2.0.0 line. Model availability described below reflects the state at that time. Since 2026-10-13, Gemini 3.7 Flash, 3.6 Flash and 3.1 Pro are Ultra / Enterprise-only and were pruned from the consumer catalog in v2.0.4; see Models for the current catalog and the project status note above for the Argon decision.

  • OpenCode v2 Native Engine & Variant Registration: Fully updated for OpenCode v2 (@opencode/cli 2.0+). Registers all models with explicit variants (low, medium, high, max) and status: active, preventing VariantUnavailableError.
  • New Real-Time Engine Stats (/antigravity-stats & antigravity_stats): Instant local diagnostic dashboard reporting per-account request distribution (OK / 429 / Errors), live health score, active rotation state, and thinking signature cache hit rate (without external network latency).
  • Integrated Health Metric in /antigravity-quota: Compact HEALTH column inside quota tables for immediate wellness inspection.
  • Persistent Engine Stats (antigravity-stats.json): Preserves health scores and usage counters across daemon/service restarts in ~/.config/opencode/antigravity-stats.json (auto-gitignored).
  • OpenCode v2 Dual-Compatibility Architecture: Fully compatible with both OpenCode v1 (opencode-ai 1.18.x) and OpenCode v2 (@opencode/cli 2.0+). Uses a polymorphic entrypoint that exports a standard v1 callable factory while exposing native v2 .id and lifecycle .setup(context) methods.
  • Native v2 Tool & Command Registries: Dispatches antigravity_quota, antigravity_stats, google_search, and /antigravity-quota slash command natively via OpenCode v2's domain transforms (context.tool.transform and context.command.transform).
  • Strict Tool Schema Sanitization (Fix HTTP 400 property is not defined): Cloud Code API backed by Protobuf rejects tool calls when schema required arrays contain properties not declared in properties. The normalizer recursively cleans parameter schemas, prunes orphan required keys, and enforces validation on pre-packaged functionDeclarations.
  • Model Addition: antigravity-gpt-oss-120b-medium: Integrated Antigravity's native 120B open-source model into OPENCODE_MODEL_DEFINITIONS with 131k context window and multi-account routing support.
  • Official Antigravity CLI Signature Parity: Synchronized client signature headers and User-Agent to antigravity/cli/<version> (aidev_client; os_type=linux; arch=amd64; cl=962369648; auth_method=consumer), matching the latest Google Antigravity binary release. The signature was pinned to 1.2.7 at the time; it is now resolved at startup from the CLI auto-updater endpoint (see docs/ANTIGRAVITY_API_SPEC.md).
  • OPSEC Safety Shield & Telemetry (safety_shield): Intercepts Google Gemini's safetyRatings in real-time. Emits UI warnings on high-risk classifications and automatically executes preventive account rotation (Account Shield) after consecutive triggers to disperse suspicious telemetry across your account pool.
  • Strip x-goog-api-key Header (Fix 400 API_KEY_INVALID): OpenCode automatically injects an AI Studio key into x-goog-api-key when intercepting generativelanguage.googleapis.com calls. Antigravity backend prioritized this header over Bearer auth, returning 400 API_KEY_INVALID. The header is now stripped alongside x-api-key.
  • Legacy gemini-cli Mode Removed (Definitive 403 #3501 Fix): Completely stripped legacy VS Code headers and -preview model fallbacks. All requests route cleanly through official Antigravity CLI signatures (aidev_client), eliminating false license errors across all accounts.
  • Configurable Safety Settings (safety_level): Uses Google's native moderation baseline by default (medium / BLOCK_MEDIUM_AND_ABOVE) to protect accounts, with configurable options for high and none (with explicit disclaimer).
  • Fixed 403 #3501 (SUBSCRIPTION_REQUIRED) on Flash: Removed decommissioned sandbox autopush endpoint from fallbacks so all requests route cleanly to live daily and prod endpoints.
  • Deprecated Gemini 3.5 Flash Removed: Fully removed antigravity-gemini-3.5-flash following Google's backend sunset, keeping only active models (Gemini 3.8 Flash, 3.7 Flash, 3.6 Flash, 3.1 Pro, and Claude 4.6).
  • Clean Install Model Whitelisting: Automatically injects a strict provider.google.whitelist in opencode.json on clean setup, hiding 18+ unauthenticated built-in Google AI Studio/Vertex models from the OpenCode model selector.
  • In-Flight 403 #3501 (SUBSCRIPTION_REQUIRED) Auto-Recovery: Intercepts project resolution failures and immediately provisions/links the companion project via onboardManagedProject without crashing the active agent session.
  • Auto-Update Commands: Includes /antigravity-update slash command and CLI updater (antigravity-update) for one-click plugin updates.
Enhancement What Was Broken Upstream How This Fork Fixes It
Automatic Slash Command Provisioning Slash commands like /antigravity-quota and /antigravity-update required manual file copying into ~/.config/opencode/command/. The plugin now automatically provisions antigravity-quota.md and antigravity-update.md on startup and configuration update.
Gemini 3.8 Flash Support Backend restricted the newest gemini-3.8-flash model to official CLI signatures. Added resolveAntigravityGemini38FlashBackendModel (→ gemini-3.8-flash-{low,medium,high}) and extended the CLI User-Agent spoofing regex to /gemini-3\.[78]-flash/i, unlocking Gemini 3.8 Flash (Low/Medium/High).
Dangling Model Turn Sanitization Interrupted tools or aborted sessions caused Gemini to reject requests with 400 "Requests ending with a model turn are not supported". Added automatic sanitizeEndingModelTurn pipeline for Gemini payloads + force-drop retry recovery (MODEL_TURN_RECOVERY_NEEDED).
Request Normalization & Clean Feedback Default filters caused false-positive blocks on coding and technical prompts with verbose legal notices. Standardized payload configurations for development tasks and added concise single-line notification handling.
⏱Server-Data-Driven Quota Exits Quota exhaustion retried blindly with backoff counters even when the server specified hours of wait time. Captures metadata.quotaResetTimeStamp / quotaResetDelay from Google RPC errors, stores exact future reset timestamps, and enforces max_all_blocked_wait_seconds (default 120s) with clear model-switch suggestions.
Native Dual-Window Quota Tool Quota required a separate external plugin or returned flat model lists. Embedded the official antigravity_quota tool directly into the auth plugin with full 5h Window + Weekly Window tracking and progress bars via /v1internal:retrieveUserQuotaSummary.
Gemini 3.7 Flash Support Backend returned 404 NOT_FOUND (rewritten as "enable preview access" or 429) when invoking gemini-3.7-flash. Discovered that Google restricts 3.7 Flash strictly to official CLI signatures. The plugin now dynamically presents the official Antigravity CLI client signature (antigravity/cli/...), unlocking full native access to Gemini 3.7 Flash (Low/Medium/High).
Fast Multi-Account Failover On quota exhaustion the plugin would spin waiting on the same account (60s+ backoffs). Default scheduling mode changed to balance with immediate QUOTA_EXHAUSTED failover (500ms) to the next account with quota.
IAM 403 / #3501 Auto-Recovery Requests failed with 403 IAM_PERMISSION_DENIED or SUBSCRIPTION_REQUIRED (#3501) on new/unprovisioned accounts. Automatic companion discovery + instant in-flight onboardManagedProject auto-recovery. Corrected metadata.platform to PLATFORM_UNSPECIFIED.
Gemini 3.6 Flash & Sunset of 3.5 Native multi-tier backend model resolution (gemini-3.6-flash-{low,medium,high}). Deprecated 3.5 Flash removed. Multi-tier thinking resolution support built into model-resolver.ts; deprecated 3.5 cleanly retired.
Clean CI & Community Standards Upstream had broken npm publishing actions and no rulesets. Replaced with clean, automated Node.js CI with 1,056 tests passing, security policies, and Dependabot groups.

Enable OpenCode to authenticate against Antigravity (Google's IDE) via OAuth so you can use Antigravity rate limits and access models like gemini-3.8-flash, claude-sonnet-4-6, claude-opus-4-6-thinking and gpt-oss-120b with your Google credentials.

What You Get

  • Gemini 3.8 Flash, Claude Opus 4.6 / Sonnet 4.6 and GPT-OSS 120B via Google OAuth - this is the complete consumer catalog; Gemini 3.7 Flash, 3.6 Flash and 3.1 Pro are Ultra / Enterprise-only and no longer registered
  • Multi-account support — add multiple Google accounts, auto-rotates when rate-limited
  • Request Normalization & Clean Feedback — optimized parameters prevent false-positives on development tasks; clean one-line message on filter notices
  • Slash Commands — /antigravity-quota to inspect dual-window limits, and /antigravity-stats for instant local metrics
  • Native Tools — antigravity_quota, antigravity_stats, and google_search tools registered directly in the agent runtime
  • Thinking models — extended thinking for Claude and Gemini 3 with configurable budgets / thinking levels
  • Google Search grounding — enable web search for Gemini models (auto or always-on)
  • Auto-recovery — handles session errors and tool failures automatically
  • Plugin compatible — works alongside other OpenCode plugins (oh-my-opencode, dcp, etc.)
  • Dual-Version Support — native compatibility with both OpenCode v1 (opencode-ai) and OpenCode v2 (@opencode/cli)

OpenCode v1 & v2 Architecture Compatibility

This plugin implements a polymorphic dual-compatibility entrypoint in index.ts:

  • OpenCode v1 (1.18.x / opencode-ai): Loads as a callable factory function:

    export default async function ({ client, directory }: PluginContext): Promise<PluginResult>

    Returns { auth, event, tool } hooks with full multi-account rotation and header interception.

  • OpenCode v2 (2.0.x / @opencode/cli): Loads as a native v2 plugin definition object:

    export default {
      id: "opencode-antigravity-auth",
      setup: async (context: V2Context) => cleanup
    }

    Registers native tools (context.tool.transform), commands (context.command.transform), models (context.model.transform) and the Google Antigravity OAuth integration (context.integration.transform), while sharing the unified account pool and config. This makes opencode auth login offer OAuth with Google (Antigravity) and appends every newly authorized account to the multi-account rotation pool.

No configuration changes are required when transitioning between OpenCode v1 and v2.


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

Option A: Direct from GitHub (Recommended)

Add to plugins in ~/.config/opencode/opencode.json:

{
  "plugins": ["github:JoshRob297/opencode-antigravity-auth"]
}

OpenCode v2 will automatically clone, build, and update the plugin directly from the official repository.

Option B: Local Directory (Development / Offline)

Clone and reference locally:

git clone https://github.com/JoshRob297/opencode-antigravity-auth.git /path/to/plugin
cd /path/to/plugin && npm install && npm run build

Then in ~/.config/opencode/opencode.json:

{
  "plugins": ["/path/to/plugin"]
}

Quick Start (Zero-Config in OpenCode v2)

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

    {
      "plugins": ["github:JoshRob297/opencode-antigravity-auth"]
    }
  2. Authenticate with Google:

    opencode auth login

    Select Google → OAuth with Google (Antigravity). (In SSH / Headless environments, the CLI automatically provides a direct URL to open on your browser and paste the verification code).

  3. Ready to use! In OpenCode v2, all models, variants, and thinking budgets are auto-registered dynamically. You can immediately run:

    opencode run "Hello" --model=google/antigravity-gemini-3.8-flash --variant=high

    (Optional: You can run /antigravity-setup inside OpenCode anytime to cleanly auto-format your opencode.json with recommended whitelists).


Models

Model Reference

Model Variants Description
antigravity-gemini-3.8-flash low, medium, high Gemini 3.8 Flash with thinking tiers (Default)
antigravity-claude-sonnet-4-6 low, medium, high, max Claude Sonnet 4.6
antigravity-claude-opus-4-6-thinking low, medium, high, max Claude Opus 4.6 with extended thinking
antigravity-gpt-oss-120b-medium low, medium, high GPT-OSS 120B open-source model

Manual models configuration (Optional / Advanced)

In OpenCode v2 this is not required because the plugin registers all models and variants automatically via model.transform. However, if you wish to pin custom token limits or override model names manually, you can add this to ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["github:JoshRob297/opencode-antigravity-auth"],
  "providers": {
    "google": {
      "models": {
        "antigravity-gemini-3.8-flash": {
          "name": "Gemini 3.8 Flash (Antigravity)",
          "limit": { "context": 1048576, "output": 65536 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
          "variants": {
            "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 } },
            "medium": { "thinkingConfig": { "thinkingBudget": 16384 } },
            "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
          }
        },
        "antigravity-gpt-oss-120b-medium": {
          "name": "GPT-OSS 120B (Antigravity)",
          "limit": { "context": 131072, "output": 8192 },
          "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
        }
      }
    }
  }
}

Model Discovery

The Antigravity backend reports which models each account can use. With model_discovery enabled the plugin registers the ones newer than the curated catalog on top of it, so a model released to your plan becomes selectable without waiting for a plugin release:

// ~/.config/opencode/antigravity.json
{
  "model_discovery": true
}
  • If your account has Argon or Claude 5.5, they show up. Gemini 4 Argon (gemini-4-argon, -low, -medium, -high) and the Claude Sonnet/Opus 5.5 successors are on the forward-only rule, so an AI Pro / Ultra / Enterprise account the backend lists them for gets the selector entry automatically - which matters on 2026-11-02, when Claude 4.6 and GPT-OSS 120B are removed for every plan. Discovery never claims support: it mirrors what the backend grants that account.
  • Quota notice on frontier models: Be advised that invoking Gemini 4 Argon burns through your 5-hour and weekly Antigravity quotas much faster than Flash models. Use it moderately for architectural decisions or tough problems, and keep Gemini 3.8 Flash as the high-throughput everyday engine.
  • Forward-only. Anything older than the curated workhorses (gemini-3.8-flash, Claude 4.6) stays out, curated ids are never duplicated, and ids measured as dead, retired or internal are filtered by a denylist. A 200 from the backend is not treated as proof of usability.
  • Best-effort. If the catalog lookup fails, the curated catalog is used and startup is unaffected.

Full behavior, limits and caveats: docs/CONFIGURATION.md.

Hiding Foreign Google Models

models.dev publishes a google provider with the full Gemini lineup. Because the Antigravity OAuth credential makes that provider available, every one of those models shows up in the picker even though only the curated Antigravity models can be served. With hide_foreign_models enabled the plugin disables every google model that is not part of its curated catalog:

// ~/.config/opencode/antigravity.json
{
  "hide_foreign_models": true
}
  • Opt-in on purpose. If you have your own Google API key (GEMINI_API_KEY) the full models.dev list is valid, so the default is false.
  • Re-evaluated on every load, so a catalog refresh can no longer push the full Gemini lineup back into the selector.
  • Fail-open. An editor that cannot list models, or any error, leaves the list as is.

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):

  • Configure models — Auto-configure all plugin models in opencode.json
  • Check quotas — View remaining API quota for each account
  • Manage accounts — Enable/disable specific accounts for rotation

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


Request Handling, Safety & Feedback

Safety Levels (safety_level)

By default, the plugin mirrors Google's native moderation baseline (medium / BLOCK_MEDIUM_AND_ABOVE) to protect your accounts from telemetry anomalies.

You can configure safety_level in ~/.config/opencode/antigravity.json:

{
  "safety_level": "medium"
}

Available levels:

  • "medium" (Default) — Standard Google safety filters (BLOCK_MEDIUM_AND_ABOVE). Maximum account protection.
  • "high" — Blocks only high-probability harm (BLOCK_ONLY_HIGH). Recommended for extensive development, vulnerability analysis, and debugging.
  • "none" — Disables external safety classifiers (BLOCK_NONE) and bypasses prompt injection filters (HARM_CATEGORY_JAILBREAK).

DISCLAIMER: Setting safety_level to "none" is strictly for authorized security research and advanced workflows. Using "none" is done solely at your own discretion and risk. We accept no responsibility or liability for account reviews, suspensions, or bans enacted by Google.

OPSEC Safety Shield (safety_shield)

When operating with safety_level: "none", Google's backend still evaluates your queries and attaches safetyRatings probabilities (NEGLIGIBLE, LOW, MEDIUM, HIGH) to responses.

The plugin provides an active defense engine configured in ~/.config/opencode/antigravity.json:

{
  "safety_level": "none",
  "safety_shield": {
    "enabled": true,
    "log_ratings": true,
    "show_toast": true,
    "auto_rotate_threshold": 2
  }
}
  • log_ratings: Emits detailed warnings in logs whenever Google assigns HIGH harm or MEDIUM jailbreak probability to an answer.
  • show_toast: Displays non-blocking OPSEC warnings in OpenCode's interface ([OPSEC Shield] Google flagged response: ...).
  • auto_rotate_threshold: Number of consecutive high-risk responses on a single account before triggering an automatic, preventive rotation to the next Google account (Account Shield). This prevents risk clustering on individual personal accounts. Set to 0 to disable auto-rotation.

Concise Notification Handling

If a query triggers a backend moderation notice, the plugin intercepts the verbose response (which contains lengthy legal disclaimers, policy links, and bug report URLs) and replaces it with a clean, actionable notice:

[Solicitud bloqueada por filtros de seguridad de Gemini. Por favor, intenta reformular tu prompt o enfoque.]

This prevents chat clutter, session lockups, and unrecoverable error cascades.


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. Fixed in v1.7.0+ by automatic discovery of the account's real managedProjectId.

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": "your@email.com",
          "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:

{
  "providers": {
    "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:

  • Tool schema incompatibility with Gemini's strict protobuf validation
  • MCP servers with malformed schemas
  • Plugin version regression

Solutions:

  1. Update to latest release from GitHub:

    { "plugins": ["github:JoshRob297/opencode-antigravity-auth"] }
  2. Disable MCP servers one-by-one to find the problematic one

  3. Add npm override:

    { "providers": { "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.8-flash" },
    "document-writer": { "model": "google/antigravity-gemini-3.8-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: plugins (v2) or plugin (v1)

In OpenCode v2, use the native plural key:

{
  "plugins": ["github:JoshRob297/opencode-antigravity-auth"]
}

OpenCode v1 uses the legacy singular key "plugin". The updater detects both automatically and preserves whichever convention your configuration uses.


Migrating Accounts Between Machines

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

  1. Ensure the plugin is installed in ~/.config/opencode/opencode.json ("plugins" or "plugin")
  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:

{
  "plugins": [
    "github:JoshRob297/opencode-antigravity-auth",
    "@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.8-flash" },
    "document-writer": { "model": "google/antigravity-gemini-3.8-flash" },
    "multimodal-looker": { "model": "google/antigravity-gemini-3.8-flash" }
  }
}

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

Plugins you don't need

  • gemini-auth plugins — Not needed. This plugin handles all Google OAuth.

Configuration

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

{
  "$schema": "https://raw.githubusercontent.com/JoshRob297/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

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 & Transport Resilience

Option Default What it does
soft_quota_threshold_percent 100 Skip account when quota usage exceeds this percentage. Defaults to 100 (disabled) to avoid premature account exhaustion lockouts on low quotas. Set to 90 for conservative protection against Google penalties.
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_quota_cache_ttl_minutes to determine cache freshness - if cache is older, the account is considered "unknown" and allowed (fail-open). When ALL accounts exceed the threshold, the plugin waits for the earliest quota reset time (like rate limit behavior). If wait time exceeds max_rate_limit_wait_seconds, it errors immediately.

Transport Circuit Breaker & Tool Pruning (v2.3.0+): To prevent 60-second gateway TCP resets (ECONNRESET) caused by massive command/tool dumps, outputs exceeding 30,000 characters in historical turns (older than the last 2) are automatically pruned with a clear summary snippet. Furthermore, a circuit breaker halts runaway retries after 3 consecutive transport dropouts on the same session, prompting context compaction.

Rate Limit Scheduling

Control how the plugin handles rate limits:

Option Default What it does
scheduling_mode "cache_first" "cache_first" = wait for same account (preserves prompt cache), "balance" = switch immediately, "performance_first" = round-robin
max_cache_first_wait_seconds 60 Max seconds to wait in cache_first mode before switching accounts
failure_ttl_seconds 3600 Reset failure count after this many seconds (prevents old failures from permanently penalizing accounts)

When to use each mode:

  • cache_first (default): Best for long conversations. Waits for the same account to recover, preserving your prompt cache.
  • balance: Best for quick tasks. Switches accounts immediately when rate-limited for maximum availability.
  • performance_first: Best for many short requests. Distributes load evenly across all accounts.

App Behavior

Option Default What it does
quiet_mode false Hide toast notifications
debug false Enable debug file logging (~/.config/opencode/antigravity-logs/)
debug_tui false Show debug logs in the TUI log panel (independent from debug)
auto_update true Auto-update plugin

For all options, see docs/CONFIGURATION.md.

Environment variables:

OPENCODE_CONFIG_DIR=/path/to/config opencode  # Custom config directory
OPENCODE_ANTIGRAVITY_DEBUG=1 opencode         # Enable debug file logging
OPENCODE_ANTIGRAVITY_DEBUG=2 opencode         # Verbose debug file logging
OPENCODE_ANTIGRAVITY_DEBUG_TUI=1 opencode     # Enable TUI log panel debug output

Troubleshooting

See the full Troubleshooting Guide for solutions to common issues including:

  • Auth problems and token refresh
  • "Model not found" errors
  • Session recovery
  • IAM and Google Cloud project permission errors
  • Safari OAuth issues
  • Plugin compatibility
  • Migration guides

Documentation

Translations:


Credits & Acknowledgments

This project stands on the shoulders of the open-source community:

License

MIT License. See LICENSE for details.

Legal

Intended Use

  • Personal / internal development only
  • Respect internal quotas and data handling policies
  • Not for production services or bypassing intended limits

Warning

By using this plugin, you acknowledge:

  • Terms of Service risk — This approach may violate ToS of AI model providers
  • Account risk — Providers may suspend or ban accounts
  • No guarantees — APIs may change without notice
  • Assumption of risk — You assume all legal, financial, and technical risks

Disclaimer

  • Not affiliated with Google. This is an independent open-source project.
  • "Antigravity", "Gemini", "Google Cloud", and "Google" are trademarks of Google LLC.

About

Google Antigravity OAuth plugin for OpenCode (Revived & Extended) - Unlocks Gemini 3.8 Flash, 3.7 Flash, 3.1 Pro & Claude 4.6

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

51 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages