Agent Tools

Gemini CLI

Connect Gemini CLI to Yolo Router and run it with a selected model.

iBefore you start, make sure you have:
  • Gemini CLI installed and available as gemini.
  • A working Yolo Router endpoint, for example https://api.yolorouter.com.
  • A Yolo Router API Key generated from the console.
  • The model ID you want to use, for example gemini-3.5-flash. It must exactly match the model ID in the Yolo Router console.

Setup

Check Gemini CLI

Run:

gemini --version

If it is not installed, install Gemini CLI using the official instructions before continuing.

Gemini CLI uses JSON settings files for persistent configuration. The user-level settings file is:

~/.gemini/settings.json

On Windows, this is usually:

%USERPROFILE%\.gemini\settings.json

You can also create project-level settings in the project root:

.gemini/settings.json

Add or merge this configuration:

{
  "$schema": "https://raw.githubusercontent.com/google-gemini/gemini-cli/main/schemas/settings.schema.json",
  "model": {
    "name": "gemini-3.5-flash"
  },
  "security": {
    "auth": {
      "selectedType": "gemini-api-key",
      "enforcedType": "gemini-api-key"
    }
  }
}

Fields:

  • model.name: the default model ID for Gemini CLI; it must exactly match the model ID in the Yolo Router console
  • security.auth.selectedType: selects Gemini API Key authentication
  • security.auth.enforcedType: keeps this configuration on Gemini API Key auth and avoids switching back to OAuth / Code Assist by mistake

Write the key and Yolo Router endpoint

Gemini CLI automatically loads .env files. For persistent use, write the Yolo Router key and endpoint to ~/.gemini/.env.

User-level .env path:

~/.gemini/.env

On Windows, this is usually:

%USERPROFILE%\.gemini\.env

Write:

GEMINI_API_KEY=sk-yolo-...
GOOGLE_GEMINI_BASE_URL=https://api.yolorouter.com
GEMINI_MODEL=gemini-3.5-flash

Variables:

  • GEMINI_API_KEY: your Yolo Router API Key
  • GOOGLE_GEMINI_BASE_URL: the Yolo Router root endpoint; do not append /v1 or /v1beta
  • GEMINI_MODEL: the default model ID. You can also configure the model only through model.name in settings.json

Do not commit .env files that contain real API keys.

Optional: use environment variables only

Gemini CLI reads GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL, and GEMINI_MODEL. A typical Yolo Router setup looks like this:

export GEMINI_API_KEY="sk-yolo-..."
export GOOGLE_GEMINI_BASE_URL="https://api.yolorouter.com"
export GEMINI_MODEL="gemini-3.5-flash"
$env:GEMINI_API_KEY = "sk-yolo-..."
$env:GOOGLE_GEMINI_BASE_URL = "https://api.yolorouter.com"
$env:GEMINI_MODEL = "gemini-3.5-flash"
set GEMINI_API_KEY=sk-yolo-...
set GOOGLE_GEMINI_BASE_URL=https://api.yolorouter.com
set GEMINI_MODEL=gemini-3.5-flash

If you do not want to write files, you can set these variables only for the current terminal session:

  • GEMINI_API_KEY: your Yolo Router API Key
  • GOOGLE_GEMINI_BASE_URL: the Yolo Router root endpoint; do not append /v1 or /v1beta
  • GEMINI_MODEL: the default model ID for Gemini CLI; it must exactly match the model ID in the Yolo Router console

Switch to API Key authentication

If you previously used Google OAuth or Code Assist, select API Key authentication again inside Gemini CLI:

gemini

Then run:

/auth

Select Gemini API Key. If GEMINI_API_KEY is set in the current terminal, Gemini CLI uses that key for requests.

Test the connection

Use print mode for a quick request:

gemini -p "Introduce the model you are using in one sentence"

Or start interactive mode:

gemini

Then send:

Introduce the model you are using in one sentence.

If Gemini CLI returns a normal response, the integration is working. You can also check the request log in the Yolo Router console.

Optional: verify the key and model list first

If you are not sure whether the endpoint, key, or model ID is valid, check the model list first:

curl https://api.yolorouter.com/v1/models \
  -H "Authorization: Bearer $GEMINI_API_KEY"
curl.exe https://api.yolorouter.com/v1/models `
  -H "Authorization: Bearer $env:GEMINI_API_KEY"

If the model list is returned, confirm that the value in GEMINI_MODEL exists.

Troubleshooting

401 or authentication failed

Check that GEMINI_API_KEY is your Yolo Router API Key and that it has no extra spaces. Do not include a Bearer prefix.

Requests still go to Google's official service

Check that the current terminal can read GOOGLE_GEMINI_BASE_URL, and that Gemini CLI is using Gemini API Key authentication. Restart Gemini CLI after changing environment variables.

404 or incompatible endpoint

Check that GOOGLE_GEMINI_BASE_URL is the root endpoint https://api.yolorouter.com, not https://api.yolorouter.com/v1 or https://api.yolorouter.com/v1beta. Gemini CLI appends the native Gemini API paths itself.

Model not found

Check that GEMINI_MODEL exactly matches the model ID in the Yolo Router console. Use the model ID, not a display name, alias, or value with extra spaces.

Changes to config files did not take effect

Gemini CLI reads settings.json and .env on startup. After changing either file, close the current Gemini CLI session and start it again.

On this page