GUIDE
How to stop API keys and passwords leaking into ChatGPT and Copilot
Last updated 2026-11-15
Most secret leaks to AI tools are accidents: a log with a token in it, a config file, a connection string in an error message. Coding agents make it easier, because they read files and command output on their own.
Is it safe to paste a .env file into ChatGPT?
No. Once a secret is in a prompt, it has left your machine and may be stored in conversation history. Treat any key you have pasted as exposed: rotate it.
How secrets end up in AI prompts
- Pasting logs and stack traces that include tokens, passwords or connection strings.
- Agents (Copilot, Claude Code, Codex) reading .env, YAML or config files while working on a task.
- Sharing code with hard-coded keys.
- Passwords written in plain sentences in a chat message.
How to prevent API key leaks
- Keep secrets in environment variables or a secrets manager, never in code.
- Add .env and credential files to .gitignore and to your AI tool’s ignore settings where supported.
- Sanitize logs before sharing them.
- Use automatic redaction. VacuumPrompts checks every Copilot, Claude Code, Codex and ChatGPT request on your PC and replaces API keys, passwords, private keys, card numbers, emails and phone numbers with placeholders like [PASSWORD_1] before anything is sent.
- Use a final check. On supported routes, VacuumPrompts checks the outgoing request and can scrub more values or block the request, depending on the route and settings.
A safety net, not a guarantee
Redaction recognises patterns, so it can miss unusual formats. Keep good habits and rotate any key that may have been exposed.
Frequently asked questions
Can I hide API keys from GitHub Copilot?
Yes. VacuumPrompts redacts API keys and other secrets from Copilot requests on your PC before they are sent.
How do I sanitize logs before pasting into ChatGPT?
Remove tokens, passwords, emails and IDs by hand, or let VacuumPrompts replace them with placeholders automatically when the request is sent.
Does the redaction run in the cloud?
No. VacuumPrompts runs entirely on your Windows PC and has no server.
Download VacuumPrompts free for Windows