"Error communicating with Google AI Studio API"

Hi, I’m trying to get Gemini to work for chat completion, but the api just won’t respond. I am indeed from one of the regions listed here: Google AI Studio और Gemini API के लिए उपलब्ध जगहें  |  Google AI for Developers

here is the error message, is there something I’m missing?:

Error communicating with Google AI Studio API: FetchError: request to https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent?key=(key redacted) failed, reason: connect ETIMEDOUT (Ipv6 address redacted)
at ClientRequest. (file:///W:/Tavern_Silly/node_modules/node-fetch/src/index.js:108:11)
at ClientRequest.emit (node:events:536:35)
at emitErrorEvent (node:_http_client:104:11)
at TLSSocket.socketErrorListener (node:_http_client:512:5)
at TLSSocket.emit (node:events:524:28)
at emitErrorNT (node:internal/streams/destroy:170:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
type: ‘system’,
errno: ‘ETIMEDOUT’,
code: ‘ETIMEDOUT’,
erroredSysCall: ‘connect’

Hi there,

are you using vpn or proxy?
can you reproduce the same error if you try with your mobile?
(i would also doublecheck typos in endpoint or apikey)

Best regards

Nope, not using vpn, just my isp. I have tried deleting and getting new API key with same result. For the api key, I just use the blue copy button at the api key page and paste it in directly. I will say that for comparison I am also accessing Deepseek model via API and it works for me.

Is there a simple alternative chat completion program I can download to test my api key with?

Update for anyone else who has this problem: I don’t know why, but turning off IPV6 in network properties allowed the API to connect for me. Hope this helps!

1 Like