Error connecting to api

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.

here’s my index.js code!!!

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