Does not works when in server application

Locally works fine and in the server not. It’s not be cause of the local of the server (Germany) because I tested the Gemini request Curl in the terminal and worked.

This is the log of this package

Server is running on port 3000 🚀
/app/node_modules/@google/generative-ai/dist/index.js:353
            throw new GoogleGenerativeAIFetchError(`Error fetching from ${url.toString()}: [${response.status} ${response.statusText}] ${message}`, response.status, response.statusText, errorDetails);
                  ^

GoogleGenerativeAIFetchError: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent: [403 Forbidden] 
    at _makeRequestInternal (/app/node_modules/@google/generative-ai/dist/index.js:353:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateCon
```tent (/app/node_modules/@google/generative-ai/dist/index.js:752:22) {
  status: 403,
  statusText: 'Forbidden',
  errorDetails: undefined
}

Node.js v18.20.2

The response of the raw request is this:

<title>Error 403 (Forbidden)!!1</title>
<p><b>403.</b> <ins>That’s an error.</ins></p>
<p>Your client does not have permission to get URL <code>/v1beta/models/gemini-1.5-flash:generateContent</code> from this server. <ins>That’s all we know.</ins></p>

My instance (working fine locally):

const aiModel = genAI.getGenerativeModel({
  model: 'gemini-1.5-flash',
  systemInstruction: CHAT_GPT_SYSTEM_PROMPT_MESSAGE,
});

No idea what is going on, I’ve been for a while on this.

Are you using the same API Key when you’re testing from the server in the console vs when the program runs? Are you sure they’re running on the same machine?

Although you insist otherwise - the most likely cause of this is that you’re using an API Key that is not attached to a billing account, so requests are forbidden since it comes from Germany.

I’m sure, and it has a billing account attached. But I already migrated the application to use ChatGPT. Thanks.