Leaked Moonshot AI (Kimi) 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 Moonshot AI step below comes from Moonshot AI's own docs, checked 21 Nov 2026.
Free. No sign-up.
Most leaked AI keys start as a call made from the browser. The template keeps every AI call on your server and records what each user spends. Buy the template →
What to do now, for Moonshot AI
Revoke the key now
On the API Keys page, disable or delete the key, then create a new one. Older v1 keys can only be deleted. The change can take about a minute to reach the API. Do this first: until it's revoked, anyone who copied it can keep spending. GitHub has no pattern for Moonshot keys, and Moonshot's docs don't say it scans for leaked keys, so don't expect a warning about one in a public repo.
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
In Organization Overview, Billing, then Overview, breaks spend down by project and API key. For newer v2 keys, Source IPs in the key list shows which IP addresses used the key each day. Note the time the key leaked and the time you revoked it.
Cap what any key can spend
Set a daily and a monthly budget in each project's settings. Once spending reaches one, every API request in that project is rejected. It can take about 10 minutes to kick in, and you still pay for usage in that gap. Budgets cover a project, not one key. The account itself is topped up in advance, and requests fail once its balance runs too low.
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. GitHub's push protection doesn't block Moonshot AI keys, so it won't stop the next one: keep the new key in a .env file that's listed in .gitignore.
If someone ran up charges, ask for them back
Email api-service@moonshot.ai. Moonshot's terms make you responsible for losses if your account isn't kept safe and someone else uses it, and say fees are non-refundable unless the law requires a refund or Moonshot decides one is appropriate. Say when the key leaked, when you revoked it and which usage wasn't yours.
Checked in Moonshot AI's own docs. Sources: Admin API guide, managing an organisation, account and billing, error codes, troubleshooting, terms of service. 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 Moonshot AI disable a leaked key for you?
GitHub has no pattern for Moonshot keys, and Moonshot's docs don't say it scans for leaked keys, so don't expect a warning about one in a public repo. Revoke it yourself either way.
Can I cap what a Moonshot AI key spends?
Set a daily and a monthly budget in each project's settings. Once spending reaches one, every API request in that project is rejected. It can take about 10 minutes to kick in, and you still pay for usage in that gap. Budgets cover a project, not one key. The account itself is topped up in advance, and requests fail once its balance runs too low.
How do I see what a leaked Moonshot AI key was used for?
In Organization Overview, Billing, then Overview, breaks spend down by project and API key. For newer v2 keys, Source IPs in the key list shows which IP addresses used the key each day.
Will Moonshot AI refund charges from a leaked key?
Email api-service@moonshot.ai. Moonshot's terms make you responsible for losses if your account isn't kept safe and someone else uses it, and say fees are non-refundable unless the law requires a refund or Moonshot decides one is appropriate.
How do I find where my Moonshot AI key leaked?
Search your code, your git history and your live site's JavaScript for “sk-ms-” (how Moonshot AI 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 xAI 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
- Leaked Fireworks AI key
- Leaked Cerebras key
- Leaked AssemblyAI key
- Leaked Pinecone key
- Which providers stop a leaked key for you
- Security checklist for vibe-coded apps