From b1853a076019968681518d1fd352fbd840a109be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E5=BA=86=E9=9B=B7?= Date: Wed, 19 Nov 2025 17:56:43 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=BC=98=E5=8C=96Gemini=20CLI=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 21 ++++++++++++++++++-- README_EN.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 95a47a55..80c6f0a5 100644 --- a/README.md +++ b/README.md @@ -410,10 +410,27 @@ export ANTHROPIC_AUTH_TOKEN="后台创建的API密钥" **Gemini CLI 设置环境变量:** +**方式一(推荐):通过 Gemini Assist API 方式访问** + +每账号每日享受 1000 次请求,每分钟 60 次免费限额。 + ```bash +CODE_ASSIST_ENDPOINT="http://127.0.0.1:3000/gemini" # 根据实际填写你服务器的ip地址或者域名 +GOOGLE_CLOUD_ACCESS_TOKEN="后台创建的API密钥" +GOOGLE_GENAI_USE_GCA="true" +GEMINI_MODEL="gemini-2.5-pro" +``` + +> **注意**:gemini-cli 控制台会提示 `Failed to fetch user info: 401 Unauthorized`,但使用不受任何影响。 + +**方式二:通过 Gemini API 方式访问** + +免费额度极少,极易触发 429 错误。 + +```bash +GOOGLE_GEMINI_BASE_URL="http://127.0.0.1:3000/gemini" # 根据实际填写你服务器的ip地址或者域名 +GEMINI_API_KEY="后台创建的API密钥" GEMINI_MODEL="gemini-2.5-pro" -GOOGLE_GEMINI_BASE_URL="http://127.0.0.1:3000/gemini" # 根据实际填写你服务器的ip地址或者域名 -GEMINI_API_KEY="后台创建的API密钥" # 使用相同的API密钥即可 ``` **使用 Claude Code:** diff --git a/README_EN.md b/README_EN.md index 6573021b..477c2f52 100644 --- a/README_EN.md +++ b/README_EN.md @@ -232,21 +232,68 @@ Assign a key to each user: 4. Set usage limits (optional) 5. Save, note down the generated key -### 4. Start Using Claude Code +### 4. Start Using Claude Code and Gemini CLI Now you can replace the official API with your own service: -**Set environment variables:** +**Claude Code Set Environment Variables:** + +Default uses standard Claude account pool: + ```bash -export ANTHROPIC_BASE_URL="http://127.0.0.1:3000/api/" # Fill in your server's IP address or domain according to actual situation +export ANTHROPIC_BASE_URL="http://127.0.0.1:3000/api/" # Fill in your server's IP address or domain export ANTHROPIC_AUTH_TOKEN="API key created in the backend" ``` -**Use claude:** +**VSCode Claude Plugin Configuration:** + +If using VSCode Claude plugin, configure in `~/.claude/config.json`: + +```json +{ + "primaryApiKey": "crs" +} +``` + +If the file doesn't exist, create it manually. Windows users path is `C:\Users\YourUsername\.claude\config.json`. + +**Gemini CLI Set Environment Variables:** + +**Method 1 (Recommended): Via Gemini Assist API** + +Each account enjoys 1000 requests per day, 60 requests per minute free quota. + +```bash +CODE_ASSIST_ENDPOINT="http://127.0.0.1:3000/gemini" # Fill in your server's IP address or domain +GOOGLE_CLOUD_ACCESS_TOKEN="API key created in the backend" +GOOGLE_GENAI_USE_GCA="true" +GEMINI_MODEL="gemini-2.5-pro" +``` + +> **Note**: gemini-cli console will show `Failed to fetch user info: 401 Unauthorized`, but this doesn't affect usage. + +**Method 2: Via Gemini API** + +Very limited free quota, easily triggers 429 errors. + +```bash +GOOGLE_GEMINI_BASE_URL="http://127.0.0.1:3000/gemini" # Fill in your server's IP address or domain +GEMINI_API_KEY="API key created in the backend" +GEMINI_MODEL="gemini-2.5-pro" +``` + +**Use Claude Code:** + ```bash claude ``` +**Use Gemini CLI:** + +```bash +gemini +``` + --- ## 🔧 Daily Maintenance