Google Gemini 2.0 Flash - EXP

Describe the problem/error/question: I always get the error message below as soon as I add the google sheet to my tools.

What is the error message (if any)? Error in sub-node ‘Google Gemini Chat Model‘[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties: should be non-empty for OBJECT type

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 copy and paste the workflow.)

{
  "nodes": [
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1O8KwKfEfsJqTc1viraYpRKXUgQ_pgM09FD1vbx9wVtg",
          "mode": "list",
          "cachedResultName": "Tax Senior 1/24",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1O8KwKfEfsJqTc1viraYpRKXUgQ_pgM09FD1vbx9wVtg/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Tax Senior",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1O8KwKfEfsJqTc1viraYpRKXUgQ_pgM09FD1vbx9wVtg/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        380,
        220
      ],
      "id": "3deef61f-27d1-499a-b2f3-9dc10044bf11",
      "name": "Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "RlCaOlzBnyYEiL1h",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "connections": {
    "Google Sheets": {
      "ai_tool": [
        []
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "0643254fd005f070c867d35e2279001046b1190311a66f1b2c5d9ba515984615"
  }
}

Share the output returned by the last node

Information on your n8n setup

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

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

i am having the same issue

1 Like

Me 3, im getting that this is an issue with Gemini and the way n8n handles function calling not being compatible atm.

1 Like

Same issue.
Running n8n locally and I did try all the Google Gemini Chat Models, none of them seem to work with the same message.

Runing latest .3 version, hoping for a resolution soon.

Did reattempt with a Basic LLM Chain, seems to work. As superfred mentioned, this is issue with the function calling, aka AI Agent using tools.

Same here, tool is not working with mistral, azure openapi (S0 pricing) as well

Same issue, not working for Agent. The problem was when I add a second property to the schema.

This was ok:

{
"type": "object",
"properties": {
	"id": {
		"type": "string",
		"description": "database id"
		}
	}
}

This not:

{
"type": "object",
"properties": {
	"id": {
		"type": "string",
		"description": "database id"
		},
  	"filter": {
		"type": "object",
		"description": "filter for querying Notion database pages, based on conditions"
		}
	}
}

@Jon Could the team have a look?

I found that with Google AI that if your tool doesn’t have a {{ $fromAI(“id”, “”) }} then it will fail, as soon as you put it in the tool will work.

1 Like

I have the same error message/problem when using AI Agent (Tools Agent) with Google Gemini Chat Model, co-operating with Vector Store Tool (with supabase db), no mater gemini-1.5-flash or 2.0-flash. It always shows Error in sub-node ‘Google Gemini Chat Model‘

[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.contents[2].parts: contents.parts must not be empty.

4 Likes

Where do we put this in? do you have an example? thankss!

1 Like

Any updates on how to solve this issue? Thanks

Hey @Andres_Rafael!

I’m having the same issue here too. The cause seems to be that, if you check the logs, you can see that the AI response is not being registered properly in the memory variables.

I’m trying to fix it through prompting. Have you already found a solution?

I FOUND A SOLUTION!

Gemini models tend to follow the system prompt very strictly, so you need to reinforce the use of n8n’s built-in format_final_response function to ensure it correctly stores the variables at the end.

Add this snippet in your chatInput and let me know the result → “REMEMBER TO ALWAYS USE format_final_response at the end of every response.”

openai works fine, google gemini does not work. it wont return data or anything no matter what you do.

Looks like others have similar problems see

Main problem I guess parsing the response from Gemini. In this example I was trying to get JSON format result. But Gemini returns with extra symbols and text. Check the topic for more detail. If you place JS code that parse the gemini response like this example, I can record every json data to google sheets with mapping.

If my reply solves your problem, please remember to mark it as a solution.

bad request here

3 Likes

:white_check_mark: I have found the SOLUTION!

:white_check_mark: I have found the SOLUTION!

After struggling with this issue, I finally figured it out! When you add a tool (like Google Docs) to your AI agent in n8n, the Google Gemini Chat Model requires at least one dynamic parameter to function properly. That means you need to define an input field using the $fromAI() function so that Gemini can dynamically generate values during execution.

But here’s the catch—tool naming matters a lot! If your tool’s name has spaces or special characters, Gemini won’t recognize it properly. It treats the tool as a function, and function names need to follow strict rules.

4 Likes

Hello,i am facing the same issue here ,cloud you plz tell me what you mean by “chatInput” ?