Connect Gemini

In short

How to use Google Gemini in Granular: create a Gemini API key in Google AI Studio, add it in the connection menu, then pick from 12 Gemini and Gemma models.

Updated 2026-10-20

Get a free Gemini API key from Google AI Studio, then add it in Granular's connection menu under Add your AI agent → API key → Gemini. Your sessions can then run on Google Gemini and Gemma models.

(An API key is a long password that lets software use a company's AI service. Granular keeps it encrypted and never shows it in chat.)

Before you start

  • Granular installed.

  • A Google account that can open Google AI Studio.

  • Google's Gemini CLI installed. Granular uses Google's own Gemini command-line tool (CLI) behind the scenes. Unlike Claude, it doesn't come built into Granular. It is free but needs Node.js, which you can get from nodejs.org. To install it, ask the agent in any session to run the command below, or paste it into a terminal in Granular yourself:

    • Mac: npm install -g @google/gemini-cli
    • Windows: npm.cmd install -g @google/gemini-cli

    When it finishes, quit Granular completely and open it again. Granular only notices newly installed tools after a restart.

Security note: never paste an API key into the chat. Always use the connection menu or the Key Vault.

Step 1: create a Gemini API key

  1. Open Google AI Studio API keys.
  2. Sign in with your Google account.
  3. Create a new API key, or copy one you already have.

Google may show project or billing options depending on your account. Follow Google's prompts. What you need at the end is the key itself.

Step 2: add it to Granular

  1. Click the connection menu: the button in the row of controls under the message box, showing your current connection's name (or Connect an agent). It opens upward.
  2. Click Add your AI agent. Under Keys & providers, click API key, then Gemini.
  3. Paste the key and click Add.

Your Gemini key now appears under Accounts in the connection menu. Pick it for a session.

Pick a Gemini model

With a Gemini connection, the model button under the message box offers these models, in this order:

ModelDescription in the list
Pro (latest) (the default)Always Google's newest Pro: deep reasoning, small free-tier quota
Flash (latest)Always Google's newest Flash: fast everyday work, bigger free quota
Flash-Lite (latest)Always Google's newest Flash-Lite: quickest, biggest free quota
Gemini 4 ArgonGoogle's newest generation, the most capable
Gemini 3.8 FlashNewest Flash, fast everyday work
Gemini 3.6 FlashPrevious Flash, fast and steady
Gemini 3.1 ProDeep reasoning (preview), small free-tier quota
Gemini 3.5 Flash-LiteLight and quick, big free quota
Gemini 3.1 Flash-LiteOlder Flash-Lite, light and quick
Gemini 3 FlashOlder Flash (preview)
Gemma 4 31BGoogle's open model, run by Google, lighter than Gemini
Gemma 4 26BSmaller open model, quick and light

The three "(latest)" models always point at Google's newest version of that model, so they change when Google releases a new one. The numbered models stay the same version. Pin the ones you use most so they stay at the top; see Pick and pin models.

If you use a free key and keep running out of quota, switch to a Flash or Flash-Lite model.

Alternative: use the Key Vault

You can also store the key in the Key Vault if you prefer:

  1. Open Settings → Key Vault and add a new secret.
  2. Paste the key and set the variable name to GEMINI_API_KEY.
  3. Turn it on for sessions and allow it for the project you're using.
  4. Start a fresh session so the terminal picks it up.

See Vault for API keys and secrets for more.

Why not sign in with my Google account?

Google has retired signing in to the Gemini CLI with a personal Google account, for free and paid accounts alike. The API key is the way to connect Gemini today. It gives you the same models.

Troubleshooting

Granular says "Gemini is not installed" or "The Gemini CLI isn't installed yet".
Install the Gemini CLI with the command in Before you start (it needs Node.js). Then quit Granular completely and open it again, and send your message again.

On Windows, the install says "running scripts is disabled on this system".
Use npm.cmd install -g @google/gemini-cli instead of npm install …. It is the same installer without the script that Windows blocks.

Granular says Gemini isn't authenticated.
Check the key was pasted in full. If you used the Key Vault instead, check the entry is turned on, is named GEMINI_API_KEY and is allowed for this project. Then start a fresh session.

Should I use GOOGLE_API_KEY instead?
Google's tools accept either name, but for Granular use GEMINI_API_KEY. It is clearer and avoids mixing it up with other Google services.

Can I put the key in a .env file?
Please don't. A .env file is a plain text file that can be shared or uploaded by accident. Use the connection menu or the Key Vault, which keep keys encrypted.

Frequently asked questions

Can I connect Gemini by signing in with Google?
Not any more. Google retired that sign-in for personal accounts. Use a free API key from Google AI Studio.
Which Gemini models can I use?
Twelve: Pro (latest), the default, plus Flash (latest), Flash-Lite (latest), Gemini 4 Argon, Gemini 3.8 Flash, Gemini 3.6 Flash, Gemini 3.1 Pro, Gemini 3.5 Flash-Lite, Gemini 3.1 Flash-Lite, Gemini 3 Flash, Gemma 4 31B and Gemma 4 26B. Pro models reason best; Flash and Flash-Lite are faster and come with much bigger free quotas from Google.
Why does Gemini keep running out of quota?
Google's free quota for Pro models is small. Switch the chat to a Flash or Flash-Lite model, which have much bigger free quotas.
Where should the API key live?
In the connection menu (Add your AI agent → API key → Gemini), or in the Key Vault as GEMINI_API_KEY.
Will Granular show my key in chat?
No. Keys are stored encrypted and are never printed.

Related