> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crazyrouter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini CLI Setup Guide

> Configure Gemini CLI for Crazyrouter using the auth and model settings verified by real requests

> Дата обновления: 2026-06-06

## Overview

Gemini CLI is Google's command-line AI assistant. By configuring Crazyrouter's Gemini-native endpoint, you can use Gemini models that have been verified with real requests in Crazyrouter production.

## Configuration

### Environment Variables

In the current Gemini CLI release, API-key mode still requires `GEMINI_API_KEY` to be present explicitly. For Crazyrouter's Gemini-native endpoint, set these three variables together:

```bash theme={null}
export GEMINI_API_KEY=sk-xxx
export GEMINI_MODEL=gemini-3.1-pro
export GOOGLE_GEMINI_BASE_URL=https://api.crazyrouter.com
```

PowerShell:

```powershell theme={null}
$env:GEMINI_API_KEY="sk-xxx"
$env:GEMINI_MODEL="gemini-3.1-pro"
$env:GOOGLE_GEMINI_BASE_URL="https://api.crazyrouter.com"
```

If you want this to persist across sessions, put the same values into `~/.gemini/.env` or your PowerShell profile.

### Configuration File

Edit `~/.gemini/settings.json`:

```json theme={null}
{
  "security": {
    "auth": {
      "selectedType": "gemini-api-key"
    }
  },
  "apiKey": "sk-xxx",
  "baseUrl": "https://api.crazyrouter.com",
  "model": {
    "name": "gemini-3.1-pro"
  }
}
```

Notes:

* Do not leave the auth mode as `oauth-personal`, or the CLI will continue trying Google sign-in.
* Do not write `model` as a plain string in current versions; use `model.name`.
* In some CLI paths, `settings.json` alone is not enough. Headless mode may still require the `GEMINI_API_KEY` environment variable.

### `~/.gemini/.env` Example

```bash theme={null}
GEMINI_API_KEY=sk-xxx
GEMINI_MODEL=gemini-3.1-pro
GOOGLE_GEMINI_BASE_URL=https://api.crazyrouter.com
```

### Launch

```bash theme={null}
gemini
```

## Recommended Model

| Model            | Description                                                                                                                              |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `gemini-3.1-pro` | Verified successfully with a real Gemini CLI request in Crazyrouter production on April 8, 2026, and recommended as the current baseline |

<Note>
  Crazyrouter supports both the Gemini native API format and the OpenAI-compatible format. Gemini CLI uses the Gemini-native format. The `gemini-3.1-pro` example above, the `gemini-api-key` auth mode, and `GOOGLE_GEMINI_BASE_URL=https://api.crazyrouter.com` have been validated with a real CLI request.
</Note>
