AI Gateway is now available: identity-aware access to any AI provider, eliminate API keys, and tunnel to self-hosted models. Get started

AI GatewayConfigure AI Clients and Agents

Gemini CLI

Connect Gemini CLI to a Pangolin AI Gateway resource

Gemini CLI talks Google's native generateContent API, so the resource you point it at needs a Google Gemini (or Vertex AI) provider attached. See AI Gateway Overview if you haven't set that up yet.

You'll need the resource's URL (its <endpoint>) and its API key (<key>). Both are on the resource's Keys page.

Public vs. private resources

Wherever these instructions show <key>, what you put there depends on the resource type:

  • Public resource - reachable from anywhere, so the gateway checks a virtual API key. Copy it from the resource URL after login, the Resource Launcher more-info panel, or https://app.pangolin.net/<org-id>/keys (use your self-hosted dashboard URL in place of app.pangolin.net if you self-host).
  • Private resource - only reachable from devices connected to your Pangolin network, so no key is checked. You must have the Pangolin client installed and connected. Use the literal string none as the key.

Don't delete the key field for private resources. Most clients refuse to start without some key set, so they need an inert placeholder rather than a missing one.

Fastest: Pangolin CLI

Install the Pangolin CLI if you don't have it, then log in:

pangolin login

Configure Gemini CLI against a resource:

pangolin configure gemini

This prompts you to pick an organization and resource if you have more than one, fetches a key for you if the resource needs one, and writes ~/.gemini/.env - the file Gemini CLI loads automatically on every run, regardless of which directory you start it from. To skip the prompts:

pangolin configure gemini --resource <resource-niceid-or-domain>

To undo it:

pangolin configure gemini --reset

Manual setup

Write ~/.gemini/.env:

GOOGLE_GEMINI_BASE_URL=<endpoint>
GEMINI_API_KEY=<key>

Gemini CLI also checks a project-local .env first (in the current directory or a parent, up to .git or your home directory) before falling back to ~/.gemini/.env, so a project-level file with the same two lines overrides this for just that project.

Or, for a one-off shell session instead of a permanent file:

export GOOGLE_GEMINI_BASE_URL=<endpoint>
export GEMINI_API_KEY=<key>
gemini

For a private resource, keep GEMINI_API_KEY in place and set it to none. Gemini CLI won't start without it set to something.

Was this page helpful?

⌘I

On this page