Email me

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 first
403 PERMISSION_DENIED: Your API key was reported as leaked. Please use another API key.

What it meansGoogle found your key in public (a GitHub repo, a website's JavaScript) and blocked it.

How to fix it

  1. Create a new key in Google AI Studio.
  2. Never ship keys in client-side code or commit them; call the API from your server and keep the key in an env var or secret manager.
  3. Check your repo history and rotate any other keys that were committed with it.

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 + jitter

Google 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

Other Google Gemini API errors

Source

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 →

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 →

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Did this answer your question?

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ