Merge pull request #680 from zengqinglei/docs/gemini-cli-configuration

docs: 优化Gemini CLI配置说明
This commit is contained in:
Wesley Liddick
2025-11-20 00:49:52 -05:00
committed by GitHub
4 changed files with 73 additions and 8 deletions

View File

@@ -410,10 +410,27 @@ export ANTHROPIC_AUTH_TOKEN="后台创建的API密钥"
**Gemini CLI 设置环境变量:** **Gemini CLI 设置环境变量:**
**方式一(推荐):通过 Gemini Assist API 方式访问**
每账号每日享受 1000 次请求,每分钟 60 次免费限额。
```bash ```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_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地址或者域名 GOOGLE_GEMINI_BASE_URL="http://127.0.0.1:3000/gemini" # 根据实际填写你服务器的ip地址或者域名
GEMINI_API_KEY="后台创建的API密钥" # 使用相同的API密钥即可 GEMINI_API_KEY="后台创建的API密钥"
GEMINI_MODEL="gemini-2.5-pro"
``` ```
**使用 Claude Code** **使用 Claude Code**

View File

@@ -232,21 +232,68 @@ Assign a key to each user:
4. Set usage limits (optional) 4. Set usage limits (optional)
5. Save, note down the generated key 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: 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 ```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" 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 ```bash
claude claude
``` ```
**Use Gemini CLI:**
```bash
gemini
```
--- ---
## 🔧 Daily Maintenance ## 🔧 Daily Maintenance

View File

@@ -1 +1 @@
1.1.195 1.1.197

View File

@@ -260,7 +260,8 @@ const handleResponses = async (req, res) => {
// 判断是否为 Codex CLI 的请求 // 判断是否为 Codex CLI 的请求
const isCodexCLI = const isCodexCLI =
req.body?.instructions?.startsWith('You are a coding agent running in the Codex CLI') || req.body?.instructions?.startsWith('You are a coding agent running in the Codex CLI') ||
req.body?.instructions?.startsWith('You are Codex') req.body?.instructions?.startsWith('You are Codex') ||
req.body?.instructions?.startsWith('You are GPT-5.1 running in the Codex CLI')
// 如果不是 Codex CLI 请求,则进行适配 // 如果不是 Codex CLI 请求,则进行适配
if (!isCodexCLI) { if (!isCodexCLI) {