i’m making this ai finance chatbot and i’m using gemini as the base but i couldn’t connect to the API the error on the terminal says ‘invalid api key’ but i’ve just ctrl+c ctrl+v the api key into my .env and the code is all correct but the only thing bugging this is the so called ‘invalid API key’ i’ve been debugging this myself for 2 weeks yet couldn’t find a solution
Hi @Put_Tiwutanon , Welcome to the forum!!!
Could you please share the portion of your index.js file where you’re loading and using the API key? This will help us check whether the environment variable is being accessed correctly and identify any issues in the setup. Thanks.
When using free tire API key for Gemini 3.Pro, tokens to connect API services with AI module server are limited…
but i’m using gemini 2.5 in my project and i’ve never actually successfully connected to the gemini API yet
Hi @Put_Tiwutanon ,
Thanks for sharing the screenshot. It appears that process.env.GEMINI_API_KEY is reading as undefined, which is likely causing the API to receive an empty request and reject it. Could you please check that your `.env` file is in the correct root directory and that the key inside it doesn’t have any extra spaces or quotes?

