Skip to content

Repository files navigation

✨ Gemini OpenAI Proxy

An elegant, production-ready OpenAI-compatible proxy for Google Gemini's Web Interface.

Built for developers who value performance, stability, and clean architecture.

⚡ OpenAI Compatible • 🚀 Production Ready • 🛡 Secure by Default • 🤖 Gemini Advanced


✨ Overview

Gemini OpenAI Proxy bridges the gap between your applications and Google Gemini's powerful web models by exposing a fully OpenAI-compatible API.

Simply replace your existing OpenAI endpoint with Gemini Proxy and continue using your favorite SDKs (like AutoGen, LobeChat, Chatbox, or AnythingLLM) without changing your application logic.

Enjoy access to gemini-3-pro, gemini-3-flash, and their multimodal capabilities — all through standard OpenAI formats.


🚀 Why Gemini Proxy?

⚡ Compatibility

Works with existing OpenAI SDKs.

No client-side rewrites.

Drop-in replacement.

🛡 Security

Docker / Non-root support

API Key Authentication

No Data Logging

Cookie-based Auth

🚀 Performance

Asynchronous Core (FastAPI)

Thread-safe Sessions

Automatic Cookie Refresh

Cross-platform Launcher


✨ Features

  • Fully OpenAI-compatible API (Chat Completions, Models, Image Generation)
  • Multimodal Support — Send images and files to Gemini seamlessly
  • 🚀 Tool Calling / Function Calling support built-in
  • 💧 Watermark Removal — Automatically removes Gemini watermarks from generated images
  • 🛡 Collision-Free Sessions — UUID-based session management
  • 🔄 Auto-Refreshing Cookies — Integrated webhook for browser extension sync
  • 📦 Cross-Platform Launcher — Run in foreground, background, systemd, or Task Scheduler
  • 🐳 Docker Support — Clean, secure containerized deployment

📦 Quick Start

1. Clone Repository

git clone https://github.com/TheOwlKun/gemini-openai-proxy.git
cd gemini-openai-proxy

2. Install

pip install -r requirements.txt

3. Configure

cp .env.example .env

🔍 Obtaining your Cookies

Valid Google cookies are strictly required to interface with Gemini.

Visit https://gemini.google.com/ ➔ Open Developer Tools (F12)
Navigate to the Application / Storage tab ➔ Select Cookies ➔ Copy the values for __Secure-1PSID and __Secure-1PSIDTS and add them to your .env file.


4. Run

The proxy comes with a powerful cross-platform launcher that works on Windows, Linux, and macOS.

# Interactive Menu
python launch.py

# Or start directly in background
python launch.py background

Alternative: Docker

docker-compose up -d

💻 Usage

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="sk-your-secret-key", # Set in your .env as GEMINI_API_KEY
    base_url="http://localhost:3000/v1"
)

# 1. Chat Completion
response = client.chat.completions.create(
    model="gemini-3-pro",
    messages=[{"role": "user", "content": "Explain quantum computing in one sentence."}]
)
print(response.choices[0].message.content)

# 2. Image Generation
image = client.images.generate(
    model="gemini-3-flash-image",
    prompt="A futuristic cyberpunk city at night",
    n=1
)
print(image.data[0].url)

cURL

curl http://localhost:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-secret-key" \
  -d '{
    "model": "gemini-3-pro",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

🛡 Built For Production

Unlike simple scripts, Gemini Proxy includes production-grade architecture by default:

  • FastAPI & Uvicorn asynchronous core
  • True Session Management (no more collision bugs with identical prompts)
  • Robust XML Parser for Gemini's tool calls
  • Background Service Wrappers (systemd for Linux, hidden process/Task Scheduler for Windows)
  • Secure Docker Image (runs as non-root user)

Perfect for personal AI agents, internal tools, and LobeChat/AnythingLLM backends.


❤️ Support Development

If this project saved you time or made your workflow easier, consider supporting future open-source development.


Crafted with ❤️ by @TheOwlKun

⭐ If you find this project useful, consider giving it a star!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages