← all repositories
Sophomoresty/gemini-web2api

A single-file proxy that turns Gemini’s web chat into an OpenAI endpoint

It reverse-engineers Google’s web StreamGenerate protocol so any OpenAI client can chat with Gemini for free, without an API key.

gemini-web2api
Velocity · 7d
+14
★ / day
Trend
accelerating
star history

What it does gemini-web2api is a single Python file that sits between your OpenAI-compatible client and Google Gemini’s web interface. It translates /v1/chat/completions requests into Gemini’s internal protobuf-like payloads and streams back the answers in OpenAI format. No Google API key is required; it talks to the same endpoint the browser uses, optionally using your free Google account cookies if you want Pro routing.

The interesting bit The project reverse-engineered Gemini’s frontend JavaScript to map model selection to field [79] in the payload via the MODE_CATEGORY enum. It also exposes both OpenAI and Google-native endpoints (/v1beta/models), so it works with the OpenAI SDK, Codex CLI, and Google’s own Gemini CLI simultaneously.

Key highlights

  • Pure Python 3.8+, zero third-party dependencies.
  • Optional Bearer-token auth; runs open by default.
  • Supports tool calling, SSE streaming, and adjustable thinking depth via model suffixes like @think=0.
  • Built-in web search via Gemini’s native search capability.
  • Proxy support for regions where gemini.google.com is blocked.

Caveats

  • No image or multimodal input: Gemini’s image upload relies on a proprietary streaming RPC protocol that can’t be replicated here.
  • Without a paid subscription cookie, the gemini-3.1-pro model routes to the same Flash backend; the label is cosmetic.
  • Each request is effectively single-turn. Multi-turn conversations are simulated by stuffing previous messages into the prompt, and Google may throttle sustained use.

Verdict Worth a look if you want a local, dependency-free drop-in replacement for OpenAI endpoints backed by Gemini’s free web tier. Skip it if you need reliable vision support, true multi-turn stateful chat, or guaranteed Pro-tier quality.

Frequently asked

What is Sophomoresty/gemini-web2api?
It reverse-engineers Google’s web StreamGenerate protocol so any OpenAI client can chat with Gemini for free, without an API key.
Is gemini-web2api open source?
Yes — Sophomoresty/gemini-web2api is open source, released under the MIT license.
What language is gemini-web2api written in?
Sophomoresty/gemini-web2api is primarily written in Python.
How popular is gemini-web2api?
Sophomoresty/gemini-web2api has 2.1k stars on GitHub and is currently accelerating.
Where can I find gemini-web2api?
Sophomoresty/gemini-web2api is on GitHub at https://github.com/Sophomoresty/gemini-web2api.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.