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

# Gemini CLI

> Connect Gemini CLI to DreamTo with GOOGLE_GEMINI_BASE_URL and GEMINI_API_KEY.

[Gemini CLI](https://github.com/google-gemini/gemini-cli) is Google's open-source command-line AI assistant. It uses Gemini's native generateContent protocol and lets you override the API address with the `GOOGLE_GEMINI_BASE_URL` environment variable. DreamTo supports this protocol natively.

## Prerequisites

* A recent version of Gemini CLI is installed (`gemini --version`), for example via `npm i -g @google/gemini-cli`. `GOOGLE_GEMINI_BASE_URL` requires a recent version; if yours doesn't recognize it, upgrade first.
* You have created an API Key on the **API Keys** page of the [DreamTo console](https://www.dreamto.ai/console).
* You have a Gemini model ID, such as `gemini-4-hydrogen`. For the full list, see [Gemini generateContent](https://docs.dreamto.ai/en/llm/gemini-generate-content.md).

## Key settings

| Environment variable | Value | Notes |
| - | - | - |
| `GOOGLE_GEMINI_BASE_URL` | `https://api.dreamto.ai` | Domain only, no `/v1beta`; the CLI appends `/v1beta/models/{model}:generateContent` |
| `GEMINI_API_KEY` | Your DreamTo API Key | Sent in the `x-goog-api-key` header by default, which DreamTo supports |
| `GEMINI_MODEL` | e.g. `gemini-4-hydrogen` | Default model; override per run with `-m` |

## Setup

**1. Set the environment variables**

We recommend putting them in `~/.gemini/.env`, which Gemini CLI loads automatically (`%USERPROFILE%\.gemini\.env` on Windows):

```bash ~/.gemini/.env theme={null}
GOOGLE_GEMINI_BASE_URL=https://api.dreamto.ai
GEMINI_API_KEY=sk-xxxx
GEMINI_MODEL=gemini-4-hydrogen
```

You can also set them directly in your shell:

```bash macOS / Linux theme={null}
export GOOGLE_GEMINI_BASE_URL="https://api.dreamto.ai"
export GEMINI_API_KEY="sk-xxxx"
export GEMINI_MODEL="gemini-4-hydrogen"
```

```powershell Windows PowerShell theme={null}
$env:GOOGLE_GEMINI_BASE_URL = "https://api.dreamto.ai"
$env:GEMINI_API_KEY = "sk-xxxx"
$env:GEMINI_MODEL = "gemini-4-hydrogen"
```

**2. Choose API Key authentication**

Start `gemini`. If asked to choose an authentication method, pick **Use Gemini API Key**, not Google sign-in or Vertex AI. If you previously signed in with a Google account, type `/auth` in the CLI to choose again.

**3. Verify**

```bash theme={null}
gemini -p "Introduce yourself in one sentence"
```

A normal response means the setup works. In interactive mode, type `/model` to confirm the current model.

## FAQ

> [accordion] 401 / API key not valid
>
> * Make sure you're using API Key authentication, not Google sign-in (use `/auth` to choose again).
> * Check whether variables such as `GOOGLE_API_KEY` or `GOOGLE_GENAI_USE_VERTEXAI=true` are still set in your shell and interfering; `unset` them if needed.

> [accordion] 404 / model not found
>
> * Set `GOOGLE_GEMINI_BASE_URL` to just `https://api.dreamto.ai`. Adding `/v1beta` results in `/v1beta/v1beta/...`.
> * The model ID must be a Gemini model ID from the DreamTo Model Marketplace. Gemini CLI's built-in default model may not exist on DreamTo, so set `GEMINI_MODEL` explicitly.

> [accordion] Warning that the Base URL is insecure
>
> Gemini CLI requires custom addresses to use HTTPS (except localhost). Make sure the address starts with `https://`.

> [accordion] Streaming breaks
>
> Gemini CLI uses `streamGenerateContent`, which DreamTo supports. If the stream drops midway, first check whether a local proxy or corporate gateway is buffering the SSE response.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.