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

# Gemini CLI

> Configure AIOHub for Gemini CLI.

[Gemini CLI](https://github.com/google-gemini/gemini-cli) uses the Gemini API. Set the API key and the gateway root URL before starting Gemini CLI.

## Prerequisites

* Gemini CLI installed, with Node.js 20+ recommended
* An AIOHub `sk-` API key
* A group assigned to the API key that can access Gemini models
* A positive account balance

You can check local versions first:

```bash theme={"system"}
node -v
npm -v
gemini --version
```

## Setup

Set the variables in the shell where you start Gemini CLI:

```bash theme={"system"}
export GEMINI_API_KEY="sk-your-api-key"
export GOOGLE_GEMINI_BASE_URL="https://api.aiohub.org"
gemini
```

### Persist in your shell profile

<Tabs>
  <Tab title="macOS / Linux (zsh)">
    ```bash theme={"system"}
    echo 'export GEMINI_API_KEY="sk-your-api-key"' >> ~/.zshrc
    echo 'export GOOGLE_GEMINI_BASE_URL="https://api.aiohub.org"' >> ~/.zshrc
    source ~/.zshrc
    ```
  </Tab>

  <Tab title="Windows PowerShell">
    ```powershell theme={"system"}
    [System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "sk-your-api-key", "User")
    [System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", "https://api.aiohub.org", "User")
    ```
  </Tab>
</Tabs>

<Note>Gemini CLI appends the API version path itself. Do not set `GOOGLE_GEMINI_BASE_URL` to a URL that already includes `/v1beta`.</Note>

## Verify

```bash theme={"system"}
gemini
```

It is often better to specify a model visible to your API key:

```bash theme={"system"}
gemini -m gemini-2.5-flash
```

A normal response means the setup is working.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Gemini CLI stalls or stops responding">
    Restart the session and confirm that the group assigned to the API key can access Gemini models.
  </Accordion>

  <Accordion title="The request returns 400">
    Clear or restart the session, then confirm that the model exists in the `/v1beta/models` response.
  </Accordion>

  <Accordion title="Project config overrides environment variables">
    Check whether the current directory contains a `.env` file or Gemini CLI config that overrides the API key, model, or Base URL. Remove the conflicting setting, then reopen the terminal.
  </Accordion>
</AccordionGroup>
