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

# Use Gemini CLI with RunBridge AI

> Use Gemini CLI gateway mode with the RunBridge AI Gemini-compatible endpoint.

[Gemini CLI](https://github.com/google-gemini/gemini-cli) can connect through a custom Gemini API gateway. RunBridge AI uses the Gemini-native API for this integration.

## Prerequisites

* Node.js 22 LTS or a newer supported LTS release, and macOS, Linux, or Windows.
* An active API key from the [RunBridge AI console](https://runbridge.ai/console/token).
* A [Gemini text model](/overview/models) available to your key that supports the [Gemini API](/api/text/gemini-generating-content), streaming, and tool calling. Replace `your-gemini-model-id` below with its exact ID.

## Install Gemini CLI

Install the official package and check its version:

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

## Configure the gateway endpoint

Store your RunBridge AI key as `RUNBRIDGE_API_KEY` in your shell or secret manager. Map that value to the environment variables Gemini CLI expects:

<Tabs>
  <Tab title="macOS / Linux">
    ```bash theme={null}
    export GEMINI_API_KEY="$RUNBRIDGE_API_KEY"
    export GOOGLE_GEMINI_BASE_URL="https://api.runbridge.ai"
    unset GOOGLE_GENAI_USE_GCA GOOGLE_GENAI_USE_VERTEXAI
    ```
  </Tab>

  <Tab title="Windows PowerShell">
    ```powershell theme={null}
    $env:GEMINI_API_KEY = $env:RUNBRIDGE_API_KEY
    $env:GOOGLE_GEMINI_BASE_URL = "https://api.runbridge.ai"
    Remove-Item Env:\GOOGLE_GENAI_USE_GCA, Env:\GOOGLE_GENAI_USE_VERTEXAI -ErrorAction SilentlyContinue
    ```
  </Tab>
</Tabs>

`GOOGLE_GEMINI_BASE_URL` points Gemini CLI at the custom gateway. Use the API origin without `/v1` or `/v1beta`; Gemini CLI adds the Gemini API version and model request path. It sends `GEMINI_API_KEY` using `x-goog-api-key`.

The Google-login and Vertex environment switches select different authentication modes, so remove them from this shell when using RunBridge AI.

For the API-key path, merge this setting into `~/.gemini/settings.json`:

```json theme={null}
{
  "security": {
    "auth": {
      "selectedType": "gemini-api-key"
    }
  }
}
```

Keep existing settings in the file. This selects API-key authentication while the custom origin remains active. In an interactive session, `/auth` → **Use Gemini API key** selects the same method.

<Note>
  With Gemini CLI 0.60.0, set the API-key authentication method explicitly when using a custom endpoint. This prevents an `Invalid auth method selected` error in non-interactive mode.
</Note>

<Note>
  To persist the settings, use Gemini CLI's user-level `~/.gemini/.env` file or your secret manager. Store the actual key as `GEMINI_API_KEY` and the origin as `GOOGLE_GEMINI_BASE_URL`; do not assume shell variable expansion inside a dotenv file. Keep credentials outside your project repository.
</Note>

## Verify the connection

First open `gemini --model your-gemini-model-id` in your test project and review its workspace trust prompt. Then run a non-interactive request with an explicit model from that trusted folder:

```bash theme={null}
gemini --model your-gemini-model-id --prompt "Reply with CONNECTED only."
```

This sends a real API request and may incur usage. A response without authentication or endpoint errors confirms basic connectivity. Then launch `gemini --model your-gemini-model-id` in a test project to check a small coding task and tool calling.

## Troubleshooting

| Symptom | Check |
| - | - |
| HTTP 401 or missing API key | Confirm your launch environment contains a nonempty `GEMINI_API_KEY` with the RunBridge AI key. Do not print the key in logs or screenshots. |
| A Google login prompt or `Invalid auth method selected` appears | Set `security.auth.selectedType` to `gemini-api-key`, keep the custom origin, and remove conflicting Google/Vertex authentication settings. |
| HTTP 404 | Set the base URL to `https://api.runbridge.ai` without an API version suffix; select a Gemini-native model. |
| Model not found | Use an exact available RunBridge AI Gemini model ID instead of a CLI alias or an OpenAI model. |
| Token counting or tool calls fail | Confirm the model route supports the Gemini operations and function calling required by the CLI. A successful text request does not establish every capability. |

See the official [authentication guide](https://geminicli.com/docs/get-started/authentication/) and [configuration reference](https://geminicli.com/docs/reference/configuration/) for persistence and authentication details.

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@type": "TechArticle",
    "headline": "Use Gemini CLI with RunBridge AI",
    "description": "Use Gemini CLI gateway mode with the RunBridge AI Gemini-compatible endpoint.",
    "url": "https://runbridge.mintlify.site/integrations/gemini-cli",
    "publisher": {
      "@type": "Organization",
      "name": "RunBridge AI"
    }
    }
    `}
</script>


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