Spaces:
Sleeping
Sleeping
Commit ·
b866ca0
1
Parent(s): 75fe411
docs: fix outdated claims in README
Browse files- httpx is required for streaming, not stdlib-only
- Pro routing needs Gemini Advanced (paid), not free account
- Add pip install httpx to Quick Start
- README.md +8 -7
- README_CN.md +8 -7
README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
|
| 7 |
[中文文档](README_CN.md)
|
| 8 |
|
| 9 |
-
Convert Google Gemini's web interface into an OpenAI-compatible API. Zero
|
| 10 |
|
| 11 |
## Features
|
| 12 |
|
|
@@ -16,14 +16,15 @@ Convert Google Gemini's web interface into an OpenAI-compatible API. Zero authen
|
|
| 16 |
- **Multiple Models**: Flash, Flash Thinking (20k+ char output), Pro, Auto, Lite
|
| 17 |
- **Thinking Depth**: Adjustable via `@think=N` suffix (0=deepest, 4=shallowest)
|
| 18 |
- **Web Search**: Built-in internet access (Gemini's native search)
|
| 19 |
-
- **Cross-Platform**: Pure Python,
|
| 20 |
-
- **Streaming**: SSE streaming support
|
| 21 |
- **Codex CLI**: Responses API (`/v1/responses`) for OpenAI Codex integration
|
| 22 |
- **Gemini CLI**: Google native API (`/v1beta/models`) for Gemini CLI compatibility
|
| 23 |
|
| 24 |
## Quick Start
|
| 25 |
|
| 26 |
```bash
|
|
|
|
| 27 |
python gemini_web2api.py
|
| 28 |
```
|
| 29 |
|
|
@@ -96,7 +97,7 @@ gemini-3.5-flash-thinking@think=4 # shallowest
|
|
| 96 |
|
| 97 |
## Optional: Cookie for Pro
|
| 98 |
|
| 99 |
-
Anonymous access works for all models, but `gemini-3.1-pro` routes to Flash without authentication. To get real Pro routing,
|
| 100 |
|
| 101 |
```bash
|
| 102 |
python gemini_web2api.py --cookie-file cookie.txt
|
|
@@ -104,7 +105,7 @@ python gemini_web2api.py --cookie-file cookie.txt
|
|
| 104 |
|
| 105 |
### How to get cookies
|
| 106 |
|
| 107 |
-
1. Open Chrome, go to [gemini.google.com](https://gemini.google.com) and sign in with
|
| 108 |
2. Open DevTools (F12) → Application → Cookies → `https://gemini.google.com`
|
| 109 |
3. Copy these cookie values: `SID`, `HSID`, `SSID`, `APISID`, `SAPISID`, `__Secure-1PSID`
|
| 110 |
4. Create `cookie.txt` in this format:
|
|
@@ -143,7 +144,7 @@ Example:
|
|
| 143 |
|
| 144 |
If authenticated requests return HTTP 400 with an `xsrf` error, refresh Gemini Web, update `xsrf_token`, and make sure `auth_user` matches the `/u/<index>/` part of the browser URL.
|
| 145 |
|
| 146 |
-
|
| 147 |
|
| 148 |
## Configuration
|
| 149 |
|
|
@@ -240,7 +241,7 @@ resp = client.chat.completions.create(
|
|
| 240 |
## Requirements
|
| 241 |
|
| 242 |
- Python 3.8+
|
| 243 |
-
-
|
| 244 |
- Network access to `gemini.google.com` (proxy/VPN may be needed in some regions)
|
| 245 |
|
| 246 |
## How It Works
|
|
|
|
| 6 |
|
| 7 |
[中文文档](README_CN.md)
|
| 8 |
|
| 9 |
+
Convert Google Gemini's web interface into an OpenAI-compatible API. Zero cost, cross-platform, single file.
|
| 10 |
|
| 11 |
## Features
|
| 12 |
|
|
|
|
| 16 |
- **Multiple Models**: Flash, Flash Thinking (20k+ char output), Pro, Auto, Lite
|
| 17 |
- **Thinking Depth**: Adjustable via `@think=N` suffix (0=deepest, 4=shallowest)
|
| 18 |
- **Web Search**: Built-in internet access (Gemini's native search)
|
| 19 |
+
- **Cross-Platform**: Pure Python, single optional dependency (`httpx` for streaming)
|
| 20 |
+
- **Streaming**: SSE streaming support via `httpx`
|
| 21 |
- **Codex CLI**: Responses API (`/v1/responses`) for OpenAI Codex integration
|
| 22 |
- **Gemini CLI**: Google native API (`/v1beta/models`) for Gemini CLI compatibility
|
| 23 |
|
| 24 |
## Quick Start
|
| 25 |
|
| 26 |
```bash
|
| 27 |
+
pip install httpx
|
| 28 |
python gemini_web2api.py
|
| 29 |
```
|
| 30 |
|
|
|
|
| 97 |
|
| 98 |
## Optional: Cookie for Pro
|
| 99 |
|
| 100 |
+
Anonymous 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:
|
| 101 |
|
| 102 |
```bash
|
| 103 |
python gemini_web2api.py --cookie-file cookie.txt
|
|
|
|
| 105 |
|
| 106 |
### How to get cookies
|
| 107 |
|
| 108 |
+
1. Open Chrome, go to [gemini.google.com](https://gemini.google.com) and sign in with a **Gemini Advanced** Google account
|
| 109 |
2. Open DevTools (F12) → Application → Cookies → `https://gemini.google.com`
|
| 110 |
3. Copy these cookie values: `SID`, `HSID`, `SSID`, `APISID`, `SAPISID`, `__Secure-1PSID`
|
| 111 |
4. Create `cookie.txt` in this format:
|
|
|
|
| 144 |
|
| 145 |
If authenticated requests return HTTP 400 with an `xsrf` error, refresh Gemini Web, update `xsrf_token`, and make sure `auth_user` matches the `/u/<index>/` part of the browser URL.
|
| 146 |
|
| 147 |
+
Pro routing requires **Gemini Advanced** (paid subscription). A free Google account cookie will authenticate but silently fall back to Flash.
|
| 148 |
|
| 149 |
## Configuration
|
| 150 |
|
|
|
|
| 241 |
## Requirements
|
| 242 |
|
| 243 |
- Python 3.8+
|
| 244 |
+
- `httpx` (`pip install httpx`) — used for streaming requests
|
| 245 |
- Network access to `gemini.google.com` (proxy/VPN may be needed in some regions)
|
| 246 |
|
| 247 |
## How It Works
|
README_CN.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
|
| 7 |
[English](README.md)
|
| 8 |
|
| 9 |
-
将 Google Gemini 网页端转换为 OpenAI 兼容 API. 零
|
| 10 |
|
| 11 |
## 特性
|
| 12 |
|
|
@@ -16,14 +16,15 @@
|
|
| 16 |
- **多模型**: Flash, Flash Thinking (2万字+输出), Pro, Auto, Lite
|
| 17 |
- **思考深度**: 通过 `@think=N` 后缀调节 (0=最深, 4=最浅)
|
| 18 |
- **联网搜索**: 内置互联网访问 (Gemini 原生搜索能力)
|
| 19 |
-
- **跨平台**: 纯 Python,
|
| 20 |
-
- **流式输出**: SSE Streaming 支持
|
| 21 |
- **Codex CLI**: Responses API (`/v1/responses`) 兼容 OpenAI Codex
|
| 22 |
- **Gemini CLI**: Google 原生 API (`/v1beta/models`) 兼容 Gemini CLI
|
| 23 |
|
| 24 |
## 快速开始
|
| 25 |
|
| 26 |
```bash
|
|
|
|
| 27 |
python gemini_web2api.py
|
| 28 |
```
|
| 29 |
|
|
@@ -96,7 +97,7 @@ gemini-3.5-flash-thinking@think=4 # 最浅
|
|
| 96 |
|
| 97 |
## 可选: Cookie 配置 (Pro 模型)
|
| 98 |
|
| 99 |
-
匿名访问对所有模型有效, 但 `gemini-3.1-pro` 在无认证时会路由到 Flash. 要获得真正的 Pro 路由,
|
| 100 |
|
| 101 |
```bash
|
| 102 |
python gemini_web2api.py --cookie-file cookie.txt
|
|
@@ -104,7 +105,7 @@ python gemini_web2api.py --cookie-file cookie.txt
|
|
| 104 |
|
| 105 |
### 如何获取 Cookie
|
| 106 |
|
| 107 |
-
1. 打开 Chrome, 访问 [gemini.google.com](https://gemini.google.com) 并登录
|
| 108 |
2. 打开开发者工具 (F12) → Application → Cookies → `https://gemini.google.com`
|
| 109 |
3. 复制以下 cookie 值: `SID`, `HSID`, `SSID`, `APISID`, `SAPISID`, `__Secure-1PSID`
|
| 110 |
4. 创建 `cookie.txt`, 格式如下:
|
|
@@ -143,7 +144,7 @@ https://gemini.google.com/u/1/app/...
|
|
| 143 |
|
| 144 |
如果登录态请求返回 HTTP 400 且错误中包含 `xsrf`, 请刷新 Gemini Web 后更新 `xsrf_token`, 并确认 `auth_user` 与浏览器 URL 中的 `/u/<序号>/` 一致.
|
| 145 |
|
| 146 |
-
|
| 147 |
|
| 148 |
## 配置文件
|
| 149 |
|
|
@@ -223,7 +224,7 @@ python gemini_web2api.py
|
|
| 223 |
## 系统要求
|
| 224 |
|
| 225 |
- Python 3.8+
|
| 226 |
-
-
|
| 227 |
- 需要能访问 `gemini.google.com` (部分地区需代理)
|
| 228 |
|
| 229 |
## 工作原理
|
|
|
|
| 6 |
|
| 7 |
[English](README.md)
|
| 8 |
|
| 9 |
+
将 Google Gemini 网页端转换为 OpenAI 兼容 API. 零成本, 跨平台, 单文件.
|
| 10 |
|
| 11 |
## 特性
|
| 12 |
|
|
|
|
| 16 |
- **多模型**: Flash, Flash Thinking (2万字+输出), Pro, Auto, Lite
|
| 17 |
- **思考深度**: 通过 `@think=N` 后缀调节 (0=最深, 4=最浅)
|
| 18 |
- **联网搜索**: 内置互联网访问 (Gemini 原生搜索能力)
|
| 19 |
+
- **跨平台**: 纯 Python, 仅一个可选依赖 (`httpx` 用于流式输出)
|
| 20 |
+
- **流式输出**: 基于 `httpx` 的 SSE Streaming 支持
|
| 21 |
- **Codex CLI**: Responses API (`/v1/responses`) 兼容 OpenAI Codex
|
| 22 |
- **Gemini CLI**: Google 原生 API (`/v1beta/models`) 兼容 Gemini CLI
|
| 23 |
|
| 24 |
## 快速开始
|
| 25 |
|
| 26 |
```bash
|
| 27 |
+
pip install httpx
|
| 28 |
python gemini_web2api.py
|
| 29 |
```
|
| 30 |
|
|
|
|
| 97 |
|
| 98 |
## 可选: Cookie 配置 (Pro 模型)
|
| 99 |
|
| 100 |
+
匿名访问对所有模型有效, 但 `gemini-3.1-pro` 在无认证时会路由到 Flash. 要获得真正的 Pro 路由, 需要 **Gemini Advanced (付费订阅)** 账号的 cookie:
|
| 101 |
|
| 102 |
```bash
|
| 103 |
python gemini_web2api.py --cookie-file cookie.txt
|
|
|
|
| 105 |
|
| 106 |
### 如何获取 Cookie
|
| 107 |
|
| 108 |
+
1. 打开 Chrome, 访问 [gemini.google.com](https://gemini.google.com) 并登录 **Gemini Advanced** 付费账号
|
| 109 |
2. 打开开发者工具 (F12) → Application → Cookies → `https://gemini.google.com`
|
| 110 |
3. 复制以下 cookie 值: `SID`, `HSID`, `SSID`, `APISID`, `SAPISID`, `__Secure-1PSID`
|
| 111 |
4. 创建 `cookie.txt`, 格式如下:
|
|
|
|
| 144 |
|
| 145 |
如果登录态请求返回 HTTP 400 且错误中包含 `xsrf`, 请刷新 Gemini Web 后更新 `xsrf_token`, 并确认 `auth_user` 与浏览器 URL 中的 `/u/<序号>/` 一致.
|
| 146 |
|
| 147 |
+
Pro 路由需要 **Gemini Advanced** (付费订阅). 免费 Google 账号的 cookie 可以登录认证, 但会静默回退到 Flash.
|
| 148 |
|
| 149 |
## 配置文件
|
| 150 |
|
|
|
|
| 224 |
## 系统要求
|
| 225 |
|
| 226 |
- Python 3.8+
|
| 227 |
+
- `httpx` (`pip install httpx`) — 用于流式请求
|
| 228 |
- 需要能访问 `gemini.google.com` (部分地区需代理)
|
| 229 |
|
| 230 |
## 工作原理
|