Terms & acceptable use
✨ Free Gemini key check

Added a Gemini chatbot or AI feature? Make sure your Google AI Studio key is not sitting in your public JavaScript. Paste your link and check your live app in about 10 seconds. Free.

FreeJust your email to see results10 seconds

The free scan shows your problems. The $9 fix report gives you a copy‑paste fix prompt for each one.

Guide · Gemini keys · Updated

Is My Gemini API Key Safe in My Frontend? Keep Google AI Studio Keys Out of Your Lovable, Bolt, v0 and AI Studio App

Gemini calls use your Google Cloud quota and can cost money. If your Gemini key is in browser code, anyone can copy it and use it. Here is what Google says, how vibe-coded apps leak these keys, what changed with Google's new key types, where the key should live, what to do if it leaked, and how to check your live app.

1. The rule: Gemini keys never go in the browser

  • Google says: treat your Gemini API key like a password. If someone gets it, they can use your project's quota, run up charges and reach private resources.
  • Never client-side in production: Google says not to hardcode keys in web or mobile apps, because keys in client code can be pulled out by users. Run a backend that makes the Gemini calls instead.
  • Keep keys out of git and read them from environment variables or a secret store, not config files.
  • Set billing alerts in the Google Cloud console so a spike does not surprise you.

Source: Google AI: Using Gemini API keys (security and secret management)

2. How vibe-coded apps leak Gemini keys

  1. You paste the key into the chat and the AI writes it straight into a file.
  2. The AI calls Gemini from a React component with the Google GenAI SDK to get a feature working fast. That puts the key in the JavaScript every visitor downloads.
  3. The key goes in a public env var like VITE_GEMINI_API_KEY or NEXT_PUBLIC_GEMINI_API_KEY. Those prefixes copy the value into browser code. See which env vars end up in the browser.
  4. A Vite define line copies it in. Some projects, including some exported from Google AI Studio, have a line in vite.config that sets process.env.GEMINI_API_KEY from your .env.local. It looks like a server variable, but Vite pastes the real value into the built JavaScript.

The feature works, so nothing looks wrong. The usage shows up later.

3. What changed: auth keys and unrestricted keys

  • Two kinds of keys. Older standard keys usually start with AIza and are tied to a Google Cloud project. Newer auth keys are tied to a service account and are limited to the Gemini API by default.
  • New AI Studio keys are auth keys. Google says every new key made in Google AI Studio since May 28, 2026 is an auth key.
  • Unrestricted standard keys are rejected. The Gemini API turns down standard keys with no restrictions. Keys restricted to the Gemini API still work.
  • Leak protection helps, but it is not a plan. Google says auth keys get fast leaked-key enforcement that stops keys its systems detect. Your key still works for whoever copies it until that happens, or until you replace it.

Bottom line: any key that works for your app also works for a stranger. These changes do not make a key in the browser safe.

Using one AIza key for both Google Maps and Gemini? Split them. See Is my Google Maps API key safe? (Firebase web keys also start with AIza and are a different case: Is my Firebase app secure?)

Sources: Google AI: Standard versus authorization keys · Google Cloud: API keys

4. Warning signs in your live app

If you find thisWhat it meansWhat to do
AIza... next to a Gemini callA standard Google API key in your pageLeak if it is your Gemini key. Replace it and move the call to the server
VITE_GEMINI_API_KEY or NEXT_PUBLIC_GEMINI_API_KEYA public env var. The value is copied into browser codeLeak. Rename to GEMINI_API_KEY and use it only on the server
define: { 'process.env.GEMINI_API_KEY': ... } in vite.configVite pastes the key into your built JavaScriptLeak once deployed. Remove the define line and add a server function
A request from the browser to generativelanguage.googleapis.comYour page talks to Gemini without your server in the middleWarning sign. It should go to your own server route
An x-goog-api-key header or ?key= in that requestThe key is sent from the visitor's browserLeak. Anyone can copy it from the Network tab

There is one fair use for a key in the browser: a "bring your own key" tool, where each user types in their own key and it never leaves their browser. If the key in the page is yours, it is a leak.

5. Where the key should live (Lovable, Bolt, v0, Cursor, AI Studio)

  • Lovable: you may not need your own key at all. Lovable's built-in AI connector offers Gemini models and runs the calls on the backend, billed to your workspace credits. To use your own Google key, Lovable says to call the provider from a backend edge function with your key stored as a secret. Do not put it in a VITE_ variable.
  • Bolt and other Supabase apps: make the Gemini call in a Supabase Edge Function. Save the key under Edge Function Secrets, or run supabase secrets set GEMINI_API_KEY=.... Read it with Deno.env.get('GEMINI_API_KEY').
  • v0, Cursor and other Next.js apps: call Gemini only from a Route Handler (like app/api/chat/route.ts) or a Server Action. Use an env var without NEXT_PUBLIC_, like GEMINI_API_KEY.
  • Apps exported from Google AI Studio: before you host one yourself, remove any define line in vite.config that copies your key, and add a small server function that calls Gemini.

Hidden key, open door. Moving the key to the server is step one. If your server route takes any prompt from anyone, a stranger can skip your app and call that route directly. Require sign-in on the server, limit each user to a fair number of requests, and set the model and output limit on the server.

VibeCheck does not call or test your API routes or edge functions. Check this part by hand, or use the third prompt below.

Sources: Lovable: AI features for your app · Lovable: Secrets · Supabase: Edge Function secrets · Google AI: Use a backend proxy

6. Check your live app in 60 seconds

Only check apps you own or have permission to test.

  1. Fastest: paste your live link at the top of this page. VibeCheck reads your homepage HTML and the JavaScript files it loads and lists any Google API key (AIza...) it finds, masked. It cannot see your Google settings, so it cannot tell a Gemini key from a Maps key and marks it low risk. If it finds one, check what that key is for. Newer auth keys may not start with AIza, so do step 2 as well.
  2. By hand in Chrome: open your live site, right-click and choose Inspect, then press Ctrl+Shift+F (Cmd+Option+F on Mac). Search for AIza, generativelanguage.googleapis.com, x-goog-api-key and the first few characters of your key from AI Studio.
  3. Use your AI feature once. In the Network tab, look at the request. If it goes straight to generativelanguage.googleapis.com from the browser with your key, the key is public. It should go to your own server route or edge function instead.

7. Found a key? Replace it the safe way

  1. Make a new key in Google AI Studio or the Google Cloud console.
  2. Update your app so it uses the new key only on the server (section 5), and deploy.
  3. Disable or delete the old key in the Cloud console once the new one works. Google says to wait until the new key is live so your app does not go down. If strangers are using it right now, switch it off first and accept a short outage.
  4. Check for abuse. Look at billing and API usage in the Google Cloud console, and the Usage page in Google AI Studio, for calls you did not make.
  5. Set billing alerts so you hear about the next spike early, then scan your live site again to confirm the key is gone.

More detail for every key type: I leaked my API key. What do I do now?

Source: Google AI: Leak response checklist

8. Copy-paste fix prompts

Paste the matching prompt into Lovable, Bolt, v0, Replit or Cursor. After you deploy, replace any Gemini key that was ever in client code.

Lovable or Bolt: move Gemini into a Supabase Edge Function
Search this whole project for GEMINI, GOOGLE_API_KEY, AIza, generativelanguage.googleapis.com, @google/genai and @google/generative-ai. Remove every Gemini API key from frontend code, from any VITE_ variable and from .env files. Create a Supabase Edge Function called gemini-chat that reads the key with Deno.env.get('GEMINI_API_KEY'), calls the Gemini API, and returns only the reply text. Make the frontend call that edge function instead of Google. Ask me to add GEMINI_API_KEY as a secret, never write it in code. List every place you removed a key from so I can replace that key in Google AI Studio.
v0, Cursor or a Google AI Studio export: move Gemini to the server
Find every place this app calls Gemini from the browser: imports of @google/genai or @google/generative-ai in client components, NEXT_PUBLIC_GEMINI_API_KEY or VITE_GEMINI_API_KEY, and any define line in vite.config that copies GEMINI_API_KEY or API_KEY into process.env. Remove the define line. Move all Gemini calls into a server route (a Next.js Route Handler at app/api/chat/route.ts, or a small serverless function if this is a Vite app) that reads process.env.GEMINI_API_KEY with no public prefix. The browser should only call /api/chat. List every key you removed so I can replace it in Google AI Studio.
Lock down my Gemini endpoint
Update the server route or edge function that calls Gemini so strangers cannot use it on my bill: require a signed-in user and check their session on the server, allow at most 20 requests per user per hour and return 429 after that, set the model, system instructions and the max output tokens on the server (never take them from the browser), cap the length of the user message, and log the user ID for each request. Show me the changed code.

9. Check it for me

Paste your link into VibeCheck. In about 10 seconds it checks the JavaScript your live site sends to visitors for leaked keys (Google AIza, OpenAI, Anthropic, Stripe sk_live_, Supabase service_role and more), checks if your public Supabase key can read open tables, and checks security headers, SEO basics and broken links.

It is a public, read-only check of your live app. It never asks for your code, your login or your Google account, and it never uses any key it finds.

Pricing: the problems list is free (just add your email). The $9 fix report gives you a copy-paste fix prompt for every problem found, or get the $29 10-pack (10 fix reports to use any time). No subscription.

No tool can promise your app is 100% secure. VibeCheck catches common, costly mistakes before a stranger does.

10. FAQ

Is it safe to put my Gemini API key in my frontend?

No. Google says to treat your Gemini API key like a password and never expose it client-side in production, because keys in web apps can be pulled out by anyone. If it leaks, others can use your quota and run up charges. Call Gemini from a backend (a server route or a Supabase Edge Function) and keep the key as a server-side secret.

Is VITE_GEMINI_API_KEY or NEXT_PUBLIC_GEMINI_API_KEY safe?

No. Anything that starts with VITE_ or NEXT_PUBLIC_ is copied into the JavaScript the browser downloads. Use a plain server-only name like GEMINI_API_KEY and read it only in server code.

I built my app in Google AI Studio. Is my key in the browser?

It can be once you deploy it somewhere else. Some exported Vite projects copy GEMINI_API_KEY into browser code with a define line in vite.config, so the key ends up in the built JavaScript. Before you host the app on Vercel, Netlify or your own domain, move the Gemini call to a server function and search your live files for your key.

Google says unrestricted keys are rejected. Does that make a leaked key harmless?

No. Google says the Gemini API now rejects unrestricted standard keys, but keys restricted to the Gemini API keep working, and new AI Studio keys are auth keys that are made for the Gemini API. A key that works in your app also works for a stranger who copies it. Google does say auth keys get fast leaked-key enforcement, but do not count on that to save your bill.

My Gemini key leaked. What do I do?

Make a new key in Google AI Studio or the Google Cloud console, deploy your app with the new key stored only on the server, then disable or delete the old key. Google says to switch to the new key first so your app does not go down. Then check billing and API usage in the Google Cloud console for calls you did not make, and set billing alerts.

How do I check if my live app leaks a Gemini key?

Paste your live link into VibeCheck for a free scan. It reads your homepage and the JavaScript files it loads and lists any Google API key (AIza...) it finds, masked. It cannot tell a Gemini key from a Maps key, so check what the key is for. By hand: open DevTools, press Ctrl+Shift+F (Cmd+Option+F on Mac) and search for AIza, generativelanguage.googleapis.com and x-goog-api-key.

More questions? See the VibeCheck FAQ. Related guides: Is my OpenAI key safe in my frontend? · Is my Anthropic (Claude) key safe? · Is my Google Maps key safe? · How to check if your API key is exposed · I leaked my API key. What do I do now? · Is NEXT_PUBLIC_ safe for API keys? · Is my Lovable app safe? · Is my Bolt app secure? · Is my v0 app secure? · Vibe coding security checklist.