From 9ca40f6ea07a7d338e0496cc9e807b8d6986eb70 Mon Sep 17 00:00:00 2001 From: hex2077 Date: Sat, 3 Jan 2026 19:16:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(proxy):=20=E6=B7=BB=E5=8A=A0=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 PROXY_URL 和 PROXY_ENABLED_PROVIDERS 配置项,支持为不同提供商设置代理 更新中英日三语文档,详细说明代理配置方法和使用场景 优化静态页面中的代理提供商选择器样式 --- README-JA.md | 60 +++++++++++++++++++++++++++++++++++-- README-ZH.md | 60 +++++++++++++++++++++++++++++++++++-- README.md | 60 +++++++++++++++++++++++++++++++++++-- configs/config.json.example | 7 ++++- package-lock.json | 4 +-- static/index.html | 14 ++++----- 6 files changed, 188 insertions(+), 17 deletions(-) diff --git a/README-JA.md b/README-JA.md index 9b79c29..4ebd9c7 100644 --- a/README-JA.md +++ b/README-JA.md @@ -31,6 +31,8 @@ > > **📅 バージョン更新ログ** > +> - **2026.01.03** - テーマ切替機能を追加し、プロバイダープール初期化を最適化、プロバイダーのデフォルト設定を使用するフォールバック戦略を削除 +> - **2025.12.30** - メインプロセス管理と自動更新機能を追加 > - **2025.12.25** - 設定ファイル統一管理:すべての設定を `configs/` ディレクトリに集約。Dockerユーザーはマウントパスを `-v "ローカルパス:/app/configs"` に更新が必要 > - **2025.12.11** - Dockerイメージが自動的にビルドされ、Docker Hubで公開されました: [justlikemaki/aiclient-2-api](https://hub.docker.com/r/justlikemaki/aiclient-2-api) > - **2025.11.30** - Antigravityプロトコルサポートの追加、Google内部インターフェース経由でGemini 3 Pro、Claude Sonnet 4.5などのモデルへのアクセスをサポート @@ -224,7 +226,61 @@ Web UI管理インターフェースでは、極めて迅速に認証設定を #### 高度な設定 -##### 1. モデルフィルタリング設定 +##### 1. プロキシ設定 + +本プロジェクトは柔軟なプロキシ設定をサポートしており、異なるプロバイダーに統一プロキシを設定したり、プロバイダー独自のプロキシ済みエンドポイントを使用したりできます。 + +**設定方法**: + +1. **Web UI設定**(推奨):便利な設定管理 + + Web UIの「設定管理」ページで、すべてのプロキシオプションを視覚的に設定できます: + - **統一プロキシ**:「プロキシ設定」エリアにプロキシアドレスを入力し、プロキシを使用するプロバイダーにチェックを入れます + - **プロバイダーエンドポイント**:各プロバイダーの設定エリアで、Base URLをプロキシ済みエンドポイントに直接変更します + - **「設定を保存」をクリック**:サービスを再起動せずに即座に有効になります + +2. **統一プロキシ設定**:グローバルプロキシを設定し、どのプロバイダーがそれを使用するかを指定します + + - **Web UI設定**:「設定管理」ページの「プロキシ設定」エリアにプロキシアドレスを入力し、プロキシを使用するプロバイダーにチェックを入れます + - **設定ファイル**:`configs/config.json`で設定 + ```json + { + "PROXY_URL": "http://127.0.0.1:7890", + "PROXY_ENABLED_PROVIDERS": [ + "gemini-cli-oauth", + "gemini-antigravity", + "claude-kiro-oauth" + ] + } + ``` + +3. **プロバイダー独自のプロキシ済みエンドポイント**:一部のプロバイダー(OpenAI、Claudeなど)はプロキシ済みAPIエンドポイントの設定をサポートしています + + - **Web UI設定**:「設定管理」ページの各プロバイダー設定エリアで、対応するBase URLを変更します + - **設定ファイル**:`configs/config.json`で設定 + ```json + { + "OPENAI_BASE_URL": "https://your-proxy-endpoint.com/v1", + "CLAUDE_BASE_URL": "https://your-proxy-endpoint.com" + } + ``` + +**サポートされるプロキシタイプ**: +- **HTTPプロキシ**:`http://127.0.0.1:7890` +- **HTTPSプロキシ**:`https://127.0.0.1:7890` +- **SOCKS5プロキシ**:`socks5://127.0.0.1:1080` + +**使用シナリオ**: +- **ネットワーク制限環境**:Google、OpenAIなどのサービスに直接アクセスできないネットワーク環境で使用 +- **ハイブリッド設定**:一部のプロバイダーは統一プロキシを使用し、他はプロバイダー独自のプロキシ済みエンドポイントを使用 +- **柔軟な切り替え**:Web UIでいつでも特定のプロバイダーのプロキシを有効化/無効化できます + +**注意事項**: +- プロキシ設定の優先順位:統一プロキシ設定 > プロバイダー独自エンドポイント > 直接接続 +- プロキシサービスが安定して利用可能であることを確認してください。そうでない場合、サービス品質に影響する可能性があります +- SOCKS5プロキシは通常、HTTPプロキシよりもパフォーマンスが優れています + +##### 2. モデルフィルタリング設定 `notSupportedModels` 設定を通じてサポートされていないモデルを除外でき、システムは自動的にこれらのプロバイダーをスキップします。 @@ -250,7 +306,7 @@ Web UI管理インターフェースでは、極めて迅速に認証設定を - 一部のアカウントは割り当てまたは権限の制限により特定のモデルにアクセスできない - 異なるアカウントに異なるモデルアクセス権限を割り当てる必要がある -##### 2. クロスタイプフォールバック設定 +##### 3. クロスタイプフォールバック設定 あるProvider Type(例:`gemini-cli-oauth`)のすべてのアカウントが429割り当て制限により枯渇したり、unhealthyとマークされた場合、システムは直接エラーを返すのではなく、互換性のある別のProvider Type(例:`gemini-antigravity`)に自動的にフォールバックできます。 diff --git a/README-ZH.md b/README-ZH.md index 53d2b1c..75e8939 100644 --- a/README-ZH.md +++ b/README-ZH.md @@ -31,6 +31,8 @@ > > **📅 版本更新日志** > +> - **2026.01.03** - 新增主题切换功能并优化提供商池初始化,移除使用提供商默认配置的降级策略 +> - **2025.12.30** - 添加主进程管理和自动更新功能 > - **2025.12.25** - 配置文件统一管理:所有配置集中到 `configs/` 目录,Docker 用户需更新挂载路径为 `-v "本地路径:/app/configs"` > - **2025.12.11** - Docker 镜像自动构建并发布到 Docker Hub: [justlikemaki/aiclient-2-api](https://hub.docker.com/r/justlikemaki/aiclient-2-api) > - **2025.11.30** - 新增 Antigravity 协议支持,支持通过 Google 内部接口访问 Gemini 3 Pro、Claude Sonnet 4.5 等模型 @@ -223,7 +225,61 @@ docker run -d -p 3000:3000 -p 8085:8085 -p 8086:8086 -p 19876-19880:19876-19880 #### 高级配置 -##### 1. 模型过滤配置 +##### 3. 代理配置 + +本项目支持灵活的代理配置,可以为不同的提供商配置统一代理或使用提供商自带的已代理端点。 + +**配置方式**: + +1. **Web UI 配置**(推荐):便捷的配置管理 + + 在 Web UI 的"配置管理"页面中,可以可视化配置所有代理选项: + - **统一代理**:在"代理设置"区域填入代理地址,勾选需要使用代理的提供商 + - **提供商端点**:在各提供商配置区域,直接修改 Base URL 为已代理的端点 + - **点击"保存配置"**:即可生效,无需重启服务 + +2. **统一代理配置**:配置全局代理,并指定哪些提供商使用该代理 + + - **Web UI 配置**:在"配置管理"页面的"代理设置"区域填入代理地址,勾选需要使用代理的提供商 + - **配置文件**:在 `configs/config.json` 中配置 + ```json + { + "PROXY_URL": "http://127.0.0.1:7890", + "PROXY_ENABLED_PROVIDERS": [ + "gemini-cli-oauth", + "gemini-antigravity", + "claude-kiro-oauth" + ] + } + ``` + +3. **提供商自带代理端点**:某些提供商(如 OpenAI、Claude)支持配置已代理的 API 端点 + + - **Web UI 配置**:在"配置管理"页面的各提供商配置区域,修改对应的 Base URL + - **配置文件**:在 `configs/config.json` 中配置 + ```json + { + "OPENAI_BASE_URL": "https://your-proxy-endpoint.com/v1", + "CLAUDE_BASE_URL": "https://your-proxy-endpoint.com" + } + ``` + +**代理类型支持**: +- **HTTP 代理**:`http://127.0.0.1:7890` +- **HTTPS 代理**:`https://127.0.0.1:7890` +- **SOCKS5 代理**:`socks5://127.0.0.1:1080` + +**使用场景**: +- **网络受限环境**:在无法直接访问 Google、OpenAI 等服务的网络环境中使用 +- **混合配置**:部分提供商使用统一代理,部分使用自带的已代理端点 +- **灵活切换**:可以随时在 Web UI 中启用/禁用特定提供商的代理 + +**注意事项**: +- 代理配置优先级:统一代理配置 > 提供商自带端点 > 直接连接 +- 确保代理服务稳定可用,否则可能影响服务质量 +- SOCKS5 代理通常比 HTTP 代理性能更好 + +##### 2. 模型过滤配置 支持通过 `notSupportedModels` 配置排除不支持的模型,系统会自动跳过这些提供商。 @@ -249,7 +305,7 @@ docker run -d -p 3000:3000 -p 8085:8085 -p 8086:8086 -p 19876-19880:19876-19880 - 某些账号因配额或权限限制无法访问特定模型 - 需要为不同账号分配不同的模型访问权限 -##### 2. 跨类型 Fallback 配置 +##### 3. 跨类型 Fallback 配置 当某一 Provider Type(如 `gemini-cli-oauth`)下的所有账号都因 429 配额耗尽或被标记为 unhealthy 时,系统能够自动 fallback 到另一个兼容的 Provider Type(如 `gemini-antigravity`),而不是直接返回错误。 diff --git a/README.md b/README.md index 9ebdea7..7c9813e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ > > **📅 Version Update Log** > +> - **2026.01.03** - Added theme switching functionality and optimized provider pool initialization, removed the fallback strategy of using provider default configuration +> - **2025.12.30** - Added main process management and automatic update functionality > - **2025.12.25** - Unified configuration management: All configs centralized to `configs/` directory. Docker users need to update mount path to `-v "local_path:/app/configs"` > - **2025.12.11** - Automatically built Docker images are now available on Docker Hub: [justlikemaki/aiclient-2-api](https://hub.docker.com/r/justlikemaki/aiclient-2-api) > - **2025.11.30** - Added Antigravity protocol support, enabling access to Gemini 3 Pro, Claude Sonnet 4.5, and other models via Google internal interfaces @@ -224,7 +226,61 @@ In the Web UI management interface, you can complete authorization configuration #### Advanced Configuration -##### 1. Model Filtering Configuration +##### 1. Proxy Configuration + +This project supports flexible proxy configuration, allowing you to configure a unified proxy for different providers or use provider-specific proxied endpoints. + +**Configuration Methods**: + +1. **Web UI Configuration** (Recommended): Convenient configuration management + + In the "Configuration" page of the Web UI, you can visually configure all proxy options: + - **Unified Proxy**: Fill in the proxy address in the "Proxy Settings" area and check the providers that need to use the proxy + - **Provider Endpoints**: In each provider's configuration area, directly modify the Base URL to a proxied endpoint + - **Click "Save Configuration"**: Takes effect immediately without restarting the service + +2. **Unified Proxy Configuration**: Configure a global proxy and specify which providers use it + + - **Web UI Configuration**: Fill in the proxy address in the "Proxy Settings" area of the "Configuration" page and check the providers that need to use the proxy + - **Configuration File**: Configure in `configs/config.json` + ```json + { + "PROXY_URL": "http://127.0.0.1:7890", + "PROXY_ENABLED_PROVIDERS": [ + "gemini-cli-oauth", + "gemini-antigravity", + "claude-kiro-oauth" + ] + } + ``` + +3. **Provider-Specific Proxied Endpoints**: Some providers (like OpenAI, Claude) support configuring proxied API endpoints + + - **Web UI Configuration**: In each provider's configuration area on the "Configuration" page, modify the corresponding Base URL + - **Configuration File**: Configure in `configs/config.json` + ```json + { + "OPENAI_BASE_URL": "https://your-proxy-endpoint.com/v1", + "CLAUDE_BASE_URL": "https://your-proxy-endpoint.com" + } + ``` + +**Supported Proxy Types**: +- **HTTP Proxy**: `http://127.0.0.1:7890` +- **HTTPS Proxy**: `https://127.0.0.1:7890` +- **SOCKS5 Proxy**: `socks5://127.0.0.1:1080` + +**Use Cases**: +- **Network-Restricted Environments**: Use in network environments where Google, OpenAI, and other services cannot be accessed directly +- **Hybrid Configuration**: Some providers use unified proxy, others use their own proxied endpoints +- **Flexible Switching**: Enable/disable proxy for specific providers at any time in the Web UI + +**Notes**: +- Proxy configuration priority: Unified proxy configuration > Provider-specific endpoints > Direct connection +- Ensure the proxy service is stable and available, otherwise it may affect service quality +- SOCKS5 proxy usually performs better than HTTP proxy + +##### 2. Model Filtering Configuration Support excluding unsupported models through `notSupportedModels` configuration, the system will automatically skip these providers. @@ -250,7 +306,7 @@ Support excluding unsupported models through `notSupportedModels` configuration, - Some accounts cannot access specific models due to quota or permission restrictions - Need to assign different model access permissions to different accounts -##### 2. Cross-Type Fallback Configuration +##### 3. Cross-Type Fallback Configuration When all accounts under a Provider Type (e.g., `gemini-cli-oauth`) are exhausted due to 429 quota limits or marked as unhealthy, the system can automatically fallback to another compatible Provider Type (e.g., `gemini-antigravity`) instead of returning an error directly. diff --git a/configs/config.json.example b/configs/config.json.example index 6c3d8f7..80c7843 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -18,5 +18,10 @@ "gemini-antigravity": ["gemini-cli-oauth"], "claude-kiro-oauth": ["claude-custom"], "claude-custom": ["claude-kiro-oauth"] - } + }, + "PROXY_URL": "http://127.0.0.1:1089", + "PROXY_ENABLED_PROVIDERS": [ + "gemini-cli-oauth", + "gemini-antigravity" + ] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c0f4b57..3d678ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "AIClient-2-API", + "name": "AIClient2API", "lockfileVersion": 3, "requires": true, "packages": { @@ -100,7 +100,6 @@ "integrity": "sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.27.1", @@ -2959,7 +2958,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001726", "electron-to-chromium": "^1.5.173", diff --git a/static/index.html b/static/index.html index 654afbc..7547ba1 100644 --- a/static/index.html +++ b/static/index.html @@ -594,28 +594,28 @@
-
-