Google gemini bad request

when i use google gemini node, i show bad request. how to solve the issue?
Request failed with status code 400

Information on your n8n setup

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

Hey @tytom2003 the host looks fine! Could it be an issue with the API key ? Did you test it somewhere else than n8n?

i entered api key. it show bad request.

1 Like

same problem here

**n8n version: 1.85.4
**Database (default: SQLite): postgres
**n8n EXECUTIONS_PROCESS setting (default: own, main): default
**Running n8n via (Docker, npm, n8n cloud, desktop app): docker
**Operating system: debian 12 with all updates

i also tried it with a version from last month, same problem.

host:
PING generativelanguage.googleapis.com(fra24s05-in-x0a.1e100.net (2a00:1450:4001:828::200a)) 56 data bytes
64 bytes from fra24s05-in-x0a.1e100.net (2a00:1450:4001:828::200a): icmp_seq=1 ttl=60 time=3.75 ms

Container:
PING generativelanguage.googleapis.com (172.217.18.10): 56 data bytes
64 bytes from 172.217.18.10: seq=0 ttl=42 time=3.890 ms

→ the api is reachable

API key has been quadruple checked

I also tried using the api endpoint explicitly (/v1beta/models/gemini-2.0-flash), even that the documentation says, that this wouldnt work… and surprise, this doesnt work, too.

:confused:

I have same problem. The API key is worked fine. I tested with this

curl --location 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=zzzz' \
--header 'Content-Type: application/json' \
--data '{"contents": [{"parts":[{"text": "Write a story about a magic backpack."}]    }]   }'
1 Like

Tested my api key with your curl and its working but have the same problem in node:

{
“status”: “Error”,
“message”: “Bad Request”
}

The error is also very plain and i dont understand where to dig

As i read docs there is point to use Google ai studio key in node:
Google Gemini Chat Model ( Google Gemini(PaLM) credentials)

May be we need to use other type of api key? or more likely some code in node is broken or maybe crenedtials apply wrong way

n8n version 1.88.0 self hosted

1 Like

Hey guys,
I have same problem here and I reported this issue in github:

Bad request from create credential of Google Gemini(PaLM) Api account · Issue #15021 · n8n-io/n8n

It would be helpful if you could share your information to reproduce the issue. Most importantly, this lets the n8n team know that this is not a single case.

Thanks

1 Like

Same problem, the API key is fine

After the update to 1.9.53, the credencial screen do not connect to api anymore. Api key checked many times!

Had this same issue. Found out that it was because im self-hosting it on Hetzner (with server location in Europe) and Google is blocking the ip.

Two solutions to try:

  1. Move server to US vps.
  2. Use OpenRouter (Easiest and fast)