whatisgithub

What is gemini-web2api?

sophomoresty/gemini-web2api — explained in plain English

Analysis updated 2026-05-18

645PythonAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

gemini-web2api is a single Python script that exposes Google Gemini through an OpenAI-compatible local API, using browser cookies instead of a paid API key.

Mindmap

mindmap
  root((gemini-web2api))
    What it does
      OpenAI-compatible API for Gemini
      Reverse-engineers web protocol
      No official API key needed
      Zero dependencies
    Tech stack
      Python standard library
      Docker optional
    Use cases
      Use OpenAI clients with Gemini
      Tool calling and streaming
      Web search via Gemini
    Audience
      Developers
      Self-hosters

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Point an OpenAI-compatible chat client, like Cherry Studio or the OpenAI SDK, at Gemini without an official API key.

USE CASE 2

Run a local server that translates OpenAI-format requests into Gemini's web protocol and back.

USE CASE 3

Use tool calling and streaming responses with Gemini through a familiar OpenAI-style interface.

USE CASE 4

Access the Pro model by exporting Google account cookies from a browser session.

What is it built with?

Python

How does it compare?

sophomoresty/gemini-web2apibytedance/lancehuangchihhungleo/claude-real-video
Stars645637637
LanguagePythonPythonPython
Setup difficultyeasyhardmoderate
Complexity2/55/52/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Pure Python standard library, no dependencies, Pro model access requires exporting browser cookies from a signed-in Google account.

MIT License: free to use, modify, and distribute, including commercially, as long as the license notice is kept.

So what is it?

Gemini-web2api is a single Python file that runs a local server on your computer and makes Google's Gemini AI accessible through the same API format that OpenAI uses. Any application that already knows how to talk to OpenAI's ChatGPT API can be pointed at this local server instead, and it will work without changes. This means tools like Cherry Studio, the OpenAI Python library, and many other chat clients can use Gemini without needing an official Gemini API key. The tool works by reverse-engineering the internal web protocol that the Gemini website uses in your browser. It translates incoming requests from the OpenAI format, forwards them to Google's web endpoint, and translates the responses back. Since it uses the web interface rather than a paid API, it costs nothing beyond your existing Google account. Anonymous access works for the faster Flash models. Getting access to the Pro model requires exporting cookies from your browser after signing in with a free Google account and providing that cookie file to the server. Several Gemini models are available through the server including Flash, Flash Thinking, Pro, and Lite variants. The thinking depth of the reasoning models can be adjusted by appending a parameter to the model name. The server also supports streaming responses so answers appear word by word, tool calling so AI agents can invoke functions you define, and web search so Gemini can look things up as part of answering a question. The README is upfront about the limitations. Images cannot be sent because the file upload protocol used by the Gemini website is proprietary and cannot be replicated. Each request is independent, so multi-turn conversation works only by including the full conversation history in each new request. Google may slow down or block high-frequency use. The entire project has no external Python dependencies beyond the standard library. It can also be run inside Docker with a configuration file for persistent settings.

Copy-paste prompts

Prompt 1
Show me how to run gemini_web2api.py and point the OpenAI Python SDK at it for a chat completion.
Prompt 2
Walk me through exporting Gemini cookies from Chrome to enable Pro model routing in gemini-web2api.
Prompt 3
Set up gemini-web2api with Docker Compose and a config.json with API key authentication enabled.
Prompt 4
Explain gemini-web2api's limitations around image input and multi-turn conversation handling.

Frequently asked questions

What is gemini-web2api?

gemini-web2api is a single Python script that exposes Google Gemini through an OpenAI-compatible local API, using browser cookies instead of a paid API key.

What language is gemini-web2api written in?

Mainly Python. The stack also includes Python.

What license does gemini-web2api use?

MIT License: free to use, modify, and distribute, including commercially, as long as the license notice is kept.

How hard is gemini-web2api to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is gemini-web2api for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.