Antigravity Claude Proxy

repository·main·Indexed 26 days ago

https://github.com/badrisnarayanan/antigravity-claude-proxy

A proxy server that provides an Anthropic-compatible API by translating requests to Google Generative AI via Antigravity's Cloud Code. It enables the use of Claude and Gemini models within tools like the Claude Code CLI. The package includes a CLI (acc) for managing the background service, Google account OAuth authorization, and a web dashboard for configuration and account management.

Tokens
16.9K
Snippets
33
Records
106
Agent score
86%

What's inside antigravity-claude-proxy

  1. Understand the intended use and risks of Antigravity Claude Proxy

    main

    Antigravity Claude Proxy is designed strictly for personal or internal development use. It is not intended for production environments or high-volume automated tasks.

    Intended Use

    • Personal / internal development only.
    • Respect internal quotas and data handling policies.

    Not Suitable For

    • Production application traffic.
    • High-volume automated extraction.
    • Any use that violates the Acceptable Use Policies of AI model providers.

    Critical Risks

    • Terms of Service (ToS) Risk: Using this proxy may violate the Terms of Service of AI model providers (e.g., Anthropic, Google). You are responsible for ensuring compliance.
    • Account Risk: Providers may detect these usage patterns and take punitive actions, such as account suspension, permanent bans, or loss of paid subscriptions.
    • Stability Risk: Providers may change APIs, authentication methods, or policies at any time, which can break the proxy without notice.

    Use at your own risk.

  2. Start Antigravity Claude Proxy and OpenClaw

    main

    To run the integrated services, you need two terminal sessions:

    1. Terminal 1: Start the proxy server. By default, it binds to all interfaces. For security (especially on a VPS), bind it to localhost only.
    2. Terminal 2: Start the OpenClaw gateway.

    Prerequisites:

    • OpenClaw installed via npm install -g openclaw@latest.
    • Antigravity Claude Proxy running on port 8080.
    • At least one Google account linked to the proxy.
    # Terminal 1: Start the proxy (bind to localhost only for security)
    HOST=127.0.0.1 antigravity-claude-proxy start
    
    # Terminal 2: Start OpenClaw gateway
    openclaw gateway
  3. Configure OpenCode to use Antigravity Claude Proxy

    main

    To use Antigravity Claude Proxy with OpenCode, you must create a global configuration file at ~/.config/opencode/opencode.json. This allows OpenCode to access both Claude and Gemini models through the proxy via a single interactive picker.

    Ensure you have the following prerequisites:

    • OpenCode installed (npm install -g opencode-ai@latest)
    • Antigravity Claude Proxy running on port 8080
    • At least one Google account linked to the proxy
    mkdir -p ~/.config/opencode
    
    cat > ~/.config/opencode/opencode.json <<'EOF'
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "antigravity": {
          "npm": "@ai-sdk/anthropic",
          "name": "Antigravity Local",
          "options": {
            "baseURL": "http://localhost:8080/v1",
            "apiKey": "{env:ANTHROPIC_API_KEY}"
          },
          "models": {
            "claude-sonnet-4-6": { "id": "claude-sonnet-4-6", "name": "Claude Sonnet 4.6" },
            "claude-opus-4-6-thinking": { "id": "claude-opus-4-6-thinking", "name": "Claude Opus 4.6 Thinking" },
            "gemini-2.5-pro": { "id": "gemini-2.5-pro", "name": "Gemini 2.5 Pro" },
            "gemini-2.5-flash": { "id": "gemini-2.5-flash", "name": "Gemini 2.5 Flash" },
            "gemini-2.5-flash-lite": { "id": "gemini-2.5-flash-lite", "name": "Gemini 2.5 Flash Lite" },
            "gemini-2.5-flash-thinking": { "id": "gemini-2.5-flash-thinking", "name": "Gemini 2.5 Flash Thinking" },
            "gemini-3-flash": { "id": "gemini-3-flash", "name": "Gemini 3 Flash" },
            "gemini-3-flash-agent": { "id": "gemini-3-flash-agent", "name": "Gemini 3 Flash Agent" },
            "gemini-pro-agent": { "id": "gemini-pro-agent", "name": "Gemini 3.1 Pro Agent" },
            "gemini-3.1-pro-low": { "id": "gemini-3.1-pro-low", "name": "Gemini 3.1 Pro Low" },
            "gemini-3.1-flash-lite": { "id": "gemini-3.1-flash-lite", "name": "Gemini 3.1 Flash Lite" },
            "gemini-3.1-flash-image": { "id": "gemini-3.1-flash-image", "name": "Gemini 3.1 Flash Image" },
            "gemini-3.5-flash-low": { "id": "gemini-3.5-flash-low", "name": "Gemini 3.5 Flash" }
          }
        }
      },
      "model": "antigravity/claude-sonnet-4-6",
      "small_model": "antigravity/gemini-3.5-flash-low"
    }
    EOF
  4. Monitor usage and analytics in the Web Console

    main

    The console includes monitoring tools for analyzing request patterns:

    • Real-time Dashboard: Monitor request volume, active accounts, model health, and subscription tier distribution.
    • Persistent History: Request volume by model family is tracked for 30 days and persists across server restarts.
    • Time Range Filtering: Analyze trends over 1H, 6H, 24H, 7D, or All Time.
    • Smart Analysis: Toggle between Family/Model views or auto-select the top 5 most used models.
  5. Set Environment Variables for the Proxy

    main

    Depending on your operating system and desired persistence, use the following methods to set environment variables for the proxy.

    #### Inline (single command)
    ```bash
    PORT=3000 HTTP_PROXY=http://proxy:8080 npm start

    macOS / Linux (persistent)

    Add to your shell profile (~/.zshrc or ~/.bashrc):

    export PORT=3000
    export HTTP_PROXY=http://proxy:8080

    Then reload: source ~/.zshrc

    Windows Command Prompt (persistent)

    setx PORT 3000
    setx HTTP_PROXY http://proxy:8080

    Windows PowerShell (persistent)

    [Environment]::SetEnvironmentVariable("PORT", "3000", "User")
    [Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://proxy:8080", "User")
  6. Set Proxy Environment Variables

    main

    You can set the proxy settings directly in your shell profile to ensure they take precedence over settings.json.

    macOS / Linux (Zsh/Bash)

    echo 'export ANTHROPIC_BASE_URL="http://localhost:8080"' >> ~/.zshrc
    echo 'export ANTHROPIC_AUTH_TOKEN="test"' >> ~/.zshrc
    source ~/.zshrc

    Windows (PowerShell)

    Add-Content $PROFILE "\n`$env:ANTHROPIC_BASE_URL = 'http://localhost:8080'"
    Add-Content $PROFILE "`$env:ANTHROPIC_AUTH_TOKEN = 'test'"
    . $PROFILE

    Windows (Command Prompt)

    setx ANTHROPIC_BASE_URL "http://localhost:8080"
    setx ANTHROPIC_AUTH_TOKEN "test"
  7. Verify and Manage OpenClaw Models

    main

    After configuring the proxy, use the OpenClaw CLI to verify that the models are correctly loaded and to switch between them.

    Commands:

    • openclaw models list: Lists all available models. Look for models prefixed with antigravity-proxy/.
    • openclaw status: Checks the current status of the gateway.
    • openclaw models set <model_id>: Sets a new default model (e.g., antigravity-proxy/claude-opus-4-6-thinking).
    # Check available models
    openclaw models list
    
    # Check gateway status
    openclaw status
    
    # Switch Models
    openclaw models set antigravity-proxy/claude-opus-4-6-thinking
  8. Set up Shell Environment for OpenCode and Proxy

    main

    Configure your shell environment to include the necessary environment variables for the proxy. The ANTHROPIC_API_KEY can be a dummy value as authentication is handled via linked Google accounts. The ANTHROPIC_BASE_URL must point to the proxy's /v1 endpoint.

    Run the following commands to update your .zshrc (or equivalent shell config):

    grep -q 'ANTHROPIC_API_KEY=' ~/.zshrc || echo 'export ANTHROPIC_API_KEY="dummy"' >> ~/.zshrc
    grep -q 'ANTHROPIC_BASE_URL=' ~/.zshrc || echo 'export ANTHROPIC_BASE_URL="http://localhost:8080/v1"' >> ~/.zshrc
    source ~/.zshrc
  9. Configure Account Selection Strategies

    main

    The proxy distributes requests across multiple accounts using one of three configurable strategies. You can set the strategy via the CLI when starting the server or through the Web UI.

    Strategies:

    • hybrid (Default): Smart selection combining health score, token bucket rate limiting, quota awareness, and LRU freshness. Best for most users.
    • sticky: Stays on the same account to maximize prompt caching hits; switches only when rate-limited. Best for prompt caching.
    • round-robin: Cycles through accounts sequentially. Best for even distribution.

    Configuration via CLI:

    antigravity-claude-proxy start --strategy=hybrid    # Default: smart distribution
    antigravity-claude-proxy start --strategy=sticky    # Cache-optimized
    antigravity-claude-proxy start --strategy=round-robin  # Load-balanced

    Configuration via Web UI: Navigate to SettingsServerAccount Selection Strategy.

    antigravity-claude-proxy start --strategy=hybrid
  10. Control the proxy server via the macOS Menu Bar App

    main

    The antigravity-claude-proxy-bar provides several native controls for managing your proxy instance:

    • Server Control: Start or stop the proxy server using a single click or the ⌘S keyboard shortcut.
    • Status Indicator: Monitor the server's running state via the menu bar icon.
    • WebUI Access: Quickly open the web management console from the menu.
    • Port Configuration: Customize the proxy server port (the default is 8080).
    • Account Selection Strategy: Configure load balancing strategies by choosing between Hybrid, Sticky, or Round-Robin.
    • Auto-Start Options: Enable the server to launch automatically when the app starts, or configure the app to launch automatically at macOS login.
  11. Authorize Google Accounts

    main

    To use the proxy, you must link Google accounts for authorization. You can use one of three methods:

    1. Open http://localhost:8080 in your browser.
    2. Go to the Accounts tab and click Add Account.
    3. Complete the Google OAuth flow. Note: For headless/remote servers, use the "Manual Authorization" mode in the WebUI to copy/paste the OAuth URL and code.

    Method B: CLI

    Desktop:

    antigravity-claude-proxy accounts add

    Headless (Docker/SSH):

    antigravity-claude-proxy accounts add --no-browser

    Method C: Automatic

    If you have the Antigravity app installed and logged in, the proxy detects your local session automatically.