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
- Gemini Trains on Your Chats Unless Keep Activity Is OffA Tell HN says paying for Gemini does not stop chat training. What Google documents about Keep Activity, human review and 3-year retention, and what developers should do before pasting code.
- Gemini 4 Carbon: Benchmarks, Pricing, and AccessGemini 4 Carbon is Google's new frontier model: 59 on the AA Intelligence Index, $2/$10 intro pricing, but cyber-defender access only. What builders do now.
- AI API 429, 529 and 503 Errors: Retry Rules That Match the DocsWhich 429, 529 and 503 errors to retry across OpenAI, Claude, Gemini and Bedrock, how to read Retry-After, and a typed wrapper that skips quota errors.
- AI Model Shutdown Dates 2026-2027: Calendar and Migration PlanEvery scheduled AI model API shutdown through mid 2027 by month: GPT-4o on Jan 14, whisper-1 on Feb 26, Claude Sonnet 4.5 on Nov 30, plus how to migrate.
- Gemini Live and TTS Preview Models Retire November 17: Moving to Gemini 3.8 Live and 3.8 Flash TTSThe Gemini API shuts down two Live API preview models and three TTS preview models on November 17, 2026. Replacement ids, what changes in the session config and TTS request, prices before and after, and the code change.
- Prompt Caching Across AI Providers: Prices, TTLs and SetupPrompt caching across OpenAI, Anthropic, Gemini, DeepSeek, Mistral, xAI and Qwen: prices, TTLs, setup code. A reused 100K prefix costs 71-93% less.
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.