openclaw - 💡(How to fix) Fix [Bug]: Google Generative AI 400 Error - All Models Failing [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#77940Fetched 2026-05-06 06:19:01
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Author
Timeline (top)
commented ×1labeled ×1

Error Message

  • ❌ No detailed error message in logs

Google Generative AI 400 Error - All Models Failing

All Google Generative AI models fail with generic 400 error, despite valid API key.

OpenClaw Error

"error": "Google Generative AI API error (400)", "rawErrorPreview": "Google Generative AI API error (400)",

Code Example

# Google Generative AI 400 Error - All Models Failing

## Environment
- **OpenClaw version:** 2026.5.3-1
- **OS:** Ubuntu 24
- **Provider:** Google AI Studio (Gemini API)

## Issue
All Google Generative AI models fail with generic 400 error, despite valid API key.

## Tested Models (all fail)
- `google/gemini-2.5-flash`
- `google/gemma-4-31b-it`

## API Key Verification
Key works perfectly when tested directly against Google's API:


curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
  -H 'Content-Type: application/json' \
  -H 'X-goog-api-key: [REDACTED]' \
  -X POST \
  -d '{"contents":[{"parts":[{"text":"Say hi"}]}]}'


**Response:**Success - returns valid JSON with "Hi there!"

## OpenClaw Error
Every attempt returns:

{
  "error": "Google Generative AI API error (400)",
  "rawErrorPreview": "Google Generative AI API error (400)",
  "model": "gemini-2.5-flash",
  "provider": "google"
}


## Configuration

**Auth profile exists:**

openclaw config get auth.profiles
# Output:
{
  "google:default": {
    "provider": "gemini",
    "mode": "api_key"
  }
}


**API key location:** `~/.openclaw/.env`
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Problem

  • ✅ API key is valid (proven by curl)
  • ✅ Models exist in Google's API
  • ✅ OpenClaw loads correct model config
  • ❌ All API calls fail with 400
  • ❌ No detailed error message in logs

Suspected cause: OpenClaw may be calling Google's API with incorrect request format or headers.

Steps to reproduce

NOT_ENOUGH_INFO

Expected behavior

NOT_ENOUGH_INFO

Actual behavior

NOT_ENOUGH_INFO

OpenClaw version

2026.5.3-1

Operating system

Ubunto 24

Install method

No response

Model

google/gemma-4-31b-it

Provider / routing chain

openclaw is on VPS, through TailScale into my laptop

Additional provider/model setup details

I have been connecting to Claude Models successfully with my Open Claw agent and I use telegram to instruct and communicate with the OpenClaw agent. I am trying to connect to a Gemma 4-31b-it model, through Google AI Studios, API Key and so far cant do it based on other information provided

Logs, screenshots, and evidence

# Google Generative AI 400 Error - All Models Failing

## Environment
- **OpenClaw version:** 2026.5.3-1
- **OS:** Ubuntu 24
- **Provider:** Google AI Studio (Gemini API)

## Issue
All Google Generative AI models fail with generic 400 error, despite valid API key.

## Tested Models (all fail)
- `google/gemini-2.5-flash`
- `google/gemma-4-31b-it`

## API Key Verification
Key works perfectly when tested directly against Google's API:


curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
  -H 'Content-Type: application/json' \
  -H 'X-goog-api-key: [REDACTED]' \
  -X POST \
  -d '{"contents":[{"parts":[{"text":"Say hi"}]}]}'


**Response:** ✅ Success - returns valid JSON with "Hi there!"

## OpenClaw Error
Every attempt returns:

{
  "error": "Google Generative AI API error (400)",
  "rawErrorPreview": "Google Generative AI API error (400)",
  "model": "gemini-2.5-flash",
  "provider": "google"
}


## Configuration

**Auth profile exists:**

openclaw config get auth.profiles
# Output:
{
  "google:default": {
    "provider": "gemini",
    "mode": "api_key"
  }
}


**API key location:** `~/.openclaw/.env`

Impact and severity

No response

Additional information

GEMINI_API_KEY=AIzaSy...

Gateway confirms correct model: [gateway] agent model: google/gemini-2.5-flash [gateway] ready

extent analysis

TL;DR

The most likely fix is to verify and adjust the request format and headers used by OpenClaw when calling Google's API.

Guidance

  • Review the OpenClaw configuration and code to ensure it is sending the correct request format and headers to Google's API, as the curl test with the same API key is successful.
  • Check the OpenClaw documentation and Google API documentation to confirm the required request format and headers for the Gemma 4-31b-it model.
  • Verify that the auth.profiles configuration in OpenClaw is correctly set up for the Google API key and provider.
  • Test the OpenClaw API calls with a tool like curl or a API debugging tool to inspect the request and response headers and body.

Example

No code snippet is provided as the issue does not contain enough information about the OpenClaw code or configuration.

Notes

The issue lacks detailed information about the OpenClaw configuration, code, and logs, making it difficult to provide a more specific solution. The curl test suggests that the API key is valid, but the OpenClaw API calls are failing with a 400 error.

Recommendation

Apply workaround: Verify and adjust the OpenClaw configuration and code to ensure it is sending the correct request format and headers to Google's API. This is because the curl test with the same API key is successful, suggesting that the issue is with the OpenClaw implementation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

NOT_ENOUGH_INFO

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: Google Generative AI 400 Error - All Models Failing [1 comments, 2 participants]