gemini-web2api: The Shadow API That Makes Gemini Look Like OpenAI

A minimal Python proxy that reverse-engineers Google’s web chat surface, translates it into OpenAI-compatible requests, and smuggles in tool calling, streaming, and multimodal uploads.

8 min read • View on GitHub • More from Sophomoresty

A split editorial scene shows an OpenAI-shaped developer console on one side and a Gemini browser interface on the other, with a small proxy box translating traffic between them. The image explains the repo’s core idea: compatibility is the product, and the proxy is the bridge.
The repo’s trick is not access alone. It is translation, turning one API shape into another without asking the client to care.
Key Takeaways

A Gemini backend that pretends to be OpenAI. That is the real product here. If your tool already speaks OpenAI’s request shape, gemini-web2api lets it talk to Gemini with almost no client-side changes.

Convert Google Gemini web into OpenAI-compatible API. Zero auth, cross-platform, single file.

Sophomoresty, Project Author/Maintainer · Sophomoresty/gemini-web2api

Why this repo exists

The official Gemini API already exists. This project aims at a different layer: the web surface, the browser session, the internals Google did not mean to expose as a public SDK. That matters if you want a drop-in backup for OpenAI-shaped apps, or if you want access to web-first behavior without rebuilding your stack around Google’s official path.

PathSetupCompatibilityFragilityBest for
Official Gemini APIAPI key, official docs, structured accessNative for Gemini clients, not OpenAI-shaped toolsLower protocol risk, higher platform constraintsTeams that want supported, stable access
Generic browser automationCustom scripts, browser sessions, scraping logicUsually poor unless you build adapters yourselfHigh, because UI changes break flowsOne-off experiments and bespoke automation
gemini-web2apiRun a Python proxy, point clients at itHigh, because it speaks OpenAI-compatible requestsMedium to high, because it tracks a moving web surfaceApps that already depend on OpenAI-style endpoints

The table is the point. This repo occupies the awkward but useful middle: more compatible than scraping, less official than the API, and much easier to slot into existing tooling than a fresh integration.

The real trick: protocol translation, not just request forwarding

The proxy does not merely relay requests. It reshapes them across two incompatible conversation models, then streams the result back in a form client apps already understand.

A close-up mechanical illustration shows a stack of chat messages being flattened, repackaged, and released into a different request structure. A small inserted slip marks the tool-call shim, while a separate upload channel branches off for images. The image explains that this repo synthesizes a bridge between two incompatible protocols.
The difficult part is not sending bytes. It is preserving the illusion that both sides are speaking the same language.

How tool calls are faked into existence

The clever part in tools.py is not that Gemini suddenly gains a native tool API. It does not. The repo instead instructs the model to emit fenced tool_call blocks, then parses them back into structured calls. In other words, the system manufactures a tool protocol by making the model write one.

# Tool Use

You can call the following tools. Call format:
```tool_call
{"name": "func_name", "arguments": {...}}
```

# Parse back into structured calls
pattern = r'```tool_call\s*\n(.*?)\n```'
Native tool APIPrompt-injected tool calling
Model returns structured tool events directlyModel is coached to print a fenced block
Schema enforced by the platformSchema reconstructed by the proxy
Usually stable across releasesDepends on prompt compliance and parser tolerance
Best when the provider owns the full stackBest when the provider exposes only a web surface

This is fragile, but not silly. It is a practical compromise when the underlying surface gives you text, not first-class function calls.

Why the multimodal path is the hardest part

Image support is the least visible part of the repo and the most browser-specific. The upload flow in multimodal.py has to discover session tokens, perform a resumable upload handshake, and hand Gemini a file reference it will accept. That is a separate protocol stack, not a small extension.

That is also why the project feels more like infrastructure than a helper script. The proxy is doing the annoying work that makes a polished client experience possible: cookies, session state, upload choreography, and stream reassembly.

The author chose boring tools on purpose

This project is for educational purposes only. Do not use it for commercial purposes. The author is not responsible for any consequences caused by the use of this project.

Sophomoresty, Project Author/Maintainer · gemini-web2api README

The codebase leans into the standard library, thin abstractions, and a small footprint. That choice matters because reverse-engineering projects do not fail from lack of features first. They fail from entropy. Simplicity buys the author a better chance of keeping up with a moving target.

The same logic shows up in the server design and cookie reload behavior. The goal is not elegance for its own sake. The goal is a proxy that can survive real traffic, real sessions, and the churn of a web product that was never meant to be a stable backend.

What this project says about the AI stack

`gemini-web2api` sits in a larger pattern: the most valuable AI layer is often not the model, but the interface that makes the model easy to consume. Official APIs, unofficial wrappers, browser automation, and compatibility layers are competing to own that interface.

LayerWhat it optimizes forWhat it sacrifices
Official APIStability and supportAccess to web-only behavior
Browser automationMaximum reach into the UIReliability and clean integration
Compatibility proxyClient reuse and drop-in adoptionLong-term certainty

That trade-off is the whole thesis. If your app, agent, or workflow already assumes an OpenAI-shaped world, the fastest path to Gemini may be a bridge that speaks both dialects. This repo is that bridge.

Bottom line

gemini-web2api is valuable because it turns a fragile web UI into something that behaves like a programmable backend. It is also a reminder that in AI infrastructure, interface control is often more important than raw model access.