Caixiaopig 573ba57db6 feat: add --no-browser OAuth mode for headless servers
## Feature Description

Enables adding Google accounts on remote servers without a desktop
environment (headless Linux, Docker containers, SSH sessions) where
automatic browser opening is not possible. Users can manually copy the
authorization URL to a device with a browser, complete authentication,
and paste the authorization code back.

## Usage

npm run accounts:add -- --no-browser

## Code Architecture

### New Modules

1. oauth.js - extractCodeFromInput()
   - Parses user input (full callback URL or raw authorization code)
   - Extracts code and state parameters
   - Handles OAuth error responses

2. accounts.js - addAccountNoBrowser()
   - Account addition flow for no-browser mode
   - Displays authorization URL for manual copying
   - Waits for user to paste authorization code
   - Calls extractCodeFromInput to parse input
   - Completes OAuth flow and saves account

3. tests/test-oauth-no-browser.cjs
   - 13 unit tests covering valid URLs, raw codes, error handling, edge cases

### Modified Modules

1. accounts.js - interactiveAdd()
   - Added noBrowser parameter
   - Selects addAccount or addAccountNoBrowser based on mode

2. accounts.js - main()
   - Parses --no-browser CLI argument
   - Updated help information

## User Flow

┌─────────────────────────────────────────────────────────────┐
│                   Headless Server Terminal                   │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
            ┌─────────────────────────────────┐
            │ npm run accounts:add -- --no-browser │
            └─────────────────────────────────┘
                              │
                              ▼
            ┌─────────────────────────────────┐
            │   Display Google OAuth URL       │
            │   (manual copy required)         │
            └─────────────────────────────────┘
                              │
         ┌────────────────────┴────────────────────┐
         │                                         │
         ▼                                         ▼
┌─────────────────┐                    ┌─────────────────────┐
│  Local Browser  │                    │  Phone/Other Device │
│  Open URL       │                    │  Open URL           │
│  Google Sign-in │                    │  Google Sign-in     │
│  Authorize App  │                    │  Authorize App      │
└─────────────────┘                    └─────────────────────┘
         │                                         │
         └────────────────────┬────────────────────┘
                              │
                              ▼
            ┌─────────────────────────────────┐
            │ Browser redirects to localhost   │
            │ (page won't load - this is OK)   │
            │ Copy full URL or code parameter  │
            └─────────────────────────────────┘
                              │
                              ▼
            ┌─────────────────────────────────┐
            │ Return to server terminal        │
            │ Paste URL or authorization code  │
            └─────────────────────────────────┘
                              │
                              ▼
            ┌─────────────────────────────────┐
            │ ✓ Account added successfully     │
            └─────────────────────────────────┘

## Security Considerations

- Supports state parameter validation (when user pastes full URL)
- Warns on state mismatch but allows continuation (manual mode tolerance)
- Authorization code length validation to prevent incorrect input

## Compatibility

- Does not affect existing automatic browser OAuth flow
- All changes are additive, no modifications to upstream logic
- Easy to merge future upstream updates
2026-01-04 14:46:16 +05:30
2026-01-02 00:03:43 +05:30
2025-12-26 20:53:54 +05:30
2025-12-19 19:27:10 +05:30
2026-01-03 22:01:57 +05:30

Antigravity Claude Proxy

npm version npm downloads License: MIT

Buy Me A Coffee

A proxy server that exposes an Anthropic-compatible API backed by Antigravity's Cloud Code, letting you use Claude and Gemini models with Claude Code CLI.

Antigravity Claude Proxy Banner

How It Works

┌──────────────────┐     ┌─────────────────────┐     ┌────────────────────────────┐
│   Claude Code    │────▶│  This Proxy Server  │────▶│  Antigravity Cloud Code    │
│   (Anthropic     │     │  (Anthropic → Google│     │  (daily-cloudcode-pa.      │
│    API format)   │     │   Generative AI)    │     │   sandbox.googleapis.com)  │
└──────────────────┘     └─────────────────────┘     └────────────────────────────┘
  1. Receives requests in Anthropic Messages API format
  2. Uses OAuth tokens from added Google accounts (or Antigravity's local database)
  3. Transforms to Google Generative AI format with Cloud Code wrapping
  4. Sends to Antigravity's Cloud Code API
  5. Converts responses back to Anthropic format with full thinking/streaming support

Prerequisites

  • Node.js 18 or later
  • Antigravity installed (for single-account mode) OR Google account(s) for multi-account mode

Installation

# Run directly with npx (no install needed)
npx antigravity-claude-proxy start

# Or install globally
npm install -g antigravity-claude-proxy
antigravity-claude-proxy start

Option 2: Clone Repository

git clone https://github.com/badri-s2001/antigravity-claude-proxy.git
cd antigravity-claude-proxy
npm install
npm start

Quick Start

1. Add Account(s)

You have two options:

Option A: Use Antigravity (Single Account)

If you have Antigravity installed and logged in, the proxy will automatically extract your token. No additional setup needed.

Option B: Add Google Accounts via OAuth (Recommended for Multi-Account)

Add one or more Google accounts for load balancing:

# If installed via npm
antigravity-claude-proxy accounts add

# If using npx
npx antigravity-claude-proxy accounts add

# If cloned locally
npm run accounts:add

This opens your browser for Google OAuth. Sign in and authorize access. Repeat for multiple accounts.

Manage accounts:

# List all accounts
antigravity-claude-proxy accounts list

# Verify accounts are working
antigravity-claude-proxy accounts verify

# Interactive account management
antigravity-claude-proxy accounts

2. Start the Proxy Server

# If installed via npm
antigravity-claude-proxy start

# If using npx
npx antigravity-claude-proxy start

# If cloned locally
npm start

The server runs on http://localhost:8080 by default.

3. Verify It's Working

# Health check
curl http://localhost:8080/health

# Check account status and quota limits
curl "http://localhost:8080/account-limits?format=table"

Using with Claude Code CLI

Configure Claude Code

Create or edit the Claude Code settings file:

macOS: ~/.claude/settings.json Linux: ~/.claude/settings.json Windows: %USERPROFILE%\.claude\settings.json

Add this configuration:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "test",
    "ANTHROPIC_BASE_URL": "http://localhost:8080",
    "ANTHROPIC_MODEL": "claude-opus-4-5-thinking",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-5-thinking",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-5-thinking",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-sonnet-4-5",
    "CLAUDE_CODE_SUBAGENT_MODEL": "claude-sonnet-4-5-thinking"
  }
}

Or to use Gemini models:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "test",
    "ANTHROPIC_BASE_URL": "http://localhost:8080",
    "ANTHROPIC_MODEL": "gemini-3-pro-high",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "gemini-3-pro-high",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "gemini-3-flash",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gemini-2.5-flash-lite",
    "CLAUDE_CODE_SUBAGENT_MODEL": "gemini-3-flash"
  }
}

Load Environment Variables

Add the proxy settings to your shell profile:

macOS / Linux:

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

For Bash users, replace ~/.zshrc with ~/.bashrc

Windows (PowerShell):

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

Windows (Command Prompt):

setx ANTHROPIC_BASE_URL "http://localhost:8080"
setx ANTHROPIC_API_KEY "test"

Restart your terminal for changes to take effect.

Run Claude Code

# Make sure the proxy is running first
antigravity-claude-proxy start

# In another terminal, run Claude Code
claude

Note: If Claude Code asks you to select a login method, add "hasCompletedOnboarding": true to ~/.claude.json (macOS/Linux) or %USERPROFILE%\.claude.json (Windows), then restart your terminal and try again.


Available Models

Claude Models

Model ID Description
claude-sonnet-4-5-thinking Claude Sonnet 4.5 with extended thinking
claude-opus-4-5-thinking Claude Opus 4.5 with extended thinking
claude-sonnet-4-5 Claude Sonnet 4.5 without thinking

Gemini Models

Model ID Description
gemini-3-flash Gemini 3 Flash with thinking
gemini-3-pro-low Gemini 3 Pro Low with thinking
gemini-3-pro-high Gemini 3 Pro High with thinking

Gemini models include full thinking support with thoughtSignature handling for multi-turn conversations.


Multi-Account Load Balancing

When you add multiple accounts, the proxy automatically:

  • Sticky account selection: Stays on the same account to maximize prompt cache hits
  • Smart rate limit handling: Waits for short rate limits (≤2 min), switches accounts for longer ones
  • Automatic cooldown: Rate-limited accounts become available after reset time expires
  • Invalid account detection: Accounts needing re-authentication are marked and skipped
  • Prompt caching support: Stable session IDs enable cache hits across conversation turns

Check account status anytime:

curl "http://localhost:8080/account-limits?format=table"

API Endpoints

Endpoint Method Description
/health GET Health check
/account-limits GET Account status and quota limits (add ?format=table for ASCII table)
/v1/messages POST Anthropic Messages API
/v1/models GET List available models
/refresh-token POST Force token refresh

Testing

Run the test suite (requires server running):

# Start server in one terminal
npm start

# Run tests in another terminal
npm test

Individual tests:

npm run test:signatures    # Thinking signatures
npm run test:multiturn     # Multi-turn with tools
npm run test:streaming     # Streaming SSE events
npm run test:interleaved   # Interleaved thinking
npm run test:images        # Image processing
npm run test:caching       # Prompt caching

Troubleshooting

"Could not extract token from Antigravity"

If using single-account mode with Antigravity:

  1. Make sure Antigravity app is installed and running
  2. Ensure you're logged in to Antigravity

Or add accounts via OAuth instead: antigravity-claude-proxy accounts add

401 Authentication Errors

The token might have expired. Try:

curl -X POST http://localhost:8080/refresh-token

Or re-authenticate the account:

antigravity-claude-proxy accounts

Rate Limiting (429)

With multiple accounts, the proxy automatically switches to the next available account. With a single account, you'll need to wait for the rate limit to reset.

Account Shows as "Invalid"

Re-authenticate the account:

antigravity-claude-proxy accounts
# Choose "Re-authenticate" for the invalid account

Safety, Usage, and Risk Notices

Intended Use

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

Not Suitable For

  • Production application traffic
  • High-volume automated extraction
  • Any use that violates Acceptable Use Policies

Warning (Assumption of Risk)

By using this software, you acknowledge and accept the following:

  • Terms of Service risk: This approach may violate the Terms of Service of AI model providers (Anthropic, Google, etc.). You are solely responsible for ensuring compliance with all applicable terms and policies.

  • Account risk: Providers may detect this usage pattern and take punitive action, including suspension, permanent ban, or loss of access to paid subscriptions.

  • No guarantees: Providers may change APIs, authentication, or policies at any time, which can break this method without notice.

  • Assumption of risk: You assume all legal, financial, and technical risks. The authors and contributors of this project bear no responsibility for any consequences arising from your use.

Use at your own risk. Proceed only if you understand and accept these risks.


  • Not affiliated with Google or Anthropic. This is an independent open-source project and is not endorsed by, sponsored by, or affiliated with Google LLC or Anthropic PBC.

  • "Antigravity", "Gemini", "Google Cloud", and "Google" are trademarks of Google LLC.

  • "Claude" and "Anthropic" are trademarks of Anthropic PBC.

  • Software is provided "as is", without warranty. You are responsible for complying with all applicable Terms of Service and Acceptable Use Policies.


Credits

This project is based on insights and code from:


License

MIT


Star History

Star History Chart

Description
Fork of Antigravity Claude Proxy - Proxy server to use Antigravity's Claude models with Claude Code CLI
Readme MIT 13 MiB
Languages
JavaScript 77.7%
HTML 21.2%
CSS 1.1%