Skip to main content
Glama

🌐 Gemini Web2API Gateway

A high-performance local developer gateway bridging Google Gemini Web to OpenAI-compatible clients, Anthropic Claude agents, and Model Context Protocol (MCP) workflows.

License: MIT Python 3.10+ OpenAI Compatible Anthropic Claude Ready MCP Ready Cloudflare Ready


πŸ“Œ Overview

Gemini Web2API Gateway is an open-source multi-protocol bridge that translates your Google Gemini Web session into standardized, drop-in replacement REST APIs for:

  1. OpenAI API (/v1/chat/completions, /v1/models)

  2. Anthropic Claude Messages API (/v1/messages, /claude/v1/messages)

  3. Gemini Deep Research (/gemini/v1beta/interactions)

  4. OpenAI Codex Responses (/v1/responses)

  5. Google GenAI Native REST (/v1beta/models/...)

Designed specifically for developers, researchers, and agentic workflows, it connects Gemini Web directly to IDE plugins, local developer tools, and autonomous coding assistants like Claude Code, Cline, OpenCode, Cursor, and OpenDevin without protocol incompatibilities.


Related MCP server: Gemini CLI MCP/OpenAI Bridge

πŸ›οΈ Architecture & Workflow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          Developer Clients                             β”‚
β”‚       OpenCode  β€’  Cline  β€’  Cursor  β€’  Claude Code  β€’  OpenDevin      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚ Standard OpenAI (/v1) or Claude (/v1/messages)
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Gemini Web2API Gateway                          β”‚
β”‚  β€’ Anthropic Claude Adapter (translates messages, system & thinking)   β”‚
β”‚  β€’ Agent Tool Adapter (formats MCP schemas & parallel tool execution)  β”‚
β”‚  β€’ Deep Research Engine (autonomous multi-stage web-grounded research) β”‚
β”‚  β€’ Hardened Scotty Resumable Upload (multimodal vision + fallback)     β”‚
β”‚  β€’ Anti-Extension Keyword Sanitizer (avoids Google Workspace traps)    β”‚
β”‚  β€’ Conversation Compactor (preserves agent state up to 300k chars)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                                β”‚
                    β–Ό                                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     SQLite Session Pool & Router      β”‚  β”‚ Browser Companion Extension β”‚
β”‚  β€’ Multi-Account Rotation & Failover  β”‚  β”‚  β€’ Multi-Profile Sync       β”‚
β”‚  β€’ Cooldown Backoff Tracking          β”‚  β”‚  β€’ Automated Session Refreshβ”‚
β”‚  β€’ Account-Specific API Keys          β”‚  β”‚  β€’ Background Worker Keep   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                                     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                        β”‚ HTTPS Session Stream
                                        β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚       Google Gemini Web       β”‚
                        β”‚  3.8 Flash β€’ 3.5 Lite β€’ Pro   β”‚
                        β”‚  Deep Research β€’ Web Search   β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🌟 Key Highlights

  • πŸ”Œ Universal Multi-Protocol Support:

    • Full OpenAI compatibility (/v1/chat/completions, /v1/models).

    • Full Anthropic Claude compatibility (/v1/messages, /claude/v1/messages, /v1/messages/count_tokens).

    • Native Gemini Deep Research pipeline (/gemini/v1beta/interactions).

  • πŸš€ Frontier & Extended Reasoning:

    • Out-of-the-box support for Gemini 3.8 Flash, Gemini 3.5 Flash-Lite, and Gemini 3.1 Pro.

    • Drop-in aliases for Claude 3.7 Sonnet, Claude 3.5 Sonnet, Claude 3.5 Haiku, GPT-4o, and GPT-4.

    • Thinking depth adjustable on any model via @think=0 suffix.

  • πŸ–ΌοΈ Hardened Scotty Resumable Multimodal Upload:

    • Dual authentication (page tokens + static internal fallback Basic c2F2...).

    • Auto-compression and support for base64 data URIs, raw base64, Claude image blocks, and URLs.

  • πŸ›‘οΈ Anti-Extension Keyword Sanitizer:

    • Prevents Gemini's pre-flight classifier from mistakenly flagging prompts containing words like "Google Docs", "Google Drive", "Gmail", "YouTube", or "Webflow" with permission traps.

  • ⚑ Autonomous Agent Optimizations:

    • 300k-character smart compactor preserves Cline / OpenCode / Claude Code state machines during massive parallel tool loops.

  • ☁️ Cloudflare Edge Worker Edition:

    • Includes ./cloudflare/worker.js and ./cloudflare/wrangler.toml for 1-click zero-cost serverless deployment on Cloudflare Workers.

  • πŸ“Š Real-time Web Dashboard:

    • Interactive HTML dashboard (/dashboard or /) with live multi-protocol playground, account health checks, and sync triggers.


πŸ“‹ Model Directory & Aliases

Model ID (API Name)

Protocol Target

Reasoning Engine

Recommended For

gemini-3.8-flash

OpenAI / Claude / Native

Standard

General coding, fast completions, small edits

gemini-3.8-flash-thinking

OpenAI / Claude / Native

🧠 Extended (mode: 2)

Autonomous coding agents, MCP, complex logic

claude-3-7-sonnet

Anthropic Claude (/v1/messages)

🧠 Extended

Claude Code, Cursor, complex agentic workflows

claude-3-5-sonnet

Anthropic Claude (/v1/messages)

🧠 Extended

High-accuracy code architecture & refactoring

claude-3-5-haiku

Anthropic Claude (/v1/messages)

Standard (mode: 6)

Ultra-fast token streaming, summaries, lookups

gemini-deep-research

Interactions / OpenAI

πŸ” Grounded Research

Multi-source investigation and report generation

gemini-3.1-pro

OpenAI / Claude / Native

Standard (mode: 3)

Gemini Advanced subscribers

gpt-4o

OpenAI drop-in

🧠 Extended

Tools with hardcoded model selectors


πŸš€ Quick Start

1. Installation

git clone https://github.com/javedhamzabwn/gemini-web2api.git
cd gemini-web2api
pip install -r requirements.txt

2. Start the Gateway

On Windows: Double-click start_manager.bat and select option 4.

Or via Command Line:

python -m gemini_web2api --port 10012

Access the Web Dashboard at: http://localhost:10012/


πŸ› οΈ Client Configuration

1. Claude Code / Terminal Agent

export ANTHROPIC_BASE_URL="http://localhost:10012"
export ANTHROPIC_API_KEY="sk-gemini-example-key"
export CLAUDE_MODEL="claude-3-7-sonnet"
claude

2. Cline / Roo Code (VS Code Extension)

  • API Provider: Anthropic or OpenAI Compatible

  • Base URL: http://localhost:10012 (for Anthropic) or http://localhost:10012/v1 (for OpenAI)

  • API Key: sk-gemini-example-key

  • Model ID: claude-3-7-sonnet or gemini-3.8-flash-thinking

3. OpenCode / OpenCode Studio

In your custom provider settings:

  • Provider: OpenAI-Compatible

  • Base URL: http://localhost:10012/v1

  • API Key: Enter any key or your account-specific key.

  • Model: gemini-3.8-flash-thinking

4. Cursor / Continue.dev

In .cursorrules or continue/config.json:

{
  "models": [
    {
      "title": "Gemini 3.8 Flash Thinking",
      "provider": "openai",
      "model": "gemini-3.8-flash-thinking",
      "apiBase": "http://localhost:10012/v1",
      "apiKey": "sk-gemini-example-key"
    },
    {
      "title": "Claude 3.7 Sonnet (via Gemini)",
      "provider": "anthropic",
      "model": "claude-3-7-sonnet",
      "apiBase": "http://localhost:10012",
      "apiKey": "sk-gemini-example-key"
    }
  ]
}

πŸ§ͺ End-to-End Verification

A comprehensive automated test suite is included:

python -m unittest tests.test_end_to_end

Covers:

  • OpenAI /v1/chat/completions compatibility

  • Anthropic Claude /v1/messages non-streaming, streaming, and tool calls

  • Token estimation /v1/messages/count_tokens

  • Scotty resumable upload MIME parsing and image extraction

  • Deep Research plan generation and synthesis

  • Live server dispatch and multi-account SQLite session integrity


☁️ Cloudflare Edge Worker Deployment

To deploy serverless on Cloudflare's edge network:

  1. Navigate to the cloudflare/ directory:

    cd cloudflare
  2. Configure your secret cookie:

    npx wrangler secret put COOKIE_STRING
  3. Deploy:

    npx wrangler deploy

See cloudflare/README.MD for full details.


πŸ“„ License

Distributed under the MIT License.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Bridges Google's Gemini CLI with MCP-compatible clients and integrates OpenRouter API for access to 400+ AI models. Provides 33 specialized tools enabling multi-AI workflows, collaborations, and debates between Claude, Gemini, and other LLMs.
      142
      -
    • A
      license
      Not graded
      quality
      F
      maintenance
      Exposes Gemini CLI's built-in tools and external MCP proxies through a unified MCP endpoint while providing an OpenAI-compatible API for Gemini models. It features configurable security modes to safely manage file system operations, web searches, and shell command execution.
      138
      Apache 2.0
    • A
      license
      A
      quality
      F
      maintenance
      MCP server for querying Google Gemini Web from Claude Code and other MCP clients, using cookie-based authentication. Enables creating, continuing, listing, viewing, and deleting Gemini chat conversations with model and thinking mode control.
      6
      AGPL 3.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides OpenAI-compatible API, MCP, and CLI for Google AI Mode, with automatic fallback to a real Chrome browser to bypass TLS fingerprint detection.
      3
      -