Leaked an API key? › OpenRouter
Leaked OpenRouter API key: what to do in the next 10 minutes
Last updated: November 15, 2026. Steps checked against OpenRouter's own docs on November 15, 2026.
Short answer: Delete the leaked key on OpenRouter's API keys page (openrouter.ai/settings/keys) first, as OpenRouter's docs say to do when a key may be exposed. Then create a new key with a credit limit and put it only in a server-only environment variable such as OPENROUTER_API_KEY, never in client JavaScript or a VITE_ or NEXT_PUBLIC_ variable, and redeploy. Check the Activity page, grouped by API key, for spend you don't recognize. A free SniffPup scan of a site you own can help find a remaining exposed sk-or-v1- key in public pages, but it cannot confirm the key is absent everywhere or that the site is secure. Removing the key from code alone does not un-leak it.
Which OpenRouter keys are secret?
- Secret: OpenRouter API keys. OpenRouter documents the format as sk-or-v1- followed by 64 lowercase hexadecimal characters, 73 characters in total. Management keys use the same format, and they can create and delete your other keys, so treat a leaked management key at least as seriously.
- Secret: OpenRouter says its API keys are more powerful than keys used directly for model APIs: they can spend your credits on many models and can be used in OAuth flows.
- Meant to be public: None. OpenRouter says to protect your API keys and never commit them to public repositories, and to keep keys out of your codebase with environment variables.
The next 10 minutes
Times are a rough guide. Do the first step before anything else.
1. Delete the leaked key (Minutes 0-2)
- Open the API keys page (openrouter.ai/settings/keys) and delete the compromised key. OpenRouter's docs say that if you get a compromise notice or suspect a key has been exposed, you should immediately delete it and create a new one. Anything still using that key stops working until you switch to the replacement.
- OpenRouter is a GitHub secret scanning partner and has other ways to detect exposed keys. If it determines a key was compromised, it emails you. Don't wait for that email. If you found the leak yourself, act now.
- On the Security settings page (openrouter.ai/settings/security), the Key safety tab can also disable or archive a key. Disabling is reversible. Archiving is permanent.
2. Create a server-only replacement with a credit limit (Minutes 2-5)
- Create a new key, give it a clear name, and choose a credit limit, with a daily, weekly or monthly reset if you want one. OpenRouter recommends a limit on every key: a key with no limit lets a leaked key spend your entire balance, including any auto top-ups. Once a key uses its limit, OpenRouter rejects its requests until you raise the limit or the limit resets.
- Store the new key only in a server-only environment variable or secrets manager, for example OPENROUTER_API_KEY, never in client JavaScript, a mobile app, a public repository, or a VITE_ or NEXT_PUBLIC_ variable. Send it as Authorization: Bearer from your backend only, then redeploy so the public bundle no longer ships the old key.
- You can't add an expiration to an existing key, so if you want one, set it when you create the replacement. OpenRouter's Security settings flag keys that never expire.
3. Check Activity for spend you didn't make (Minutes 5-8)
- Open the Activity page (openrouter.ai/activity) and group by API Key. It shows Spend, Tokens and Requests over 1 hour, 1 day, 1 month or 1 year. Look for traffic on the leaked key that your app didn't send, and note times and amounts. You can export the data as CSV or PDF.
- On Security settings, review the Overview cards: keys with no spend limit, keys that never expire, keys idle for 90 days or more, and keys that are safe to remove. Set limits on keys you keep and remove the ones nothing uses.
- If you see usage you don't recognize, contact OpenRouter with the times and amounts. That is our advice, not a step from OpenRouter's docs, and we can't promise how OpenRouter will handle charges from a leaked key.
4. Clean up and re-check (Minutes 8-10)
- Remove the key from frontend code, public files, screenshots, CI logs, and git history. History can keep a secret after the file is deleted. Rotate any other secrets that sat in the same file or commit. Give each app and environment its own key.
- Deleting the key from a repo does not revoke it. Only deleting, disabling or archiving it in OpenRouter does that. Close the leak path so the replacement never ships to the browser.
- Re-scan the live site you own. A passive scan can help find a remaining exposed sk-or-v1- key in public pages. It cannot confirm the key is absent everywhere, and a clean report is not a guarantee of security. Don't paste the full secret into chat.
Good to know
- The free scan flags an OpenRouter API key when it finds sk-or-v1- followed by 64 lowercase hex characters in HTML, inline scripts, or same-origin JavaScript bundles. That matches the format OpenRouter documents. Management keys share the format, so the scan cannot tell the two apart.
- For a planned rotation, OpenRouter's zero-downtime order is: create a new key, update your applications, then delete the old key once all systems have moved. Check Activity to confirm traffic moved to the new key before you delete the old one.
- Replacing a key without removing it from client bundles or public .env files exposes the new key the same way.
- The scan is passive and read-only on a live URL you own or are authorized to test. It is not a security guarantee.
After the first 10 minutes
Move the code that needs the key to the server (an API route, serverless function or Supabase Edge Function), keep the key in a server-only environment variable, redeploy, and re-check your live site. The general plan, with a prompt you can paste into Lovable, Bolt, Cursor or Claude Code, is in I leaked an API key in my vibe-coded app. What do I do now?
What SniffPup checks, and what it doesn't
A free SniffPup scan reads only what your live site serves to the public: secret key patterns in HTML and same-origin JavaScript (masked in the report) and public files such as /.env and /.git/config. It never uses a key it finds. It can't see your repo, your server or OpenRouter's logs, so the steps above are always on you. A clean report is not a guarantee of security.
Sources
- OpenRouter Docs: Authentication (credit limits, if your key has been exposed)
- OpenRouter Docs: Security settings
- OpenRouter Docs: API Key Rotation
- OpenRouter Docs: Activity Export
OpenRouter can change its dashboard and steps at any time. If something here doesn't match what you see, follow OpenRouter's docs and tell us.
Other providers
- Leaked OpenAI API key: what to do in the next 10 minutes
- Leaked Anthropic API key: what to do in the next 10 minutes
- Leaked Gemini API key: what to do in the next 10 minutes
- Leaked Resend API key: what to do in the next 10 minutes
- Leaked Perplexity API key: what to do in the next 10 minutes
- Leaked ElevenLabs API key (unauthorized charges): what to do
- Leaked Stripe secret key: what to do in the next 10 minutes
- Leaked Supabase service_role or secret key: next 10 minutes
- Leaked AWS access key: what to do in the next 10 minutes
- Leaked GitHub token: what to do in the next 10 minutes