What should I do if my AI API key leaked on GitHub?
Revoke the leaked key immediately in the provider's console, then create a new one. Deleting the file from your repository is not enough because the key remains in history, forks and clones.
Steps:
- Revoke or delete the exposed key first. Do this before anything else.
- Create a replacement and store it in an environment variable or secrets manager.
- Check your usage and billing for activity you did not make.
- Test that the old key now fails.
- Remove the key from the code and, if appropriate, clean the history, treating that as a secondary step.
- Turn on secret scanning or push protection in your code host.
- Tell your team or security contact.
Some providers take part in programs that detect keys found in public repositories and may disable them, but do not rely on that, and it does not cover private repos. Your provider's support pages describe their exact process.
Related answers
Are AI-written phishing emails harder to spot, and what should I look for now?
Yes, AI can write clean, convincing phishing emails without the spelling mistakes people used to rely on, so judge the request and the sender, not the grammar.
privacy-safety
Can AI analyze my Excel or CSV data and can I trust the results?
Often yes, especially with assistants that can run code on uploaded files, but you should verify the results.
accuracy
Can an AI assistant be tricked by hidden instructions in emails or web pages?
Yes. If an assistant reads emails, web pages or documents, hidden text in them can try to give it new instructions, which is called prompt injection.
privacy-safety