#I keep getting 404 errors when using a Google API key

1 messages · Page 1 of 1 (latest)

kindred hawk
#

LLM error: { "error": { "code": 400, "message": "Invalid JSON payload received. Unknown name "functionResponse" at 'contents[8].parts[0]': Cannot find field.\nInvalid JSON payload received. Unknown name "functionResponse" at '...

maiden lakeBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

magic sequoiaBOT
#

That Unknown name "functionResponse" at 'contents[...].parts[...]' error is coming from Google rejecting tool-call results in the request body.

In OpenClaw, when the model calls a tool, the next turn sends the tool result back as a Gemini functionResponse part. You’ll see this error when the endpoint you’re hitting doesn’t support that field — most commonly because you’re pointing at the wrong Gemini REST version (or a proxy) that only supports plain text parts.

What to check / fix

  1. Check if you overrode the Google base URL
  • If you have models.providers.google.baseUrl set to https://generativelanguage.googleapis.com/v1 → switch it to v1beta:
  • https://generativelanguage.googleapis.com/v1beta
  • Or simplest: remove your entire models.providers.google override and just use the built-in google provider with GEMINI_API_KEY.
  1. Make sure you’re using the Gemini API-key provider (google), not Vertex
  • google = Gemini API key (GEMINI_API_KEY)
  • google-vertex = Vertex AI (ADC / service account), different setup
  1. Restart the gateway after changes
#
openclaw gateway restart

Quick debug info that’ll confirm it fast

Paste these (redact keys):

openclaw --version
openclaw models status
openclaw config get agents.defaults.model
openclaw config get models.providers.google

The models.providers.google block is the big one—if it shows baseUrl: .../v1 (or some proxy URL), that’s almost certainly the cause.

kindred hawk
#

its not working, I changed the url to v1beta on the config file, should I just completely remove that section so it isn't in config json

magic sequoiaBOT
#

Yeah — unless you intentionally run Gemini through a custom proxy/base URL, you should delete the whole models.providers.google override (or at least delete the google: { ... } block).

OpenClaw already has a built-in google provider config for Gemini; you typically only need to supply the key (GEMINI_API_KEY). Your current error (Unknown name "functionResponse") is a strong hint you’re still hitting an endpoint/schema that isn’t the real Gemini Generative AI API (or the gateway is still using the old config).

Do this exact sequence:

  1. Remove models.providers.google from your config (so it falls back to the built-in provider).
  2. Put your key in one of these places:
  • GEMINI_API_KEY in ~/.openclaw/.env (common when running as a daemon/service), or
  • env: { GEMINI_API_KEY: "..." } in your openclaw.json
  1. Restart:
openclaw gateway restart
  1. Verify:
kindred hawk
#

it is still erroring

#

here is the log

#

Service: LaunchAgent (loaded)
File logs: /tmp/openclaw/openclaw-2026-02-27.log
Command: /opt/local/bin/node /opt/local/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Service file: ~/Library/LaunchAgents/ai.openclaw.gateway.plist
Service env: OPENCLAW_GATEWAY_PORT=18789

Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json

Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: running (pid 30137)
RPC probe: ok

Listening: 127.0.0.1:18789
Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting

magic sequoiaBOT
#

If it’s still throwing Unknown name "functionResponse" after you changed/removed the Google provider block, that basically means one of these is true:

  1. the Gateway is not using the config file you edited (super common: daemon/service uses a different config), or
  2. it’s still hitting a Gemini endpoint variant/proxy that doesn’t accept tool-result parts (e.g. the /openai compatibility route, or some proxy URL).

Can you paste the output of these (redact keys)? They’ll tell us which one it is immediately:

openclaw --version
openclaw gateway status --deep
openclaw config get models.providers.google
openclaw models status --json

What I’m looking for in those outputs:

  • In gateway status --deep: whether Config (cli) and Config (service) differ. If they differ, you edited the wrong one.
  • In models status --json: the actual baseUrl the running gateway is using for google. It must be the native Gemini API base URL (ends in /v1beta) and must NOT include /openai.
#

The snippet you pasted is gateway status (service healthy, config path matches) — good news, but it doesn’t include the actual Gemini request URL / provider config that’s causing functionResponse to be rejected.

Next step: we need to confirm what the running gateway thinks the google provider baseUrl + api are.

Please paste these outputs (redact keys/tokens):

openclaw config get agents.defaults.model
openclaw models status --json

If --json is huge, just search within it and paste the google part (baseUrl + api). Easiest:

openclaw models status --json | grep -n \"\\\"google\\\"\" -n | head -60
#

Also paste the actual error lines from the file log it pointed you to:

grep -n "functionResponse" /tmp/openclaw/openclaw-2026-02-27.log | tail -n 20
grep -n "Invalid JSON payload received" /tmp/openclaw/openclaw-2026-02-27.log | tail -n 20

What we’re trying to catch:

  • Is the baseUrl really https://generativelanguage.googleapis.com/v1beta (no /openai, no Vertex aiplatform.googleapis.com, no proxy)?
  • Is the provider api actually google-generative-ai (and not something mismatched)?
  • Sometimes the config edit is correct, but the gateway is still using an old generated models.json / cached provider entry — models status --json tells the truth.

Once you paste those, I can tell you exactly what to change (and where).

kindred hawk
#

d"}","1":"embedded run agent end: runId=172dfdb9-dfd3-421a-b97f-ca2d87ad16f9 isError=true error=LLM error: {\n "error": {\n "code": 400,\n "message": "Invalid JSON payload received. Unknown name \"functionResponse\" at 'contents[8].parts[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"functionResponse\" at 'contents[10].parts[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"systemInstruction\": Cannot find field.\nInvalid JSON payload received. Unknown name \"tools\": Cannot find field.",\n "status": "INVALID_ARGUMENT",\n "details": [\n {\n "@type": "type.googleapis.com/google.rpc.BadRequest",\n "fieldViolations": [\n {\n "field": "contents[8].parts[0]",\n "description": "Invalid JSON payload received. Unknown name \"functionResponse\" at 'contents[8].parts[0]': Cannot find field."\n },\n {\n "field": "contents[10].parts[0]",\n "description": "Invalid JSON payload received. Unknown name \"functionResponse\" at 'contents[10].parts[0]': Cannot find field."\n },\n {\n "description": "Invalid JSON payload received. Unknown name \"systemInstruction\": Cannot find field."\n },\n {\n "description": "Invalid JSON payload received. Unknown name \"tools\": Cannot find field."\n }\n ]\n }\n ]\n }\n}","_meta":{"runtime":"node","runtimeVersion":"22.22.0","hostname":"unknown","name":"{"subsystem":"agent/embedded"}","parentNames":["openclaw"],"date":"2026-02-27T05:10:39.290Z","logLevelId":4,"logLevelName":"WARN","path":{"fullFilePath":"file:///opt/local/lib/node_modules/openclaw/dist/subsystem-DypCPrmP.js:1170:14","fileName":"subsystem-

magic sequoiaBOT
#

That extra bit in the error (Unknown name "systemInstruction" + Unknown name "tools") is the giveaway: you’re still hitting a Gemini endpoint/schema that doesn’t support tool calling (that’s why it also rejects functionResponse).

Even if you changed/removed models.providers.google in ~/.openclaw/openclaw.json, OpenClaw writes/merges provider overrides into a generated models registry file, and removing the config section does not delete the old entry.

Fix (most common)

  1. Check if you have a stale Google provider in the generated registry:
ls -la ~/.openclaw/agents/main/agent/models.json
grep -n "generativelanguage\\|/v1\\b\\|v1beta\\|google" ~/.openclaw/agents/main/agent/models.json | head -60
  1. If you see Google pointing at /v1 (not /v1beta), either edit it or (simpler) move it aside so it gets regenerated:
mv ~/.openclaw/agents/main/agent/models.json ~/.openclaw/agents/main/agent/models.json.bak
openclaw gateway restart