Gemini CLI
将 Google 官方 Gemini CLI 接入 ShuYou,通过 ShuYou 的 Google 兼容端点调用 Gemini 模型。
使用前准备
- 安装 Node.js LTS(建议 v20+)。
- 在 ShuYou 控制台 创建 API Key。
ShuYou Gemini / Vertex 兼容 Base URL:https://api.shuyou.ai
第一步:安装 Gemini CLI
npm install -g @google/gemini-cli
gemini --version
第二步:将 API 指向 ShuYou
查看全局 npm 模块路径:
在 {npm_root}/@google/gemini-cli/node_modules/@google/genai/dist/node/ 下,分别编辑 index.mjs 与 index.cjs,找到默认 Base URL:
// 修改前
initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;
// 修改后
initHttpOptions.baseUrl = `https://api.shuyou.ai/`;
设置 API Key:
export GEMINI_API_KEY="你的 ShuYou API Key"
$env:GEMINI_API_KEY = "你的 ShuYou API Key"
第三步:验证
交互模式输入 /model 切换模型,请从 ShuYou 模型列表 选择 Google / Vertex 协议支持的 slug。
常见问题
401 / 403: 检查 GEMINI_API_KEY,并确认 index.mjs 与 index.cjs 均已修改。
升级后失效: 更新 @google/gemini-cli 后需重新打补丁。
建议在专门的项目目录中使用 Gemini CLI。