[UNTESTED] [cyberanrhy/gemini-web2api] 1 endpoint(s)
ChatGPT
API Proxy/ChatGPT
2,166 characters
Status: [UNTESTED]
Endpoints found:
http://localhost:8081/v1/chat/completions
http://localhost:8081/v1/models
Source: https://github.com/cyberanrhy/gemini-web2api

# Gemini Web2API
OpenAI-compatible proxy for [Gemini](https://gemini.google.com) Web API.
Converts standard `/v1/chat/completions` requests to Gemini internal `StreamGenerate` endpoint. Works via cookie-based auth — no API key needed.
## Features
- OpenAI-compatible `/v1/chat/completions`
- Streaming (SSE) and non-streaming
- Models: `gemini-3.5-flash`, `gemini-3.5-flash-thinking`, `gemini-flash-lite`, `gemini-pro`, `gemini-auto`
- Tool calling (function calling) support
- OpenAI Responses API (`/v1/responses`) for Codex CLI
- Google AI native API (`:generateContent`, `:streamGenerateContent`)
- Automatic rate-limit retry with xsrf token recovery
- CORS enabled
## Requirements
- **Python 3.10+**
- `pip install -r requirements.txt` (just `requests` + optional `httpx`)
- **Firefox** with [cookies.txt](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/) extension
- **Optional:** VPN/proxy if Google blocks your IP (Gemini sometimes blocks datacenter IPs)
## Setup (step by step)
### 1. Clone & install
```bash
git clone https://github.com/YOUR_USERNAME/gemini-web2api.git
cd gemini-web2api
pip install -r requirements.txt
```
### 2. Copy config
```bash
cp config.json.example config.json
```
### 3. Export cookies
1. Open [Gemini](https://gemini.google.com/app) **in Firefox** and log in
2. Install [cookies.txt](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/) extension (if not already)
3. Click the extension icon → **Export** → save as `cookie.txt`
4. Put `cookie.txt` in the project directory (alongside `gemini_web2api.py`)
> The file must be in **Netscape format** (tabs, not spaces). The cookies.txt extension exports this by default.
### 4. Get xsrf token
The proxy needs an `xsrf_token` to authenticate requests to Gemini. Run:
```bash
python3 -c "
from gemini_web2api import gemini_init, load_config
load_config()
gemini_init()
print('OK — xsrf_token set')
"
```
This extracts the token fr