Fix "Incorrect API key provided" in my AI feature | Vovy
Track down why your AI provider rejects your key: wrong variable name, missing prod env var, stray spaces, or a revoked key.
My app says invalid API key but I pasted it right. What's going on?
How it works
- Find where the key is read: Vovy searches your code for the variable name, like OPENAI_API_KEY, and checks it matches what you set, letter for letter.
- Check local and production: Vovy checks your .env file and your host's environment variables. The classic case: it works locally because prod never got the key.
- Test the key directly: Vovy tests the key with a single curl request in Terminal. If that fails too, the key itself is wrong, revoked or from another project.
- Replace and redeploy: If needed, Vovy creates a fresh key, updates the variable with no spaces or quotes, and redeploys, since env changes only apply to new deploys.
- Confirm the fix: Vovy triggers the AI feature on your live site and shows a card with the cause it found and the working response.
What you provide
- Access to your code and host
- Access to your AI provider account
What you get
- The real cause of the error
- A working key in every environment
- A tested live feature
FAQ
Why does it work on my Mac but not live?
Your .env file is not uploaded when you deploy. Production needs the same variable set in your host's dashboard.
I changed the env var and it still fails.
Most hosts only read environment variables at deploy time. Redeploy after every change.
Can I put the key in a VITE_ or NEXT_PUBLIC_ variable?
Do not. Those prefixes ship the key to every visitor's browser. Keep it server-side.
Related tasks
All tasksLoading...