In my case, the solution was to modify how the environment variables were handled. Locally, the key was set as an environment variable enclosed in double quotes, for example: key="example key" and everything worked fine. But then, when deployed to Vercel (production), it no longer worked and threw the error. Configuring the environment variables in production as: key=example key, without the double quotes, fixed the problem.