diff --git a/README.md b/README.md index f4d8ed82..b2e017a7 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ The first Chinese provider has now been added: [Qwen Code](https://github.com/Qw - OpenAI Codex support (GPT models) via OAuth login - Claude Code support via OAuth login - Qwen Code support via OAuth login +- Gemini Web support via cookie-based login - Streaming and non-streaming responses - Function calling/tools support - Multimodal input support (text and images) @@ -76,6 +77,13 @@ You can authenticate for Gemini, OpenAI, and/or Claude. All can coexist in the s Options: add `--no-browser` to print the login URL instead of opening a browser. The local OAuth callback uses port `8085`. +- Gemini Web (via Cookies): + This method authenticates by simulating a browser, using cookies obtained from the Gemini website. + ```bash + ./cli-proxy-api --gemini-web-auth + ``` + You will be prompted to enter your `__Secure-1PSID` and `__Secure-1PSIDTS` values. Please retrieve these cookies from your browser's developer tools. + - OpenAI (Codex/GPT via OAuth): ```bash ./cli-proxy-api --codex-login @@ -277,6 +285,12 @@ The server uses a YAML configuration file (`config.yaml`) located in the project | `openai-compatibility.*.models` | object[] | [] | The actual model name. | | `openai-compatibility.*.models.*.name` | string | "" | The models supported by the provider. | | `openai-compatibility.*.models.*.alias` | string | "" | The alias used in the API. | +| `gemini-web` | object | {} | Configuration specific to the Gemini Web client. | +| `gemini-web.context` | boolean | true | Enables conversation context reuse for continuous dialogue. | +| `gemini-web.code-mode` | boolean | false | Enables code mode for optimized responses in coding-related tasks. | +| `gemini-web.max-chars-per-request` | integer | 1,000,000 | The maximum number of characters to send to Gemini Web in a single request. | +| `gemini-web.disable-continuation-hint` | boolean | false | Disables the continuation hint for split prompts. | +| `gemini-web.token-refresh-seconds` | integer | 540 | The interval in seconds for background cookie auto-refresh. | ### Example Configuration File @@ -312,6 +326,13 @@ quota-exceeded: switch-project: true # Whether to automatically switch to another project when a quota is exceeded switch-preview-model: true # Whether to automatically switch to a preview model when a quota is exceeded +# Gemini Web client configuration +gemini-web: + context: true # Enable conversation context reuse + code-mode: false # Enable code mode + max-chars-per-request: 1000000 # Max characters per request + token-refresh-seconds: 540 # Cookie refresh interval in seconds + # API keys for authentication api-keys: - "your-api-key-1" @@ -491,6 +512,12 @@ Run the following command to login (Gemini OAuth on port 8085): docker run --rm -p 8085:8085 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --login ``` +Run the following command to login (Gemini Web Cookies): + +```bash +docker run -it --rm -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --gemini-web-auth +``` + Run the following command to login (OpenAI OAuth on port 1455): ```bash @@ -555,7 +582,11 @@ docker run --rm -p 8317:8317 -v /path/to/your/config.yaml:/CLIProxyAPI/config.ya ```bash docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --login ``` - - **OpenAI (Codex)**: + - **Gemini Web**: + ```bash + docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI --gemini-web-auth + ``` + - **OpenAI (Codex)**: ```bash docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --codex-login ``` diff --git a/README_CN.md b/README_CN.md index 9a99df97..0b44c179 100644 --- a/README_CN.md +++ b/README_CN.md @@ -36,6 +36,7 @@ - 新增 OpenAI Codex(GPT 系列)支持(OAuth 登录) - 新增 Claude Code 支持(OAuth 登录) - 新增 Qwen Code 支持(OAuth 登录) +- 新增 Gemini Web 支持(通过 Cookie 登录) - 支持流式与非流式响应 - 函数调用/工具支持 - 多模态输入(文本、图片) @@ -89,6 +90,13 @@ 选项:加上 `--no-browser` 可打印登录地址而不自动打开浏览器。本地 OAuth 回调端口为 `8085`。 +- Gemini Web (通过 Cookie): + 此方法通过模拟浏览器行为,使用从 Gemini 网站获取的 Cookie 进行身份验证。 + ```bash + ./cli-proxy-api --gemini-web-auth + ``` + 程序将提示您输入 `__Secure-1PSID` 和 `__Secure-1PSIDTS` 的值。请从您的浏览器开发者工具中获取这些 Cookie。 + - OpenAI(Codex/GPT,OAuth): ```bash ./cli-proxy-api --codex-login @@ -289,6 +297,12 @@ console.log(await claudeResponse.json()); | `openai-compatibility.*.models` | object[] | [] | 实际的模型名称。 | | `openai-compatibility.*.models.*.name` | string | "" | 提供商支持的模型。 | | `openai-compatibility.*.models.*.alias` | string | "" | 在API中使用的别名。 | +| `gemini-web` | object | {} | Gemini Web 客户端的特定配置。 | +| `gemini-web.context` | boolean | true | 是否启用会话上下文重用,以实现连续对话。 | +| `gemini-web.code-mode` | boolean | false | 是否启用代码模式,优化代码相关任务的响应。 | +| `gemini-web.max-chars-per-request` | integer | 1,000,000 | 单次请求发送给 Gemini Web 的最大字符数。 | +| `gemini-web.disable-continuation-hint` | boolean | false | 当提示被拆分时,是否禁用连续提示的暗示。 | +| `gemini-web.token-refresh-seconds` | integer | 540 | 后台 Cookie 自动刷新的间隔(秒)。 | ### 配置文件示例 @@ -324,6 +338,13 @@ quota-exceeded: switch-project: true # 当配额超限时是否自动切换到另一个项目 switch-preview-model: true # 当配额超限时是否自动切换到预览模型 +# Gemini Web 客户端配置 +gemini-web: + context: true # 启用会话上下文重用 + code-mode: false # 启用代码模式 + max-chars-per-request: 1000000 # 单次请求最大字符数 + token-refresh-seconds: 540 # Cookie 刷新间隔(秒) + # 用于本地身份验证的 API 密钥 api-keys: - "your-api-key-1" @@ -499,6 +520,12 @@ auth.json: docker run --rm -p 8085:8085 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --login ``` +运行以下命令进行登录(Gemini Web Cookie): + +```bash +docker run -it --rm -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --gemini-web-auth +``` + 运行以下命令进行登录(OpenAI OAuth,端口 1455): ```bash @@ -564,7 +591,11 @@ docker run --rm -p 8317:8317 -v /path/to/your/config.yaml:/CLIProxyAPI/config.ya ```bash docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --login ``` - - **OpenAI (Codex)**: + - **Gemini Web**: + ```bash + docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI --gemini-web-auth + ``` + - **OpenAI (Codex)**: ```bash docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --codex-login ```