Connect Gemini
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.
- Mac:
Step 1: create a Gemini API key
- Open Google AI Studio API keys.
- Sign in with your Google account.
- 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
- 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.
- Click Add your AI agent. Under Keys & providers, click API key, then Gemini.
- 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:
| Model | Description 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 Argon | Google's newest generation, the most capable |
| Gemini 3.8 Flash | Newest Flash, fast everyday work |
| Gemini 3.6 Flash | Previous Flash, fast and steady |
| Gemini 3.1 Pro | Deep reasoning (preview), small free-tier quota |
| Gemini 3.5 Flash-Lite | Light and quick, big free quota |
| Gemini 3.1 Flash-Lite | Older Flash-Lite, light and quick |
| Gemini 3 Flash | Older Flash (preview) |
| Gemma 4 31B | Google's open model, run by Google, lighter than Gemini |
| Gemma 4 26B | Smaller 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:
- Open Settings → Key Vault and add a new secret.
- Paste the key and set the variable name to
GEMINI_API_KEY. - Turn it on for sessions and allow it for the project you're using.
- 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?
Which Gemini models can I use?
Why does Gemini keep running out of quota?
Where should the API key live?
GEMINI_API_KEY.