Environment Variables & API Keys
Environment Variable / API Key
A separate place to keep secret values, like passwords and API keys, that should never be written directly in your code.
💡 It's keeping your house key in a safe instead of under the doormat.
🤖 Say this to your AI
Don't put my OpenAI API key directly in the code. Put it in an environment variable (.env.local), read it only on the server, and create an example file (.env.example) too.
The key word is ‘Environment Variable / API Key’. Including it helps AI understand you much more precisely.
📌 Good to know
If an API key gets pushed to GitHub, it can be stolen within minutes and run up a huge bill. If a key is ever exposed, revoke it and get a new one right away.
When to use it
- When you use keys for outside services like payments, AI, or maps
Also called: api key, secret key, env, .env, environment variable, token, secrets, leaked key