Skip to main content

Gemini CLI

Connect Google’s Gemini CLI to ShuYou and call Gemini models through ShuYou’s Google-compatible endpoint.

Prerequisites

  1. Install Node.js LTS (v20+).
  2. Create a ShuYou API key in the console.
ShuYou Gemini / Vertex-compatible base URL: https://api.shuyou.ai
Gemini CLI requires patching the installed @google/genai package to change the default Google endpoint. Back up files before editing, or prefer Claude Code or Codex CLI for simpler setup.

Step 1: Install Gemini CLI

npm install -g @google/gemini-cli
gemini --version

Step 2: Point API to ShuYou

Find the global npm modules path:
npm root -g
In {npm_root}/@google/gemini-cli/node_modules/@google/genai/dist/node/, edit index.mjs and index.cjs. Locate the default base URL assignment:
// Before
initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;

// After
initHttpOptions.baseUrl = `https://api.shuyou.ai/`;
Set your API key:
export GEMINI_API_KEY="YOUR_SHUYOU_API_KEY"

Step 3: Verify

gemini "Who are you?"
In interactive mode, use /model to switch models. Pick slugs supported on ShuYou models for the Google / Vertex protocol.

FAQ

401 / 403: Verify GEMINI_API_KEY and that both index.mjs and index.cjs were updated. Updates break config: Re-apply the base URL patch after upgrading @google/gemini-cli.
Run Gemini CLI in a dedicated project folder only.