Problem in node ‘AI Agent‘ - failed to fetch Google Gemini API

AI Agent node is using Gemini Chat Model but its not able to connect to Gemini API.

Running n8n from Docker. The Gemini API is whitelisted in my corporate proxy. I have verified the connectivity to Gemini through a curl command from the Linux VM and also from the n8n Docker container and it was successful.
I was able to successfully connect to Gemini API using HTTP request node. Only when I’m using Gemini Chat Model, its failing.

Even in Gemini Chat Model, I could see the models getting listed in the drop down. However when I try to send any message to the Gemini, its getting failed with below error

[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent: fetch failed

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to{
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.4,
      "position": [
        0,
        0
      ],
      "id": "183627e4-3c09-4445-8a39-3428063086ed",
      "name": "When chat message received",
      "webhookId": "82d96c60-519b-464c-a6ce-dce7046c2915"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        208,
        0
      ],
      "id": "1df4b91c-99b4-4fd0-9342-92ba9adc6fc8",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "modelName": "models/gemini-3-pro-preview",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        80,
        208
      ],
      "id": "c3f7f981-cd47-45d3-8563-c44a2d4d86ac",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "id": "jtmGuD2hLva7mJNZ",
          "name": "Google Gemini(PaLM) Api account"
        }
      }
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "889989dff0cc28a2a74fa69dc3303ab2c09b7734fbc341246a13aa5048f159c0"
  }
} 

Share the output returned by the last node

[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent: fetch failed

Information on your n8n setup

  • n8n version: 2.1.5
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: RHEL 7

Verified the Gemini APi connectivity from the container and its success.

Even the models are getting loaded

The same Gemini API is accessible from HTTP node

having similar issue since today!

Using AI Agent node, which is connected and authenticated to Gemini, used as its “brain”

Since today, all tiggered executions fail, specifically in Gemini node, see screenshot

Cannot read properties of undefined (reading ‘reduce’)

p.s.: the strangest thing is that it works when I trigger the same flow but manually instead of webhook trigger.

Note that it worked perfectly until today

That’s a weird issue if HTTP requests work but Chat Model fails - might be authentication headers differences or timeout settings. Have you checked the n8n logs for more detailed error messages?

Unrelated but on connectivity topic - been using FastVPN from https://fastvpn.com/mac-app/ on my Mac for work and it’s been really solid! Connection stays stable even during video calls, which is crucial for me. Speed is consistently good and I haven’t had any unexpected drops.

Really helpful for maintaining secure connections while working remotely. Your Docker networking might need similar stability checks - definitely look into container network settings!

I am seeing this error today too.