Invalid API Key provided
- Stripe
- OpenAI
- Supabase
- Any API
What it means
The service does not recognise the key your app sent. In production this is almost always a missing, outdated or wrong-mode environment variable, not a problem with the code.
Why it happens
- The variable was never added to your hosting provider (it only exists in your local .env).
- A test key in production, or a live key against test data.
- The key was rotated or revoked, and the host still has the old one.
- Stray quotes or spaces were pasted with the key.
How to fix it
- Check the variable exists in your host's production settings, then redeploy (new values apply on the next build).
- Match key and mode: sk_live_ with live data, sk_test_ with test data.
- Paste the key again without quotes or spaces.
Let your AI find the cause
Paste this into Claude Code, Cursor, Lovable or whichever AI built your app. It looks first and changes nothing until you have read the answer.
My live app fails with 'Invalid API key' for a service that works locally. Without changing anything yet, list every environment variable that service needs, where the code reads it, and which of them must also be set in my hosting provider.