AI API errors / Google Gemini API
Google Gemini API · HTTP 403 · checked Oct 24, 2026
Google Gemini API 403 PERMISSION_DENIED: what it means and how to fix it
Do not retry: fix it first403 PERMISSION_DENIED: Your project has been denied access
What it meansThe key lacks permission or the project is restricted: free tier unavailable, payment needed, or the key blocked.
How to fix it
- Check the project's status in Google AI Studio. Free-tier eligibility is per Google Cloud project, so a new key in the same project will not help; link a Cloud Billing account.
- If billing is past due, fix the payment method.
Handle it in code
import random, time
from google import genai
from google.genai import errors
client = genai.Client()
def generate(prompt, tries=6):
for i in range(tries):
try:
return client.models.generate_content(model="gemini-flash-latest", contents=prompt)
except errors.APIError as e:
# 429 RESOURCE_EXHAUSTED, 503 UNAVAILABLE, 500, 504: transient. 400/402/403: fix, do not retry.
if e.code not in (429, 500, 503, 504) or i == tries - 1:
raise
time.sleep(min(60, 2 ** i) + random.random()) # exponential backoff + jitterGoogle lists 429 RESOURCE_EXHAUSTED, 503 UNAVAILABLE, 408 and 5xx as transient: retry with exponential backoff and jitter. 400, 402 and 403 are not.
Same kind of error at other providers
- Anthropic 401 authentication_error
- Anthropic 403 permission_error
- OpenAI 401 invalid_api_key
- OpenAI 401 invalid_authentication
Other Google Gemini API errors
- 429RESOURCE_EXHAUSTEDretry
- 503UNAVAILABLE: The model is overloaded. Please try again later.retry
- 400INVALID_ARGUMENTfix
- 400FAILED_PRECONDITIONfix
- 402payment_requiredfix
- 403PERMISSION_DENIED: Your API key was reported as leaked. Please use another API key.fix
- 404NOT_FOUNDfix
- 500INTERNALretry
- 504DEADLINE_EXCEEDEDretry
- -RECITATIONfix
- -SAFETYfix
Source
- Google Gemini API error documentation: ai.google.dev/gemini-api/docs/api-errors (checked Oct 24, 2026)
Paying too much per call while you are here? Compare AI model prices or estimate your bill.
Up next
Paste any errorEvery AI API error, retry or fixAnthropic, OpenAI and Gemini in one finder.Read it next →Also worth your time
Did this answer your question?
Up next
Get 3 picks for your job, volume and budgetPick an AI model for your jobLLM API pricing for 71 models per 1M tokens, checked at the source. Pick for me: your job, volume and budget give 3 models with the monthly cost. Filters, CSV.Read it next →