Google API keys and Gemini: lock them down now
Gemini now rejects unrestricted Google API keys, but an AIza key whose restrictions include Gemini still works. How to restrict every key in about 10 minutes, and when to rotate.
Uses 1 of your 3 free scans today; a site scanned in the last 24 hours answers from that scan. Passive and read-only: we only look at what any browser can see. Only check sites you own or may test.
What the free scan checks
- Leaked keys in your live JavaScript (AI, payment and cloud keys), including a Supabase
service_rolekey - Files that should never be public, like
/.envand/.git - Supabase and Firebase secrets in the browser: an
sb_secret_key, a Supabase access token or a Firebase service-account file - HTTPS and security headers (CSP, HSTS, clickjacking protection)
It only reads what any visitor's browser can see. It doesn't log in, read your tables or check App Check.
What it is: a Gemini API key shipped in your page or JavaScript, where anyone can copy it and run Gemini on your bill. Since May 28, 2026, new keys created in Google AI Studio are auth keys, which look like AQ.Ab…, not the older AIza… (Google, Using Gemini API keys).
Who's affected: apps that call Gemini straight from the browser, often through a VITE_ or NEXT_PUBLIC_ variable, plus any older AIza key whose API restrictions include Gemini (below).
Safe self-check
Search your own built files for either key format. It prints only the first characters of anything it finds.
grep -rEo "AQ\.Ab[A-Za-z0-9_-]{6}|AIza[0-9A-Za-z_-]{6}" dist/ build/ .next/static/ 2>/dev/null | sort -uNo output means no key in those folders. Any line means a key is in what you ship: move it server-side and replace it.
New key format: AQ. auth keys
- Google: "Starting May 28, 2026, all new API keys created in Google AI Studio are automatically created as auth keys", and "the Gemini API rejects requests from unrestricted standard keys" (Gemini API key docs).
- Format: keys bound to a service account "have the following format AQ.Ab8RN6LEVE…" (gemini-cli PR #25497, merged Apr 21, 2026).
- Google's rule for every key: "Never expose keys client-side in production… Keys compiled in client-side code can be extracted by users. To secure client-side apps, run a backend proxy server to make the actual API calls" (Gemini API key docs).
API restrictions don't make an AQ. key safe to publish: it is a Gemini credential. If one was ever in your public code, delete it in Google AI Studio, create a new one and keep it server-side (an Edge Function or API route).
What changed
For years Google said keys that start with AIza (Maps, Firebase and so on) were fine to put in your website. Then Gemini started accepting the same keys. At the time, when someone enabled the Gemini (Generative Language) API on a Google Cloud project, existing unrestricted keys in that project quietly gained Gemini access, with "no warning", "no confirmation dialog" and "no email notification" (Truffle Security).
Google has since tightened this. The Gemini API now rejects requests from unrestricted standard keys, while standard keys with explicit restrictions keep working (Gemini API key docs). So a key whose API restrictions include the Generative Language API still works for Gemini. Keys that Firebase creates for you have been restricted to Firebase-related APIs automatically since May 2024; keys you made yourself in the Cloud console were not changed (Firebase docs).
Researchers found about 2,800 public keys that could access Gemini, including some of Google's own (Malwarebytes). With a key that has Gemini access, an attacker can access files you uploaded to Gemini and run up your AI bill (Truffle Security).
Google's current rules
- A Firebase key is fine to expose only if it is restricted to Firebase APIs. "Never include the Gemini Developer API in the allowlist for a publicly accessible API key" (Firebase docs).
- Since 28 May 2026, new AI Studio keys are "auth keys" tied to a service account. The Gemini API rejects unrestricted standard keys (Gemini API key docs).
- Never put a Gemini key in web or mobile app code. Call Gemini from a backend instead (Gemini API key docs).
What to do (about 10 minutes)
- Open Google Cloud Console → APIs & Services → Credentials for each project.
- For each key, set API restrictions so only the APIs it needs (Maps, Firebase and so on) are allowed, and make sure Generative Language API is not on the list (Google Cloud blog).
- Add Application restrictions (your website's domain) where you can.
- If you use Gemini, create a separate key, keep it in a server-side secret (an Edge Function or API route) and never in a
VITE_orNEXT_PUBLIC_variable. - If a key with Gemini access was ever in your public code, rotate it. Start with your oldest keys (Truffle Security).
Scan your app free
ShipLatch checks your live site for leaked keys, public env values, source maps and exposed files. The $29 Fix Pack gives you fix prompts written for your app and re-scans that prove each fix worked.
Questions
What does a new Gemini API key look like?
Keys created in Google AI Studio since May 28, 2026 are auth keys that start with AQ.Ab, according to Google's Gemini API key docs and the gemini-cli project. Older Google keys start with AIza.
Can I put a Gemini API key in my frontend?
No. Google says never to expose keys client-side in production, because anyone can extract them. Call Gemini from a backend or edge function and keep the key there.
Want the whole pre-launch process in one place? See what's inside App Security for Vibe Coders, our $9 PDF playbook, or go straight to checkout.