openclaw - 💡(How to fix) Fix Google provider: image/vision fails with 400 via OpenAI-compatible endpoint

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…

Root Cause

OpenClaw sends image requests through Google's OpenAI-compatible endpoint (/v1beta/openai/chat/completions), which doesn't properly handle image inputs.

Code Example

curl https://generativelanguage.googleapis.com/v1beta/openai/chat/completions   -H 'Authorization: Bearer KEY'   -d '{"model":"gemini-2.5-flash","messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":"data:image/jpeg;base64,..."}}]}]}'
# Returns 400 or empty response

---

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=KEY   -d '{"contents":[{"parts":[{"text":"Describe"},{"inlineData":{"mimeType":"image/jpeg","data":"..."}}]}]}'
# Works perfectly
RAW_BUFFERClick to expand / collapse

Bug

When using google/gemini-2.5-flash (or gemini-2.5-pro) as imageModel, the image tool returns 400 (no body).

Root Cause

OpenClaw sends image requests through Google's OpenAI-compatible endpoint (/v1beta/openai/chat/completions), which doesn't properly handle image inputs.

Evidence

OpenAI-compatible endpoint (BROKEN)

curl https://generativelanguage.googleapis.com/v1beta/openai/chat/completions   -H 'Authorization: Bearer KEY'   -d '{"model":"gemini-2.5-flash","messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":"data:image/jpeg;base64,..."}}]}]}'
# Returns 400 or empty response

Native endpoint (WORKS)

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=KEY   -d '{"contents":[{"parts":[{"text":"Describe"},{"inlineData":{"mimeType":"image/jpeg","data":"..."}}]}]}'
# Works perfectly

Environment

  • OpenClaw v2026.4.8 and v2026.4.15
  • Provider: google (OpenAI-completions API)
  • Models: gemini-2.5-flash, gemini-2.5-pro
  • Auth: API key (inline in provider config)

extent analysis

TL;DR

Use the native endpoint (/v1beta/models/{model}:generateContent) instead of the OpenAI-compatible endpoint (/v1beta/openai/chat/completions) for image requests with gemini-2.5-flash or gemini-2.5-pro models.

Guidance

  • Identify the endpoint used by OpenClaw for image requests and verify if it's the OpenAI-compatible endpoint.
  • Update the OpenClaw configuration to use the native endpoint for image requests with the specified models.
  • Test the updated configuration using the provided curl examples to ensure the native endpoint works as expected.
  • Consider adding model-specific endpoint handling in OpenClaw to accommodate different model requirements.

Example

# Updated curl example using the native endpoint
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=KEY \
  -d '{"contents":[{"parts":[{"text":"Describe"},{"inlineData":{"mimeType":"image/jpeg","data":"..."}}]}]}'

Notes

This solution assumes that the native endpoint supports all required features and functionality for the specified models. Additional testing and verification may be necessary to ensure compatibility.

Recommendation

Apply workaround: Use the native endpoint for image requests with gemini-2.5-flash and gemini-2.5-pro models, as it has been shown to work correctly in the provided examples.

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

openclaw - 💡(How to fix) Fix Google provider: image/vision fails with 400 via OpenAI-compatible endpoint