Google Gemini APIRunbook 0/2 done
API_KEY_INVALID

Google Gemini API Error API_KEY_INVALID: API key not valid

Critical✕ Not retryable · fix the payloadHTTP 400 Bad RequestAI Provider
TL;DR · 10-second read

Gemini reports a bad key as 400 INVALID_ARGUMENT with reason API_KEY_INVALID, not 401. Create a key in Google AI Studio and check it is restricted to the Generative Language API.

Identify: does your log match?

What you see · exact log / response
{
  "error": {
    "code": 400,
    "message": "API key not valid. Please pass a valid API key.",
    "status": "INVALID_ARGUMENT",
    "details": [{ "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "API_KEY_INVALID", "domain": "googleapis.com" }]
  }
}

Fix

Being written

Copy-paste fixes for API_KEY_INVALID are in the enrichment queue

The summary above is verified. Paste your full trace into the decoder for a diagnosis now.

Open the decoder →

Related errors

Last verified 2026-10-22 · Source: Gemini API troubleshooting guide + google.rpc status codes · Official docs ↗ · ~6,600 searches/mo