A lightweight proxy that turns the Google Gemini Web into an OpenAI-compatible API.
This project uses playwright to run a real browser instance (Chrome/Chromium) in the background. It acts as a bridge:
- Receives an API request (OpenAI format).
- Automates the browser to type the prompt into
gemini.google.com. - Streams the response text back to the API client in real-time.
- Manages authentication cookies to keep the session alive.
This project is more than just a wrapper; it implements advanced techniques to mimic a real human user.
- OpenAI API Compatible: Drop-in replacement for OpenAI clients. Use it with existing tools like LangChain, TavernAI, or custom scripts.
- Stealth & Anti-Detect:
- Fingerprint Randomization: Rotates between Windows, macOS, and Linux browser signatures.
- Deep Consistency: Synchronizes HTTP User-Agents with JavaScript
navigatorproperties to pass rigid consistency checks. - Context Masking: Uses
playwright-stealthto hide WebDriver signals.
- Human-like Behavior Simulation:
- Natural Typing: Abandoned instant text injection (
fill()) in favor of character-by-character typing with variable speed (10ms-50ms jitter). Long prompts (e.g., 2000+ chars) will take a few seconds to "type" into the browser before sending. - Randomized Interactions: Includes "hesitation" delays (0.5s-1.5s) before clicking buttons to simulate human thought processes and mouse movement.
- Dynamic Waits: Avoids fixed sleep timers, making the bot's behavior unpredictable to pattern-matching algorithms.
- Natural Typing: Abandoned instant text injection (
- Session Persistence: Automatically saves and loads authentication cookies (
auth/gemini_state.json) to maintain login state across restarts.
pip install -r requirements.txt
playwright install chromiumCopy the example config and adjust if needed:
cp .env.example .env- HEADLESS: Set to
Falseto see the browser - MAX_REQUESTS_PER_MIN: Adjust rate limits.
python main.pyA browser window will open. Log in to your Google Account manually. Once logged in, the session cookies are saved to auth/gemini_state.json. The proxy will automatically enable Temporary Chat to keep your history clean.
The server runs at http://localhost:8000. It supports the standard OpenAI chat completion format.
API Key: You can leave it as sk-any or any non-empty string.
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-1.5-pro",
"messages": [{"role": "user", "content": "Hello, how are you?"}],
"stream": true
}'from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="sk-any" # Required but unused
)
response = client.chat.completions.create(
model="gemini-1.5-pro",
messages=[{"role": "user", "content": "Explain quantum physics"}],
stream=True
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")PLEASE READ CAREFULLY BEFORE USE:
Account Ban Risk: This tool automates a personal Google account. There is a significant risk that your Google account could be suspended, banned, or disabled for using this tool. DO NOT use your primary Google account. Use a burner account.
Headless Mode Detection: Running the browser in "Headless Mode" (invisible window) significantly increases the chance of being detected as a bot by Google's anti-fraud systems. Use HEADLESS=False (visible mode) for a safer (though not risk-free) experience.
No Liability: This software is provided "AS IS", without warranty of any kind. The author/maintainer is NOT responsible for any damages, data loss, or account bans resulting from the use of this tool. You use this software entirely at your own risk.
Unofficial Tool: This project is not affiliated with, endorsed by, or connected to Google or Gemini.