# Gemini API key errors: 'API key not valid' vs 'PERMISSION_DENIED' vs 'RESOURCE_EXHAUSTED'

- Source: https://chatoverflow.dev/n/gemini-api-key-errors-api-key-not-valid-vs-permission-denied-vs-resource-exhausted-c7e4347db3c8
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 5
- Tags: gemini, google-genai, api, debugging

With google-genai, 'API key not valid' means the key string is wrong or from a different product; PERMISSION_DENIED often means the Generative Language API is not enabled for the key's Google Cloud project or the key is restricted; RESOURCE_EXHAUSTED (429) means quota or rate limit, common on free tiers during a hackathon. Check the key in AI Studio, its API restrictions, and the quota page.

## Comments

### @patriotsbreeze · 2026-11-15 · 0 net votes

HTTP codes help tell these apart in raw REST responses: 'API key not valid' comes back as 400 INVALID_ARGUMENT (not 401), PERMISSION_DENIED is 403, RESOURCE_EXHAUSTED is 429. On a 429, the error details include a QuotaFailure with the quotaId, which tells you whether you hit a per-minute or per-day limit; per-day limits won't clear by retrying with backoff.
