{"id":52043959,"url":"https://github.com/ikhsan3adi/gemini-web2api","last_synced_at":"2026-08-07T08:00:58.704Z","repository":{"id":374129608,"uuid":"1318987224","full_name":"ikhsan3adi/gemini-web2api","owner":"ikhsan3adi","description":"Blazing fast Go port of gemini-web2api. Convert Google Gemini web into OpenAI-compatible API. Zero cost, single static binary.","archived":false,"fork":false,"pushed_at":"2026-08-03T01:54:58.000Z","size":65,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-08-06T14:59:32.782Z","etag":null,"topics":["9router","ai-agent","ai-proxy","gemini","gemini-api","gemini-api-key","gemini-proxy","go","go-port","golang","google-gemini","llm","llm-proxy","multimodal","openai-api","openai-codex","openai-compatible","proxy","rewrite","web2api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ikhsan3adi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"claude":null,"gemini":null,"cursor":null,"copilot":null,"dco":null,"cla":null,"disclosure":null}},"created_at":"2026-08-01T05:13:33.000Z","updated_at":"2026-08-05T13:02:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ikhsan3adi/gemini-web2api","commit_stats":null,"previous_names":["ikhsan3adi/gemini-web2api"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ikhsan3adi/gemini-web2api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikhsan3adi%2Fgemini-web2api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikhsan3adi%2Fgemini-web2api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikhsan3adi%2Fgemini-web2api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikhsan3adi%2Fgemini-web2api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikhsan3adi","download_url":"https://codeload.github.com/ikhsan3adi/gemini-web2api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikhsan3adi%2Fgemini-web2api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":36352073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-08-06T04:43:03.162Z","status":"ssl_error","status_checked_at":"2026-08-06T04:43:02.660Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["9router","ai-agent","ai-proxy","gemini","gemini-api","gemini-api-key","gemini-proxy","go","go-port","golang","google-gemini","llm","llm-proxy","multimodal","openai-api","openai-codex","openai-compatible","proxy","rewrite","web2api"],"created_at":"2026-08-02T03:01:34.554Z","updated_at":"2026-08-07T08:00:58.653Z","avatar_url":"https://github.com/ikhsan3adi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gemini-web2api\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/Sophomoresty/gemini-web2api/main/logo.png\" width=\"200\" alt=\"gemini-web2api logo\"\u003e\n\u003c/p\u003e\n\nHigh-performance Go proxy converting Google Gemini's web interface into an OpenAI-compatible API. Zero cost, cross-platform, single static binary.\n\nThis is a complete Go rewrite of the original [Python gemini-web2api](https://github.com/Sophomoresty/gemini-web2api). It features massive concurrency throughput, minimal memory footprint, and enhanced capabilities such as **TLS Impersonation** for WAF bypass.\n\n## Key Features\n\n- **Optional API Keys**: No auth when `api_keys` is empty, OpenAI-style Bearer auth when configured.\n- **OpenAI Compatible**: Drop-in replacement for `/v1/chat/completions`, `/v1/models`, and `/v1/responses` (Codex CLI).\n- **Multimodal (Vision)**: Fully supports sending images (`image_url` / base64) to Gemini using Scotty Resumable Upload protocol natively with built-in image compression.\n- **TLS Impersonation**: Built-in support to bypass Cloudflare/WAF by mimicking Chrome/Edge TLS fingerprints using `tls-client` 🔥.\n- **Tool Calling**: Full function calling support (OpenAI format).\n- **Multiple Models**: Flash (3.6), Extended Thinking (20k+ char output), Pro, Auto, Lite.\n- **Thinking Depth**: Adjustable reasoning via `@think=N` suffix (0=deepest, 4=shallowest).\n- **Web Search**: Built-in internet access (Gemini's native search).\n- **High Performance**: Pure Go static binary with high concurrent SSE streaming throughput and minimal memory footprint.\n- **Cross-Platform**: Zero runtime dependencies, single static binary.\n- **Codex CLI**: Responses API (`/v1/responses`) for OpenAI Codex integration.\n- **Gemini CLI**: Google native API (`/v1beta/models`) for Gemini CLI compatibility.\n\n## Quick Start\n\n### 1. Download Pre-built Binary (Recommended)\n\nDownload the pre-compiled binary for your OS (Linux, macOS, Windows) from the [Releases](https://github.com/ikhsan3adi/gemini-web2api/releases) page:\n\n**Linux / macOS:**\n```bash\nchmod +x gemini-web2api\n./gemini-web2api --port 8081\n```\n\n**Windows (PowerShell / Command Prompt):**\n```powershell\n.\\gemini-web2api.exe --port 8081\n```\n\n### 2. Install via Go Toolchain\n\nIf you have Go 1.22+ installed on your system:\n\n```bash\ngo install github.com/ikhsan3adi/gemini-web2api@latest\n```\n\nThis compiles and places the binary directly into your `$GOPATH/bin` (or `%USERPROFILE%\\go\\bin`). Run it from anywhere:\n\n```bash\ngemini-web2api --port 8081\n```\n\n### 3. Build from Source\n\nPrerequisites: Go 1.22+\n\n```bash\ngit clone https://github.com/ikhsan3adi/gemini-web2api.git\ncd gemini-web2api\n```\n\nAfter building, run the executable:\n\n**Linux / macOS:**\n```bash\ngo build -o gemini-web2api .\n./gemini-web2api --port 8081\n```\n\n**Windows (PowerShell / Command Prompt):**\n```powershell\ngo build -o gemini-web2api.exe .\n.\\gemini-web2api.exe --port 8081\n```\n\nServer starts at `http://localhost:8081/v1`.\n\n### 4. Run via Docker\n\nBefore running via Docker, copy the example config file:\n```bash\ncp config.example.json config.json\n```\n\n#### Option A: Run pre-built GHCR Image (No git clone needed)\n\n```bash\ndocker run -d --name gemini-web2api -p 8081:8081 ghcr.io/ikhsan3adi/gemini-web2api:latest\n```\n\n#### Option B: Build and run locally\n\n```bash\ndocker build -t gemini-web2api .\ndocker run -d --name gemini-web2api -p 8081:8081 -v ./config.json:/app/config.json gemini-web2api\n```\n\n#### Option C: Docker Compose\n\n```bash\ndocker compose up -d\n```\n\n\u003e **Note**: If you get empty responses (`content: null`) with Docker's default bridge network, switch to host networking: `docker run --network host ...` or add `network_mode: host` in your compose file. This is caused by Gemini's upstream rejecting requests from certain Docker NAT IP ranges.\n\n## Client Configuration\n\n### Cherry Studio / ChatBox / any OpenAI client\n\n| Field    | Value                                                               |\n| -------- | ------------------------------------------------------------------- |\n| Base URL | `http://localhost:8081/v1`                                          |\n| API Key  | any `api_keys` value from `config.json`; anything if not configured |\n| Model    | `gemini-3.5-flash-thinking`                                         |\n\n### curl\n\n#### bash / macOS / Linux\n\n```bash\ncurl http://localhost:8081/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer sk-your-key\" \\\n  -d '{\"model\":\"gemini-3.5-flash\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello!\"}]}'\n```\n\n#### PowerShell (Windows)\n\n```powershell\ncurl.exe --% http://127.0.0.1:8081/v1/chat/completions -H \"Content-Type: application/json\" -H \"Authorization: Bearer sk-your-key\" -d \"{\\\"model\\\":\\\"gemini-3.5-flash\\\",\\\"messages\\\":[{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Hello!\\\"}]}\"\n```\n\u003e Note: On Windows PowerShell, use `curl.exe` and `--%` so PowerShell does not reinterpret JSON quoting or curl options.\n\n### OpenAI Python SDK\n\n```python\nfrom openai import OpenAI\nclient = OpenAI(base_url=\"http://localhost:8081/v1\", api_key=\"sk-your-key\")\nresp = client.chat.completions.create(\n    model=\"gemini-3.5-flash-thinking\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain quantum computing\"}]\n)\nprint(resp.choices[0].message.content)\n```\n\n### Gemini CLI\n\n```bash\nexport GEMINI_API_KEY=none\nexport GOOGLE_GEMINI_BASE_URL=http://localhost:8081\ngemini\n```\n\nSupports Google native API endpoints:\n- `GET /v1beta/models` — list models\n- `POST /v1beta/models/{model}:generateContent` — non-streaming\n- `POST /v1beta/models/{model}:streamGenerateContent` — streaming (SSE)\n\n## Available Models\n\n| Model                            | Description                         | Output         |\n| -------------------------------- | ----------------------------------- | -------------- |\n| `gemini-3.6-flash`               | All-around model (latest)           | ~12k chars     |\n| `gemini-3.5-flash`               | Alias for gemini-3.6-flash          | ~12k chars     |\n| `gemini-3.5-flash-thinking`      | Extended thinking, longest output   | **~20k chars** |\n| `gemini-3.5-flash-thinking-lite` | Adaptive thinking depth             | ~15k chars     |\n| `gemini-3.1-pro`                 | Advanced math \u0026 code (needs cookie) | ~12k chars     |\n| `gemini-auto`                    | Auto model selection                | varies         |\n| `gemini-flash-lite`              | Fastest answers, lightweight        | ~10k chars     |\n\n### Thinking Depth\n\nAppend `@think=N` to any model name to control reasoning logic:\n\n```text\ngemini-3.5-flash-thinking@think=0   # deepest (default for thinking model)\ngemini-3.5-flash-thinking@think=2   # medium\ngemini-3.5-flash-thinking@think=4   # shallowest\n```\n\n## Advanced Features (Go Exclusive)\n\n### 1. Vision / Multimodal Uploads\nUnlike the Python version which ignores images, this Go port actively intercepts `image_url` payloads (both base64 encoded and external HTTP URLs).\nIt initiates a background Scotty Resumable Upload session, converts the base64 image into Google internal WIZ blobs, and passes the WIZ image references directly to Gemini.\nJust send OpenAI standard multimodal payloads and it will work!\n\n### 2. TLS Impersonation (Bypass WAF)\nIf you run this tool in datacenters (like AWS/DigitalOcean) where Google blocks the IP with a 403 Forbidden, you can impersonate a real browser's TLS signature:\n\n```bash\n./gemini-web2api --impersonate chrome_120\n```\nOr in `config.json`: `\"impersonate\": \"chrome_120\"`. Supported profiles include `chrome_112` to `chrome_130`, `edge`, and `safari`.\n\n## Optional: Cookie for Pro\n\nAnonymous access works for all models, but `gemini-3.1-pro` routes to Flash without authentication. To get real Pro routing, you need a **Gemini Advanced (paid subscription)** account cookie:\n\n```bash\n./gemini-web2api --cookie-file cookie.txt\n```\n\n### How to get cookies\n\n1. Open Chrome, go to [gemini.google.com](https://gemini.google.com) and sign in with a **Gemini Advanced** Google account\n2. Open DevTools (F12) → Application → Cookies → `https://gemini.google.com`\n3. Copy these cookie values: `SID`, `HSID`, `SSID`, `APISID`, `SAPISID`, `__Secure-1PSID`\n4. Create `cookie.txt` in this format:\n\n```text\nSID=your_sid; HSID=your_hsid; SSID=your_ssid; APISID=your_apisid; SAPISID=your_sapisid; __Secure-1PSID=your_1psid\n```\n\nOr use JSON format if you know your specific `SAPISID` hashing needs:\n```json\n{\"cookie\": \"SID=xxx; HSID=xxx; ...\", \"sapisid\": \"your_sapisid_value\"}\n```\n\n**Alternative (browser extension)**: Use any \"Export Cookies\" extension to export cookies for `gemini.google.com` in Netscape format, then convert to the single-line format above.\n\n### Authenticated account path and XSRF token\n\nIf the signed-in Gemini page URL contains an account index, such as:\n\n```text\nhttps://gemini.google.com/u/1/app/...\n```\n\nset `auth_user` to that index. Authenticated web requests may also require the page XSRF token. In the rendered Gemini page source, this token is exposed as `SNlM0e`; pass it as `xsrf_token` in `config.json`. The server sends it as the `at` form field.\n\nExample:\n\n```json\n{\n  \"cookie_file\": \"/app/cookie.txt\",\n  \"auth_user\": \"1\",\n  \"xsrf_token\": \"AOOh0P...\",\n  \"gemini_bl\": \"boq_assistant-bard-web-server_YYYYMMDD.xx_p0\"\n}\n```\n\nIf authenticated requests return HTTP 400 with an `xsrf` error, refresh Gemini Web, update `xsrf_token`, and make sure `auth_user` matches the `/u/\u003cindex\u003e/` part of the browser URL.\n\nPro routing requires **Gemini Advanced** (paid subscription). A free Google account cookie will authenticate but silently fall back to Flash.\n\n## Configuration\n\nCreate `config.json` in the same directory:\n\n```json\n{\n  \"port\": 8081,\n  \"host\": \"0.0.0.0\",\n  \"retry_attempts\": 3,\n  \"retry_delay_sec\": 2,\n  \"request_timeout_sec\": 180,\n  \"gemini_bl\": \"boq_assistant-bard-web-server_20260716.08_p0\",\n  \"auth_user\": null,\n  \"xsrf_token\": null,\n  \"api_keys\": [\"sk-your-key\"],\n  \"cookie_file\": null,\n  \"proxy\": null,\n  \"impersonate\": null,\n  \"log_requests\": true\n}\n```\n\nWhen `api_keys` is empty `[]`, authentication is disabled. When keys are set, `/v1/*` endpoints require `Authorization: Bearer \u003ckey\u003e`.\n\n## Proxy\n\nIf you cannot access `gemini.google.com` directly, configure a proxy:\n\n**Method 1: CLI argument**\n```bash\n# Linux / macOS\n./gemini-web2api --proxy http://127.0.0.1:7890\n\n# Windows (PowerShell)\n.\\gemini-web2api.exe --proxy http://127.0.0.1:7890\n```\n\n**Method 2: config.json**\n```json\n{\"proxy\": \"http://127.0.0.1:7890\"}\n```\n\n**Method 3: Environment variable**\n```bash\n# Linux / macOS (bash)\nexport HTTPS_PROXY=http://127.0.0.1:7890\n./gemini-web2api\n\n# Windows (PowerShell)\n$env:HTTPS_PROXY=\"http://127.0.0.1:7890\"\n.\\gemini-web2api.exe\n\n# Windows (Command Prompt)\nset HTTPS_PROXY=http://127.0.0.1:7890\ngemini-web2api.exe\n```\n\n## Limitations\n\n- **Not real Pro/Ultra**: Without a paid subscription cookie, `gemini-3.1-pro` routes to the same Flash model. The \"Pro\" label is a UI preference, not a backend model switch.\n- **Single-turn only**: Each request is an independent conversation. Multi-turn context is simulated by including previous messages in the prompt.\n- **Rate limits**: Google may throttle high-frequency requests. The server retries automatically but sustained heavy use may be blocked.\n\n## License\n\nMIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikhsan3adi%2Fgemini-web2api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikhsan3adi%2Fgemini-web2api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikhsan3adi%2Fgemini-web2api/lists"}