Leaked xAI (Grok) API key? What to do now
Revoke it first, then check what it was used for, cap what your keys can spend and clean up where it leaked. Every xAI step below comes from xAI's own docs, checked 15 Nov 2026.
Free. No sign-up.
What to do now, for xAI
Revoke the key now
On the API keys page, check you're in the right team, then open the ⋮ menu and choose Disable key or Delete key. Do this first: until it's revoked, anyone who copied it can keep spending. xAI disables keys found in public GitHub repos and emails you.
Keep the new key on the server
Put the new key only in a server-side secret: your host's environment settings, your builder's secrets, or Supabase function secrets. Never in a variable starting NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_, which are sent to every visitor.
Check usage for charges that weren't yours
The Usage Explorer can filter by API key, and by the IP address requests came from. Note the time the key leaked and the time you revoked it.
Cap what any key can spend
Accounts are prepaid: with the default settings, requests are rejected once credits run out, unless auto top-up or invoiced billing is on. Keys can have rate limits but not spend caps.
Clean up the repo, after revoking
Remove the key from the code and the git history, but only once it's revoked: anyone who cloned the repo, or a fork, still has it. Then turn on push protection, so GitHub blocks the next key you try to push.
If someone ran up charges, ask for them back
Email support@x.ai. xAI doesn't refund prepaid credits except where the law requires it. Say when the key leaked, when you revoked it and which usage wasn't yours.
Checked in xAI's own docs. Sources: security FAQ, usage, billing, billing FAQ. Dashboards move, so if a link is out of date, look for the same setting under account or organisation settings.
Then find every other copy, with your coding agent
Find every place an API key or other secret is exposed in this project, and fix it. Search the code, env files, config and local settings files (such as .claude/settings.local.json), the full git history (with gitleaks or a similar scanner) and the built browser bundle. Flag any secret in a variable with a public prefix such as NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_, and any AI provider called from browser code. Move every AI call into a server route or function that reads its key from a server-only variable, add .env and local settings files to .gitignore, and list each key that was exposed and where, so I can revoke it. Don't rewrite git history.
Questions
Does xAI disable a leaked key for you?
xAI disables keys found in public GitHub repos and emails you. Revoke it yourself either way.
Can I cap what an xAI key spends?
Accounts are prepaid: with the default settings, requests are rejected once credits run out, unless auto top-up or invoiced billing is on. Keys can have rate limits but not spend caps.
How do I see what a leaked xAI key was used for?
The Usage Explorer can filter by API key, and by the IP address requests came from.
Will xAI refund charges from a leaked key?
Email support@x.ai. xAI doesn't refund prepaid credits except where the law requires it.
How do I find where my xAI key leaked?
Search your code, your git history and your live site's JavaScript for “xai-” (how xAI keys start). Common places are browser code, a committed .env or local settings file, and screenshots.
Other providers
- Leaked OpenAI key
- Leaked Anthropic key
- Leaked Google Gemini key
- Leaked Mistral key
- Leaked DeepSeek key
- Leaked OpenRouter key
- Leaked ElevenLabs key
- Leaked Replicate key
- Leaked fal key
- Leaked Groq key
- Leaked Together AI key
- Leaked Hugging Face key
- Leaked Perplexity key
- Leaked Cohere key
- Which providers stop a leaked key for you
- Security checklist for vibe-coded apps