Setup guide - Documented by Aider
Use Gemini in Aider
Aider connects to Gemini natively by setting GEMINI_API_KEY and passing --model. It also documents a generic OpenAI-compatible route.
Last verified 3 steps5 official sources
Steps
- Step 1.
Configure your API key.
Terminalexport GEMINI_API_KEY=<key> # Mac/Linux setx GEMINI_API_KEY <key> # Windows, restart shell after setx - Step 2.
Start aider in your codebase. Aider's docs show these commands.
Terminal# Change directory into your codebase cd /to/your/project # You can run the Gemini 2.5 Pro model with this shortcut: aider --model gemini # List models available from Gemini aider --list-models gemini/ - Step 3.
Alternative (aider's OpenAI-compatible doc combined with Google's endpoint): set OPENAI_API_BASE to Gemini's OpenAI-compatible base URL and prefix the model name with openai/.
Terminalexport OPENAI_API_BASE=https://generativelanguage.googleapis.com/v1beta/openai/ export OPENAI_API_KEY=<key> aider --model openai/gemini-3.8-flash
Caveats
- The aider docs page is stale. It says --model gemini runs Gemini 2.5 Pro, but aider/models.py on main now maps "gemini" to "gemini/gemini-3-pro-preview", and Google lists Gemini 3 Pro Preview as Shut down. Pass an explicit current id such as gemini/gemini-3.8-flash rather than the alias.
- The gemini-exp shortcut on aider's page maps to gemini/gemini-2.5-pro-exp-03-25, an old experimental model. It is not recommended.
- The gemini/<id> form is inferred from aider's documented
aider --list-models gemini/command and its model alias table. The OpenAI-compatible alternative combines aider's documented OPENAI_API_BASE mechanism with Google's documented base URL, and aider warns about models it is not familiar with.
More setup guides
Same tool, other providers
Related reading
- Do Your Agent Hooks Fail Open? Claude Code vs Codex vs Cursor vs Gemini CLIA guard hook that crashes, times out or points at a missing script lets the tool call through by default in Claude Code. v2.1.295 adds onFailure: block. Here is what each coding agent does when your policy hook breaks, with real test runs.
- Google AI Pro vs Gemini API: What Developers Actually GetGoogle AI Pro costs $19.99 a month and has no API key, but includes $10 of monthly Cloud credits. When the subscription wins and when to pay per token.
- How to Keep API Keys Away From Your AI Coding Agent: Claude Code vs Codex vs Cursor vs Gemini CLIA deny rule on .env stops cat but not a Python one-liner. Here are the three layers that actually keep secrets out of a coding agent's context - file rules, environment scrubbing and credential masking - and what Claude Code, Codex, Cursor and Gemini CLI give you for each, with real test runs.
- Google Gemini Agent: Coworker Agents With Their Own EmailGoogle's Gemini agent can create coworker agents with their own Workspace account, email and audit trail. What Google announced and what builders should copy.
- Gemini 4 Argon: What Developers Can Actually UseGemini 4 Argon for developers: what Google shipped, what is verified, why access starts narrow, and what to watch before planning a migration around it.
- Gemini 3.8 Live and 3.8 Live Extended Thinking: Google's Audio-to-Audio Voice Models, Benchmarked and PricedGemini 3.8 Live and 3.8 Live Extended Thinking are Google's audio-to-audio voice models with background tool calls. Benchmarks, pricing and how to build.
FAQ
How do I use Gemini in Aider?
Aider connects to Gemini natively by setting GEMINI_API_KEY and passing --model. It also documents a generic OpenAI-compatible route.
Which Gemini model ids work in Aider?
The official docs read for this guide list gemini/gemini-4-argon, gemini/gemini-3.8-flash, gemini/gemini-3.6-flash, gemini/gemini-3.1-pro-preview, gemini/gemini-2.5-pro and gemini/gemini-2.5-flash. Requests go to https://generativelanguage.googleapis.com/v1beta/openai/.
Is this an official Gemini and Aider setup?
Aider documents this setup in its own docs. It was last checked against 5 official pages on October 17, 2026.
Sources
Last verified against 5 official pages.
- raw.githubusercontent.comhttps://raw.githubusercontent.com/Aider-AI/aider/main/aider/website/docs/llms/gemini.md
- raw.githubusercontent.comhttps://raw.githubusercontent.com/Aider-AI/aider/main/aider/website/docs/llms/openai-compat.md
- raw.githubusercontent.comhttps://raw.githubusercontent.com/Aider-AI/aider/main/aider/models.py
- ai.google.devhttps://ai.google.dev/gemini-api/docs/openai
- ai.google.devhttps://ai.google.dev/gemini-api/docs/models
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.