Bilo Guides FAQ

"Missing environment variable" / API key not set: what to do

Secret settings such as API keys live outside your code, in environment variables. Your computer has them in a local file; the website host does not unless you add them there. The app asks for a value, finds nothing, and stops.

The error looks like this:

Error: Missing environment variable

How to fix it

  1. Find the exact name. The error or the code names the variable, for example OPENAI_API_KEY. Copy the name exactly, including capital letters.
  2. Add it where the app runs. On Vercel, open the project, go to its environment variables settings, add the name and value, and choose the environments it applies to (Production, Preview, Development).
  3. Redeploy. Vercel says changes to variables are not applied to earlier deployments, only new ones. Trigger a new deployment after saving.
  4. For local work, use a local file. Vercel lets you download the Development values with vercel env pull, which writes a .env file. Keep that file out of Git.

What you should see

The new deployment starts without the "missing" message, and the feature that needed the key works.

Not fixed? Bring the exact message to Bilo and we will look at it with you.

Still stuck? Paste your error into Bilo

Quick questions

Why does it work locally?

Your computer reads a local .env file that was never uploaded. Hosts do not see it, which is the point: secrets should not be in your code.

Can I paste the key into the code to test?

Please do not. Code often ends up in Git, where the key can leak. Use the host's variable settings instead.

I added it but nothing changed.

You probably have not redeployed, or you added it to a different environment than the one running (for example Preview instead of Production).

Sources and date checked

Written in our own words from the official pages above. Tool names are only references; we are not affiliated with them. Commands change between versions, so check the linked docs if something differs.

Tell us your idea and get a blueprint with an estimated cost, free.

Start the free interview

Bilo works by connecting to your own AI (Claude, ChatGPT, …). You need an account with that AI, and the usage for writing things comes out of your own AI plan.