Configuration Priority
Settings are applied in the following order (highest to lowest priority):- Environment variables (e.g.,
PORT=3000) - Config file (
~/.config/antigravity-proxy/config.json) - Default values (built-in defaults)
Environment Variables
Server Configuration
HTTP server port. The proxy listens on this port for API requests.
Bind address. Use
127.0.0.1 to restrict to localhost only.Security
Protect
/v1/* API endpoints with a bearer token. When set, clients must include Authorization: Bearer YOUR_API_KEY.Password-protect the Web Console. Users will be prompted to enter this password when accessing the dashboard.
Proxy & Network
Route outbound API requests through an HTTP proxy. Useful for corporate firewalls or debugging.
Same as
HTTP_PROXY but for HTTPS requests. Both variables are supported (case-insensitive).Developer Mode
Enable developer mode with debug logging and advanced features.When enabled:
- Debug logs are printed to console
/api/strategy/healthendpoint is accessible- Dev tools panel is visible in WebUI
- Screenshot mode and placeholder data are available
Legacy alias for
DEV_MODE. Setting DEBUG=true automatically enables developer mode.Model Fallback
Enable automatic model fallback when quota is exhausted. See Fallback Strategy for details.
systemd / Service Deployments
Path to the Example systemd service file:
.claude directory containing settings.json. Required when running as a systemd service.Problem: When running as a systemd service, os.homedir() returns the service user’s home (e.g., /root), not the real user’s home.Solution: Set this variable to the real user’s .claude directory.OAuth Callback Port
Port for OAuth callback server during account authentication. Windows users may need to change this if the default port is reserved by Hyper-V/WSL2.Fallback ports:
51122, 51123, 51124, 51125, 51126Config File Structure
The config file is located at~/.config/antigravity-proxy/config.json. It is created automatically on first run.
Example config.json
Retry & Rate Limiting
Maximum number of retry attempts for failed requests.
Base delay in milliseconds for exponential backoff.
Maximum retry delay in milliseconds (30 seconds).
Default cooldown period after rate limit errors (10 seconds).
Maximum time to wait before giving up and returning an error (2 minutes).
Deduplication window to prevent concurrent retry storms (2 seconds).
Number of consecutive failures before applying extended cooldown.
Extended cooldown period after repeated failures (1 minute).
Delay before switching accounts after a rate limit (5 seconds).
Capacity & Backoff
Maximum retries for model capacity exhaustion errors.
Progressive backoff tiers for capacity exhaustion (in milliseconds).
Account Management
Maximum number of Google accounts allowed (1-100). Configurable via WebUI.
Global minimum quota fraction before switching accounts.
0= Disabled (use quota until exhausted)0.01to0.99= Switch when quota drops below this fraction- Example:
0.10= Switch when quota falls below 10%
This can be overridden per-account and per-model in the Web Console.
Enable delay before each Google API request (opt-in). Helps prevent rate limits in high-concurrency scenarios.
Delay in milliseconds when request throttling is enabled (100-5000ms).
Account Selection Strategy
TheaccountSelection object configures the load balancing strategy.
Account selection algorithm:
sticky: Cache-optimized (stays on same account)round-robin: Load-balanced (rotates every request)hybrid: Smart distribution (default)
Hybrid Strategy Tuning
These settings only apply whenstrategy is set to hybrid.
Health scoring configuration:
initial(70): Starting score for new accountssuccessReward(1): Points added on successful requestrateLimitPenalty(-10): Points subtracted on rate limitfailurePenalty(-20): Points subtracted on other failuresrecoveryPerHour(10): Passive recovery rateminUsable(50): Minimum score to be selectedmaxScore(100): Maximum score cap
Client-side rate limiting via token bucket:
maxTokens(50): Maximum token capacitytokensPerMinute(6): Regeneration rateinitialTokens(50): Starting tokens for new accounts
Quota awareness thresholds:
lowThreshold(0.10): Reduce score when quota falls below 10%criticalThreshold(0.05): Exclude from selection below 5%staleMs(300000): Max age of quota data to trust (5 minutes)
Component weights for score calculation:
health(2): Weight for health score componenttokens(5): Weight for token bucket componentquota(3): Weight for quota awareness componentlru(0.1): Weight for LRU freshness component
Quota Threshold Configuration
Quota thresholds protect accounts from complete exhaustion by switching to another account when quota drops below a configurable level.Three-Tier Resolution
Thresholds are checked in priority order:- Per-model (
account.modelQuotaThresholds[modelId]) - Per-account (
account.quotaThreshold) - Global (
config.globalQuotaThreshold)
Configuring via WebUI
Global threshold
Navigate to Settings → Server and adjust the Global Quota Threshold slider (0-99%).
Per-account threshold
- Go to Accounts
- Click the settings icon next to an account
- Adjust the Account Quota Threshold slider
Server Presets
The proxy includes built-in presets optimized for different scenarios. Access them via Settings → Server in the WebUI.Default (3-5 Accounts)
Balanced settings for most users:- Strategy: Hybrid
- Max retries: 5
- Max wait: 2 minutes
- Account selection: Balanced weights
Many Accounts (10+)
Optimized for high account counts:- Strategy: Hybrid
- Max retries: 3 (faster failures)
- Max wait: 1 minute
- Account selection: Prioritizes health over LRU
Conservative
Maximum reliability with longer waits:- Strategy: Sticky (best for caching)
- Max retries: 8
- Max wait: 4 minutes
- Account selection: Gentle penalties, slow recovery
Editing the Config File
You can edit the config file manually or through the WebUI.- WebUI (Recommended)
- Manual Editing
- Open
http://localhost:8080 - Navigate to Settings → Server
- Adjust settings using sliders and dropdowns
- Changes are saved automatically
systemd Service Setup
When running the proxy as a systemd service, set theCLAUDE_CONFIG_PATH environment variable to the real user’s .claude directory.
Example Service File
/etc/systemd/system/antigravity-proxy.service
Enable and Start
Troubleshooting
Changes not taking effect
Changes not taking effect
- Check that you’re editing the correct config file (
~/.config/antigravity-proxy/config.json) - Restart the proxy after manual edits
- Environment variables override config file settings
Port already in use
Port already in use
Change the port using the
PORT environment variable:OAuth callback fails on Windows
OAuth callback fails on Windows
Windows may reserve ports 49152-65535 for Hyper-V/WSL2. Set
OAUTH_CALLBACK_PORT to a lower port:Config file not found
Config file not found
The config file is created automatically on first run. If it’s missing: