GoogleGenerativeAI Error [400 Bad Request]: contents.parts must not be empty

Describe the problem/error/question

I’m encountering an error in n8n when using my fine-tuned Gemini 1.5 flash model. Yesterday the setup was working perfectly, but today it’s throwing an error.

I’m also interested in integrating a Vertex AI fine-tuned Gemini 1.5 Pro model if that’s possible within n8n. Any information on that integration would be greatly appreciated.

What is the error message (if any)?

[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/tunedModels/finetunelinkedin-hve38iyfflh4:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.system_instruction.parts: contents.parts must not be empty.

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:

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 have the same issue. No clue how to fix it unfortunately.
Google searches tell me it may be a node version issue.

same here.

1 Like

you need change existing value to $fromAI like this {{ $fromAI(‘start_date’) }}

here’s an example from google calendar API

Hello,
The same issue occurred when I added the AI agent along with additional AI nodes.

Same issue here

bumping this

Any news on this? Is anyone also having troubles when calling tools with tools agent using Gemini?

Thanks.

same issue

1 Like

Anyone from the n8n team have any word on this? Gemini is a great model for n8n and would like to get it working. Currently as a workaround im using openrouter with gemini, which has been really good with testing. And still free

Hi,
I’ve fixed it by adding a node.js node before.

I’ve just took data from the previous nodes to exit the same data :wink: . Maybe not the best answer but it works fine.

1 Like

I also started having this same error today with Gemini 2.0-flash-lite, it just stopped working and throwing this error out of nothing. Plugin in 4o-mini it works with no problem

n8n 1.82.0
self hosted docker
windows 10

I had the same problem and found the solution:

Your tool nodes’ names must not use special characters (such as ‘_’)!

not helps in mys case (deletel _ in tools - still - contents.parts must not be empty.

Same. I have added a node code before AI Agent node (output and input are the same) and it fixed.

1 Like

I´ve exactly the same issue with Google Gemini on an AI Agent. Also without connected tools the same problem arise. When I use Gemini on a simple AI Chain it works…

Here´s the exception: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.0-pro:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.contents[1].parts: contents.parts must not be empty.

Maybe someone has another hint?

Best regards,
Michael

I found out that the reason for that seems to be a merge node before the agent node. As soon as I remove the merge node, also googles models work…

Hi Mike, I’m facing the same issue with Google Gemini on the AI Agent. I tried removing the Merge node before the AI Agent, but it didn’t help—the flow still gives the same error.