opencode-antigravity-auth

repository·main·Indexed 27 days ago

https://github.com/noefabris/opencode-antigravity-auth

An authentication plugin for OpenCode that enables access to Google's Antigravity and Gemini CLI services via OAuth. It allows users to access high-tier models such as Claude 4.6 and Gemini 3.1 Pro, featuring multi-account rotation, automatic quota management, and support for both Antigravity and Gemini CLI quota pools.

Tokens
16.5K
Snippets
51
Records
102
Agent score
94%

What's inside opencode-antigravity-auth

  1. Antigravity Unified Gateway API Overview

    main
    Antigravity is a Unified Gateway API that provides a single, consistent Gemini-style interface to access multiple AI models, including Claude, Gemini, and GPT-OSS. It uses internal routing to direct requests to model backends (such as Vertex AI for Claude or the Gemini API for Gemini) and returns a unified response format using the candidates[] structure.
  2. Understand the Request Transformation Flow

    main

    The plugin intercepts requests to generativelanguage.googleapis.com and performs several transformations to make them compatible with the Antigravity API and Claude models:

    1. Model Detection: Identifies if the model is Claude or Gemini.
    2. Thinking Configuration: Adds thinkingConfig for supported thinking models.
    3. Thinking Stripping: Removes all thinking blocks from outgoing requests to prevent signature corruption.
    4. Tool Normalization: Converts tools into functionDeclarations[].
    5. Schema Cleaning: Sanitizes JSON Schemas by removing unsupported fields like const, $ref, $defs, default, examples, $schema, and title. Note that const: "value" is transformed into enum: ["value"].
    6. ID Assignment: Assigns IDs to tool calls using FIFO matching.
    7. Request Wrapping: Wraps the payload into the format { project, model, request: {...} }.
  3. Configure GitHub Actions to use the Raspberry Pi runner

    main

    Once your runner status shows as "Idle" (green) in your GitHub Repository settings, update your workflow file (e.g., .github/workflows/issue-triage.yml) to target the self-hosted runner.

    Use the runs-on key to specify the runner. You can use a generic label or a specific label if you have multiple self-hosted runners.

    runs-on: self-hosted
    # or specifically:
    # runs-on: [self-hosted, pi]
  4. Use Model Variants via CLI

    main

    OpenCode's variant system allows you to dynamically configure thinking budgets without needing separate model definitions for every level. When a model has variants defined in its configuration, you can select a specific variant using the --variant flag in the CLI. This passes the providerOptions to the plugin to set the thinking configuration.

    opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max
  5. Integrate with oh-my-opencode

    main

    When using oh-my-opencode, you must disable the built-in Google authentication to prevent conflicts. You should also override the agent models in your oh-my-opencode.json file.

    Example configuration for ~/.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" }
      }
    }
  6. Install the opencode-antigravity-auth plugin

    main

    To install the plugin, add it to the plugin array in your OpenCode configuration file located at ~/.config/opencode/opencode.json. You can use the @latest tag for stable releases or @beta for bleeding-edge features.

    After adding the plugin, run the login command to authenticate with your Google account:

    opencode auth login
    {
      "plugin": ["opencode-antigravity-auth@latest"]
    }
  7. Run E2E regression tests

    main

    The plugin includes regression tests that consume API quota. Use these commands to verify functionality:

    • --sanity: Runs 7 tests (approx. 5 min).
    • --heavy: Runs 4 tests (approx. 30 min).
    • --dry-run: Lists available tests without running them.
    npx tsx script/test-regression.ts --sanity      # 7 tests, ~5 min
    npx tsx script/test-regression.ts --heavy       # 4 tests, ~30 min
    npx tsx script/test-regression.ts --dry-run     # List tests
  8. Recommended configurations for different account setups

    main

    Use these pre-configured JSON objects based on your requirements:

    1 Account (Preserve prompt cache):

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

    2-3 Accounts (Smart rotation):

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

    3+ Accounts / Parallel Agents (Maximum throughput):

    {
      "$schema": "https://raw.githubusercontent.com/NoeFabris/opencode-antigravity-auth/main/assets/antigravity.schema.json",
      "account_selection_strategy": "round-robin",
      "switch_on_first_rate_limit": true,
      "pid_offset_enabled": true
    }
  9. Authenticate AI tools on your Raspberry Pi

    main

    After setting up the runner, you must authenticate tools like gh copilot and other AI utilities by running the auth-pi-tools.sh script (found in the scripts/ folder of this repository).

    # On your Pi
    chmod +x auth-pi-tools.sh
    ./auth-pi-tools.sh

    Follow the interactive login flows to complete authentication.

    chmod +x auth-pi-tools.sh
    ./auth-pi-tools.sh
  10. Handle Rate Limits and Shadow Bans

    main

    Google enforces strict quotas. If you experience hanging prompts or 403 errors, follow these steps:

    • Wait it out: Stop using the account for 24-48 hours.
    • Warm up accounts: Log in to Antigravity IDE and run simple prompts (e.g., "Hello") to reset internal flags.
    • Reduce volume: Use shorter sessions and avoid parallel subagents.
    • Fail fast: Set max_rate_limit_wait_seconds: 0 to avoid infinite retries.