Fix Gemini API_KEY_INVALID / API key not valid
Short answer: start with Using Gemini API keys, Gemini troubleshooting, Gemini API reference (4 tools listed below). Stop retrying the 400, check GOOGLE_API_KEY vs GEMINI_API_KEY, send x-goog-api-key, then rotate a leaked or mangled key in AI Studio.
Last updated: · 4 tools on this page.
New to this? Start with the 5-step fix: Gemini returns “API key not valid”. Fix which key is sent, then stop retrying 400s
Which tools are best to fix Gemini API_KEY_INVALID / API key not valid?
4 tools →1 of 1 open this week · labeled problem sponsor · Book this page →
- Using Gemini API keys Env var precedence (GOOGLE_API_KEY over GEMINI_API_KEY) and how to pass a key explicitly. Free docs
- Gemini troubleshooting Do not retry 400s; leaked-key and project status guidance. Free docs
- Gemini API reference Native auth via x-goog-api-key on generativelanguage.googleapis.com. Free docs
- Google AI Studio API keys Create and rotate Studio keys restricted to the Gemini API. Free
Listing order is editorial, not paid. Pricing notes are a guide; check each vendor's site.
NewAIToolsToday Daily
Top 3 AI launches, one model or news item that matters, and one simple fix. A 5-minute read, every weekday.