Leaked OpenAI API key: how to check and what to do
How to tell if your OpenAI key is exposed in your frontend or repo, how to revoke and replace it, and how to call OpenAI safely from a vibe-coded app.
Check your live site
Run the free ShipLatch scan on your own site without leaving this page.
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.
Related free check: Is my .env file public?
If your app calls OpenAI straight from the browser, your API key is in your JavaScript bundle, and anyone who opens dev tools can copy it and spend your credits. AI builders do this often when you ask for "a chatbot" and don't say where the key should live.
How to check
- Open your live site, then dev tools → Sources (or view source) and search the loaded
.jsfiles forsk-. OpenAI keys start withsk-, and newer ones withsk-proj-. - Search your repo too, including old commits. A key that was ever pushed to a public repo should be treated as leaked.
- Check that
https://YOUR_DOMAIN/.envdoes not download (see How to check if your .env is exposed).
What to do if it leaked
- Revoke it first. In the OpenAI platform dashboard, go to API keys and delete the exposed key. Deleting it from your code does nothing; copies already exist.
- Create a new key and put it only in server-side environment variables (your host's secrets, a Supabase Edge Function secret, etc.). Never in a variable that gets bundled for the browser, such as ones prefixed
VITE_,NEXT_PUBLIC_orEXPO_PUBLIC_. - Look at usage for the time the key was public and set a monthly budget limit on the project so a future leak has a ceiling.
- Proxy the calls. Your frontend calls your own endpoint; that endpoint checks the user is signed in, applies a rate limit, and calls OpenAI with the server-side key.
My OpenAI API key is currently used in frontend code. Move every OpenAI call into a server-side function (an API route or Supabase Edge Function). Read the key from a server-only environment variable, never one prefixed VITE_, NEXT_PUBLIC_ or EXPO_PUBLIC_. Require a signed-in user and add a simple per-user rate limit. Remove the key from all client code and tell me every file you changed.
Related: Can I call the OpenAI API directly from my React app? · I committed an API key to GitHub. What do I do? · Hide API keys when an AI builder writes your app · Exposed service_role key
Scan your app free
Paste your URL. ShipLatch checks for leaked keys, exposed /.env and /.git, and flags Supabase/Firebase so you know what to lock down. The free scan finds the issues; the $29 Fix Pack gives you fix prompts written for your app and re-scans that prove each fix worked.
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.