← All posts

Vibe Coding Security: How to Keep API Keys Out of Your AI Chat

Pasting an API key into ChatGPT or Claude is an easy mistake. Learn why it's risky, what to do instead, and how to set environment variables safely when you deploy.

The easiest mistake in AI-built apps

Your app needs an API key, perhaps for payments, email or an AI model. Your AI asks for it, and the quickest thing is to paste it into the chat. Don't.

Secrets pasted into a chat can end up in chat history, in code the AI writes back (often with the key hard-coded in it), in screenshots, and in GitHub if that code gets pushed. Leaked keys get found and abused, sometimes within hours.

Three simple rules

  1. Never paste a secret into a chat. A secret is anything that grants access: API keys, passwords, tokens, database URLs.
  2. Never hard-code a secret in your code. Code gets saved, shared and pushed.
  3. Keep secrets in environment variables. The code reads them when it runs, and the values live in your hosting settings, not in the files.

What an environment variable is

It's a named setting your app reads at run time. In code you'd write something like process.env.OPENAI_API_KEY. The code mentions only the name. The value is stored separately on the server, so the key never appears in your files.

How to do it right with deployinn

  • While deploying from the extension: if your app needs a key, you are asked in a hidden field. It goes straight to hosting.
  • In the dashboard: open the project's settings and add variables there. You see variable names, never values played back.
  • From a connected AI app: ask it to add a variable. It gives you a link to the settings page instead of asking you to paste the value. You add it there.
  • From the terminal: deployinn env set my-app API_KEY=... sends the value straight to hosting.
  • After changing a variable, redeploy so the running app picks it up.

deployinn doesn't store secret values. They go to the hosting and are not shown back. The Environment variables doc has every option in detail.

What your AI can and can't see

When you deploy through the extension's setup chat, the assistant sees file names and variable names only, not your code and not your values. When you connect an AI app, the tools return project information such as names, addresses and status, but never secret values. More in Privacy and security.

A quick checklist before you share a project

  • No key, token or password appears in any file.
  • There is no .env file in the repository (deployinn never sends .env files).
  • Every secret is set as an environment variable.
  • Old test keys are deleted or rotated.
  • Your keys have spending limits where the provider offers them.
  • You know where to remove access (the Devices page in your dashboard).

What if a key already leaked?

  1. Revoke or rotate it at the provider right away. Do this first.
  2. Create a new key and set it as an environment variable.
  3. Check the provider's usage page for charges you don't recognise.
  4. If it was in a public repository, assume it's copied. Removing it from the files doesn't un-leak it. Rotation does.

FAQ

Is it safe to paste an API key into ChatGPT or Claude?

Avoid it. Use environment variables and add values outside the chat.

What is a .env file?

A local file that lists variables. It must stay out of your repository.

Why does my app not see the new variable?

Redeploy. Running apps pick up variables on the next deploy.

Does deployinn store my keys?

No. Values go straight to hosting and aren't shown back.

Deploy without leaking a key

Keys go in a hidden field, never the chat. Get the Chrome extension. New to deploying? Start with How to Deploy an App Built with ChatGPT or Claude.

For the bigger picture, read AI Made Everyone a Builder. Deploying Is Still the Hard Part.

AI-built apps, live in minutes.

Works with
  • Claude
  • ChatGPT
  • Gemini
  • Grok
  • Chrome
  • Cursor
  • Claude Code
  • Codex