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

# Configure Google Gemini CLI to Use KiosAPI Gateway

> Set up the Google Gemini CLI to use KiosAPI as the backend provider, routing Gemini model requests through KiosAPI's unified API gateway.

Google's Gemini CLI is the official command-line interface for interacting with Gemini models. This tutorial walks you through installing Gemini CLI, configuring it to point at KiosAPI, and verifying that your setup works — so you can use Gemini models through KiosAPI's unified gateway.

## Prerequisites

* **Node.js 18+** — verify with `node --version`
* A **KiosAPI API key** (starts with `sk-`) from the [Dashboard](https://kiosapi.com) → **Token Management**

<Steps>
  ### Install Gemini CLI

  Install the Gemini CLI globally via npm:

  ```bash theme={null}
  npm install -g @google/gemini-cli
  ```

  Verify the installation:

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

  ### Get your KiosAPI key

  1. Log in to the [KiosAPI Dashboard](https://kiosapi.com)
  2. Navigate to **Token Management**
  3. Create or copy an existing API key (starts with `sk-`)

  ### Set the base URL

  Create `~/.gemini/.env` and set the base URL:

  ```bash theme={null}
  GOOGLE_GEMINI_BASE_URL=https://kiosapi.com/
  ```

  <Info>
    The base URL must end with a trailing slash `/`. Gemini CLI appends the API path after it.
  </Info>

  ### Configure settings

  Create `~/.gemini/settings.json` with your authentication method, default model, and model definitions:

  ```json theme={null}
  {
    "auth": {
      "selectedType": "api-key"
    },
    "model": "gemini-2.5-pro",
    "models": {
      "gemini-2.5-pro": {
        "name": "Gemini 2.5 Pro",
        "base_url": "https://kiosapi.com/"
      },
      "gemini-2.5-flash": {
        "name": "Gemini 2.5 Flash",
        "base_url": "https://kiosapi.com/"
      },
      "gemini-2.5-flash-lite": {
        "name": "Gemini 2.5 Flash Lite",
        "base_url": "https://kiosapi.com/"
      }
    }
  }
  ```

  | Setting             | Description                                          |
  | ------------------- | ---------------------------------------------------- |
  | `auth.selectedType` | Authentication method — set to `api-key` for KiosAPI |
  | `model`             | Default model to use                                 |
  | `models`            | Model definitions with display names and base URLs   |

  ### Launch and authenticate

  Run Gemini CLI for the first time:

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

  On first launch, Gemini CLI will prompt you to select an authentication method:

  1. Select **API Key**
  2. Enter your KiosAPI key (`sk-xxx`)
  3. Press Enter to confirm

  <Warning>
    Do **not** select "Google Login" — this will attempt to authenticate with Google's servers directly and will not work with KiosAPI. Always choose **API Key**.
  </Warning>

  ### Verify your setup

  Run a quick test to confirm everything is connected:

  ```bash theme={null}
  gemini "Say hello"
  ```

  If Gemini responds, your configuration is working correctly.
</Steps>

## Usage

<CodeGroup>
  ```bash Interactive mode theme={null}
  gemini
  ```

  ```bash Direct question theme={null}
  gemini "What is the capital of France?"
  ```

  ```bash With a file context theme={null}
  gemini "Explain this code" < main.py
  ```
</CodeGroup>

## Switching Models

Change the default model in `~/.gemini/settings.json`:

```json theme={null}
{
  "model": "gemini-2.5-flash"
}
```

Or specify a model for a single session:

```bash theme={null}
gemini --model gemini-2.5-flash "Summarize this article"
```

## Available Models

| Model ID                | Description                                     |
| ----------------------- | ----------------------------------------------- |
| `gemini-2.5-pro`        | Most capable Gemini model for complex reasoning |
| `gemini-2.5-flash`      | Fast and cost-effective for everyday tasks      |
| `gemini-2.5-flash-lite` | Ultra-fast lightweight model                    |

<Tip>
  Check the [KiosAPI pricing page](https://kiosapi.com/pricing) for the full list of available Gemini models and their costs.
</Tip>

## Troubleshooting

### Authentication failed

* Ensure you selected **API Key** (not Google Login) during setup
* Verify your API key is correct and starts with `sk-`
* Re-run `gemini` and re-select the auth method if needed

### Connection error

* Check that `GOOGLE_GEMINI_BASE_URL` in `~/.gemini/.env` is `https://kiosapi.com/` — with a trailing slash
* Ensure `base_url` in `settings.json` also includes the trailing slash
* Verify your network connection

### Model not found

* Check the model ID matches exactly (e.g., `gemini-2.5-pro`, not `gemini-pro`)
* Confirm the model is available on KiosAPI by checking the [models list](../api-reference/models/list-models)

## Need Help?

* [KiosAPI Dashboard](https://kiosapi.com)
* [Token Management Guide](/token-management/quota)
* [Available Models](../api-reference/models/list-models)
