openclaw - 💡(How to fix) Fix Gemini 2.5 Flash returns 400 via OpenClaw, works via direct curl [2 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#61364Fetched 2026-04-08 02:59:26
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
commented ×2mentioned ×1subscribed ×1

Gemini 2.5 Flash (google/gemini-2.5-flash) returns HTTP 400 errors when called through OpenClaw's model routing, but works correctly when called directly via curl to the Google Generative AI API with the same API key.

Error Message

  1. Agent receives 400 error from the API

Root Cause

Gemini 2.5 Flash (google/gemini-2.5-flash) returns HTTP 400 errors when called through OpenClaw's model routing, but works correctly when called directly via curl to the Google Generative AI API with the same API key.

Fix Action

Workaround

Using anthropic/claude-3-5-haiku-20241022 as Researcher model instead of Gemini Flash.

Code Example

{
  "models": {
    "providers": {
      "google": {
        "baseUrl": "https://generativelanguage.googleapis.com/v1beta/openai",
        "apiKey": "<GOOGLE_API_KEY>",
        "api": "openai-completions",
        "models": [{
          "id": "gemini-2.5-flash",
          "name": "Gemini 2.5 Flash",
          "reasoning": false,
          "input": ["text"],
          "contextWindow": 1048576,
          "maxTokens": 8192
        }]
      }
    }
  }
}

---

curl -s "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions" \
  -H "Authorization: Bearer $GOOGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gemini-2.5-flash","messages":[{"role":"user","content":"Hello"}]}'
RAW_BUFFERClick to expand / collapse

Version: OpenClaw 2026.3.27 (initially discovered), persists in 2026.4.4 OS: macOS (Darwin 25.4.0, arm64, M4 Mac mini) Node: v25.8.2

Summary

Gemini 2.5 Flash (google/gemini-2.5-flash) returns HTTP 400 errors when called through OpenClaw's model routing, but works correctly when called directly via curl to the Google Generative AI API with the same API key.

Configuration

{
  "models": {
    "providers": {
      "google": {
        "baseUrl": "https://generativelanguage.googleapis.com/v1beta/openai",
        "apiKey": "<GOOGLE_API_KEY>",
        "api": "openai-completions",
        "models": [{
          "id": "gemini-2.5-flash",
          "name": "Gemini 2.5 Flash",
          "reasoning": false,
          "input": ["text"],
          "contextWindow": 1048576,
          "maxTokens": 8192
        }]
      }
    }
  }
}

Steps to Reproduce

  1. Configure Google provider as above in openclaw.json
  2. Spawn a sub-agent with model: "google/gemini-2.5-flash"
  3. Agent receives 400 error from the API

Direct API call works

curl -s "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions" \
  -H "Authorization: Bearer $GOOGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gemini-2.5-flash","messages":[{"role":"user","content":"Hello"}]}'

→ Returns valid response

Workaround

Using anthropic/claude-3-5-haiku-20241022 as Researcher model instead of Gemini Flash.

Expected Behavior

Gemini Flash should work through OpenClaw's model routing the same way it works via direct API calls.

extent analysis

TL;DR

Verify the request payload and headers sent by OpenClaw's model routing to ensure they match the working curl request.

Guidance

  • Compare the API request headers and payload sent by OpenClaw with the curl command to identify any discrepancies.
  • Check the Content-Type header and the JSON payload structure to ensure they are correctly formatted.
  • Validate the Authorization header to confirm the API key is being passed correctly.
  • Test the API call with a minimal payload to isolate the issue.

Example

No code example is provided as the issue does not imply a specific code change.

Notes

The root cause of the issue is likely related to the differences in the request sent by OpenClaw's model routing and the curl command. Identifying and addressing these differences should resolve the issue.

Recommendation

Apply workaround: Use the anthropic/claude-3-5-haiku-20241022 model as a temporary replacement until the issue with Gemini Flash is resolved, as it has been confirmed to work through OpenClaw's model routing.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING