An API key can end up somewhere it does not belong through a very ordinary mistake: a code commit, a screen recording, a support message, or a website build that includes a secret in its public files.
If that happens, focus on containing it. You do not need to know whether someone used the key before deciding to replace it.
First, make the exposed key stop working
Revoke the compromised credential in the provider’s console. Where continuity matters, use the provider’s rotation process to issue a replacement, update the affected services, and retire the old credential promptly. If there is evidence of active misuse, prioritize revocation over keeping the feature available.
GitHub’s guidance puts revoking or rotating a secret before repository cleanup. Deleting the latest copy of a file does not make the old key invalid, and copies may remain in history or elsewhere. GitHub’s incident guidance
Record which key was affected, the relevant project, when you discovered it, and where it appeared. Do not copy the full secret into your incident notes or a new support thread.
Work out what that key could actually reach
Check the key’s permissions and the account it belongs to. Could it only generate text? Could it read stored files, change records, or access another service? An exposed key does not automatically mean every customer record was accessed, but a quiet dashboard does not prove nothing happened.
Review available usage, billing, and access logs for activity you cannot explain. Preserve relevant evidence securely. Contact the provider if you need help interpreting it or stopping ongoing misuse. If personal information may be involved, get appropriate incident-response and legal advice about your obligations.
Google’s key guidance describes unexpected charges, quota consumption, and access to private resources as possible consequences of a compromised Gemini key. The actual exposure depends on the key and its permissions. Google’s key-security guidance
Remove the copies without creating another problem
Search the places your own project uses: current source files, repository history, generated website files, deployment configuration, logs, shared documents, and recordings. Automated secret scanning can help, but manually review the output and any files the scanner does not cover.
Repository history cleanup can affect collaborators and existing clones. Coordinate it rather than rewriting history in a hurry. Ask people who received a copy to remove it, while remembering that removal is not a substitute for revocation. Repository cleanup considerations
Deleting a leaked key from a file changes the file. Revoking the key changes what the credential can do.
Fix how the key got there
Put the replacement secret in your server’s secret store. Keep development and production credentials separate. Give each integration the smallest practical set of permissions, and document who owns it.
Check the deployed application as well as the source. Some frontend build systems deliberately embed selected environment variables into public JavaScript. A variable named “secret” is not protected if the application sends its value to the browser.
Use sample credentials in tutorials and video demos. Before recording, close account settings and terminals containing secrets. Before publishing, review the actual video frames and screenshots.
Finally, test that the old credential is rejected, the legitimate service works with the replacement, and spending alerts reach the right person. Keep the result in a short incident record so the lesson becomes part of how you build.
Cost controls are another useful layer. They do not make a leaked key safe, but they can help limit what happens while you respond. Set up your AI API spending controls.
Sources & last checked
Checked against these primary sources on October 24, 2026. Provider settings can change; use the linked documentation to confirm the current controls.
TURN THE IDEA INTO A CLEAR NEXT STEP
Building something?
Let’s look at what it needs.
Training, project consulting, or a scoped review of what you have built. Start with the question you are trying to answer.
Talk about your project