AI Brief Practical fixes, setup guides and tool comparisons
Troubleshooting

Gemini API 400 in n8n: GenerateContentRequest.model: unexpected model name format

Gemini API returns 400 INVALID_ARGUMENT with unexpected model name format in n8n? Here is what caused it in my workflow and how I fixed the model name in the URL.

Short answer: this 400 error means the model name inside the request URL is not a valid model code. In my case the URL still contained a placeholder text instead of a real model code. Put a real model code from Google documentation in the URL, run the node again, and the error goes away.

The error I saw

I called the Gemini API with an HTTP Request node in n8n. The node failed with this message:

Bad request - please check your parameters [item 0]
* GenerateContentRequest.model: unexpected model name format
httpCode: 400
Node: HTTP Request (typeVersion 4.2)
n8n: 2.8.3 (Self Hosted)

The raw response from the API had the same text:

{"error":{"code":400,"message":"* GenerateContentRequest.model: unexpected model name format\n","status":"INVALID_ARGUMENT"}}

What caused it in my case

The node sent a POST request to a URL of this form:

https://generativelanguage.googleapis.com/v1beta/models/<model-code>:generateContent

The workflow I had imported read the model code from a Config node. That value was still a placeholder, so the request URL looked like this:

https://generativelanguage.googleapis.com/v1beta/models/YOUR_GEMINI_MODEL:generateContent

Google answered with 400 INVALID_ARGUMENT because YOUR_GEMINI_MODEL is not a model code. Later, while I was editing the URL field, the expression that read the Config value turned into plain text. After that, changing the Config value no longer changed the URL, and the same error came back until I restored it.

How to fix it

  1. Open the model list in the Gemini API documentation and pick a model code. Model names change over time, so always copy the current one from that page. On October 7, 2026 the page I checked listed codes such as gemini-3.5-flash.
  2. Put the code into the URL, between models/ and :generateContent. Do not add spaces or quotation marks.
  3. If the URL reads the value from another node, keep the expression and change the value in that node. The example below the list shows an expression that reads the value from a node named Config.
  4. If the preview of the URL field still shows the old value, run the Config node again and check the preview once more.
  5. Execute the HTTP Request node again. A successful call returns a response with candidates instead of the 400 error.
https://generativelanguage.googleapis.com/v1beta/models/{{ $('Config').first().json.geminiModel }}:generateContent

After I fixed the model name, the same node finished successfully in my run (about 4 seconds), and the workflow continued to the next step.

What I did not test

  • Other malformed values, such as a second models/ prefix, an empty value or spaces
  • Other n8n versions than 2.8.3
  • The built-in Google Gemini node instead of an HTTP Request node
  • API key problems, which should produce a different error

Source

Updated: Oct 8, 2026