Intercept Google Antigravity IDE API calls and use your own Gemini API token
A MITM (Man-in-the-Middle) proxy that intercepts Google Antigravity IDE's API calls to generativelanguage.googleapis.com and replaces the authentication credentials with your own Gemini API token.
Antigravity IDE β MITM Proxy β Google Gemini API
β
[Replace API Key]
β
Your API Token
- Intercepts all API calls from Antigravity to Google's Gemini API
- Replaces Google's API key with your own token
- Monitors all requests and responses for debugging
- Controls your own API usage and billing
# 1. Install dependencies
brew install mitmproxy
pip3 install python-dotenv
# 2. Setup SSL certificate
mitmproxy # Press 'q' to quit
open ~/.mitmproxy/mitmproxy-ca-cert.pem
# In Keychain Access: Trust β "Always Trust"
# 3. Configure your API key
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY
# 4. Start the proxy
mitmproxy -s mitmproxy-addon.py --listen-port 8080
# 5. Launch Antigravity (new terminal)
HTTP_PROXY=http://localhost:8080 \
HTTPS_PROXY=http://localhost:8080 \
/Applications/Antigravity.app/Contents/MacOS/Antigravity- macOS (tested on macOS 14+, should work on Linux/Windows with minor adjustments)
- Python 3.8+
- Homebrew (for macOS)
- Google Gemini API Key (Get one free)
# macOS
brew install mitmproxy
# Linux (Ubuntu/Debian)
sudo apt install mitmproxy
# Or via pip
pip3 install mitmproxypip3 install python-dotenvThis step is critical for intercepting HTTPS traffic:
# Start mitmproxy to generate certificates
mitmproxyPress q to quit. Certificate is now at ~/.mitmproxy/mitmproxy-ca-cert.pem
macOS:
# Open certificate in Keychain
open ~/.mitmproxy/mitmproxy-ca-cert.pem- Double-click "mitmproxy" certificate in Keychain Access
- Expand "Trust" section
- Set "When using this certificate" to "Always Trust"
- Close (enter password when prompted)
Linux:
sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy.crt
sudo update-ca-certificatesWindows:
# Open Certificate Manager
certmgr.msc
# Import ~/.mitmproxy/mitmproxy-ca-cert.pem to Trusted Root Certification Authorities# Clone this repository
git clone https://github.com/yourusername/antigravity-proxy.git
cd antigravity-proxy
# Copy example config
cp .env.example .env
# Edit and add your API key
nano .env # or use any editorSet your Gemini API key:
GEMINI_API_KEY=your_actual_api_key_herecd antigravity-proxy
# Interactive mode (with TUI)
mitmproxy -s mitmproxy-addon.py --listen-port 8080
# Headless mode (terminal output only)
mitmdump -s mitmproxy-addon.py --listen-port 8080
# Web interface
mitmweb -s mitmproxy-addon.py --listen-port 8080
# Then open http://localhost:8081Option 1: Using the launch script
./scripts/launch-antigravity.shOption 2: Manual launch
HTTP_PROXY=http://localhost:8080 \
HTTPS_PROXY=http://localhost:8080 \
/Applications/Antigravity.app/Contents/MacOS/AntigravityWhen you use Antigravity's AI features, you should see in the proxy terminal:
π₯ INCOMING REQUEST #1
Method: POST
URL: https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent
π Replaced key in header
Old: AIzaSyABC123***
New: AIzaSyDEF456***
β
RESPONSE
Status: 200
π Stats: 1 requests, 1 keys replaced
This proxy uses mitmproxy, an industry-standard MITM proxy, with a custom Python addon (mitmproxy-addon.py) that:
- Intercepts HTTPS requests to
generativelanguage.googleapis.com - Extracts the original API key from headers or query parameters
- Replaces it with your configured API key from
.env - Forwards the modified request to Google's servers
- Returns the response to Antigravity
- β Industry-standard tool for API interception
- β Handles SSL/TLS certificate generation automatically
- β Can inspect and modify HTTPS traffic
- β Well-documented and actively maintained
- β Python scripting for custom logic
Edit .env file:
# Your Google Gemini API Key (required)
GEMINI_API_KEY=your_api_key_here
# Proxy port (optional, default: 8080)
PROXY_PORT=8080- MITMPROXY_SETUP.md - Complete setup guide
- IMPORTANT_NOTES.md - Technical limitations and alternatives
- docs/VSCODE_SETUP.md - VS Code configuration
What this means:
- The mitmproxy certificate allows intercepting ALL HTTPS traffic
- Only use on your personal development machine
- Never use on production systems
- Don't expose the proxy to the internet
- Revoke certificate trust when done
API Key Security:
- Never commit
.envto git (already in.gitignore) - Don't share your
.envfile - Use separate API keys for development/production
- Rotate keys regularly
See docs/SECURITY.md for detailed security information.
Symptom: SSL/TLS errors in Antigravity
Solution:
- Open Keychain Access (macOS)
- Search for "mitmproxy"
- Double-click certificate
- Set Trust to "Always Trust"
- Restart Antigravity
Symptom: Proxy shows no traffic
Solutions:
- Verify environment variables:
echo $HTTP_PROXY echo $HTTPS_PROXY
- Check proxy is running:
lsof -ti:8080 - Test with curl:
HTTP_PROXY=http://localhost:8080 \ HTTPS_PROXY=http://localhost:8080 \ curl https://generativelanguage.googleapis.com/v1beta/models
Symptom: Proxy logs show no key replacement
Solution:
- Verify
.envhas correctGEMINI_API_KEY - Check logs show "Replaced key in header"
- Ensure you copied
.env.exampleto.env
See docs/TROUBLESHOOTING.md for more help.
Contributions are welcome! Please feel free to submit a Pull Request.
git clone https://github.com/yourusername/antigravity-proxy.git
cd antigravity-proxy
cp .env.example .env
# Edit .env with your API key# Test the proxy with curl
HTTP_PROXY=http://localhost:8080 \
HTTPS_PROXY=http://localhost:8080 \
curl -v https://generativelanguage.googleapis.com/v1beta/modelsMIT License - see LICENSE file for details.
This tool is for educational and personal use only. Ensure you comply with:
- Google's Terms of Service
- Gemini API Terms of Service
- Gemini API Usage Policies
- Your organization's security policies
The authors are not responsible for any misuse or violations.
An educational Node.js implementation is available in the nodejs-experimental branch:
git checkout nodejs-experimentalNote: The Node.js version demonstrates proxy concepts but cannot inspect HTTPS content due to encryption limitations. Use the master branch (mitmproxy) for actual functionality.
See nodejs-experimental branch for details.
- mitmproxy - The excellent MITM proxy framework
- Google Antigravity team for building an interesting IDE
- Google Gemini team for the API
- Issues: GitHub Issues
- Documentation: See docs/ directory
- Security: See docs/SECURITY.md
If you find this project useful, please consider giving it a star β
master (default)
βββ mitmproxy-addon.py # Working proxy solution
βββ docs/ # Documentation
βββ scripts/ # Helper scripts
βββ README.md # This file
nodejs-experimental
βββ src/ # Node.js implementation (educational)
βββ package.json # Node.js dependencies
βββ README_NODEJS.md # Branch-specific docs
Made with β€οΈ for developers who want control over their AI API usage