openclaw - 💡(How to fix) Fix bug(models): Missing google provider config silently routes Gemini requests to OpenAI

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…

When a Google Gemini model (e.g., gemini-3.5-flash) is added to agents.defaults.models or used in agents.defaults.model.fallbacks, but models.providers.google is omitted/empty in openclaw.json, OpenClaw's model resolution fails to throw a clean config validation error.

Instead, it falls back to the default provider adapter (which is OpenAI) and attempts to route the Gemini request—carrying the Google API key (AIzaSy...)—directly to OpenAI's endpoint!

This results in a highly confusing 401 error being logged and surfaced:

[agent/embedded] embedded run agent end: runId=... isError=true model=gemini-3.5-flash provider=google error=401 Incorrect API key provided: AIzaSyDp***************************Rojc. You can find your API key at https://platform.openai.com/account/api-keys.

Error Message

When a Google Gemini model (e.g., gemini-3.5-flash) is added to agents.defaults.models or used in agents.defaults.model.fallbacks, but models.providers.google is omitted/empty in openclaw.json, OpenClaw's model resolution fails to throw a clean config validation error. This results in a highly confusing 401 error being logged and surfaced: [agent/embedded] embedded run agent end: runId=... isError=true model=gemini-3.5-flash provider=google error=401 Incorrect API key provided: AIzaSyDp***************************Rojc. You can find your API key at https://platform.openai.com/account/api-keys. 4. Observe that the Google API key is sent to OpenAI, returning an OpenAI-specific 401 error. The model resolution or config validator should throw a clean, local configuration error (e.g. Google provider is not configured under models.providers) if a model prefix is matched to a provider that has no registered entry, instead of silently falling back to the OpenAI adapter and routing the payload there.

Root Cause

When a Google Gemini model (e.g., gemini-3.5-flash) is added to agents.defaults.models or used in agents.defaults.model.fallbacks, but models.providers.google is omitted/empty in openclaw.json, OpenClaw's model resolution fails to throw a clean config validation error.

Instead, it falls back to the default provider adapter (which is OpenAI) and attempts to route the Gemini request—carrying the Google API key (AIzaSy...)—directly to OpenAI's endpoint!

This results in a highly confusing 401 error being logged and surfaced:

[agent/embedded] embedded run agent end: runId=... isError=true model=gemini-3.5-flash provider=google error=401 Incorrect API key provided: AIzaSyDp***************************Rojc. You can find your API key at https://platform.openai.com/account/api-keys.

Code Example

[agent/embedded] embedded run agent end: runId=... isError=true model=gemini-3.5-flash provider=google error=401 Incorrect API key provided: AIzaSyDp***************************Rojc. You can find your API key at https://platform.openai.com/account/api-keys.
RAW_BUFFERClick to expand / collapse

Description

When a Google Gemini model (e.g., gemini-3.5-flash) is added to agents.defaults.models or used in agents.defaults.model.fallbacks, but models.providers.google is omitted/empty in openclaw.json, OpenClaw's model resolution fails to throw a clean config validation error.

Instead, it falls back to the default provider adapter (which is OpenAI) and attempts to route the Gemini request—carrying the Google API key (AIzaSy...)—directly to OpenAI's endpoint!

This results in a highly confusing 401 error being logged and surfaced:

[agent/embedded] embedded run agent end: runId=... isError=true model=gemini-3.5-flash provider=google error=401 Incorrect API key provided: AIzaSyDp***************************Rojc. You can find your API key at https://platform.openai.com/account/api-keys.

Steps to Reproduce

  1. Add google/gemini-3.5-flash to your fallbacks in openclaw.json.
  2. Leave models.providers.google completely undefined or empty in the config.
  3. Trigger a run that falls back to Gemini.
  4. Observe that the Google API key is sent to OpenAI, returning an OpenAI-specific 401 error.

Impact

  1. Confusing UX: The user is left wondering why their Google API key is being rejected by OpenAI's auth server, leading them to think their OpenAI settings are corrupted.
  2. Key exposure: Sending a Google API key to OpenAI's endpoint is a security/privacy leak that should be prevented.

Suggested Fix

The model resolution or config validator should throw a clean, local configuration error (e.g. Google provider is not configured under models.providers) if a model prefix is matched to a provider that has no registered entry, instead of silently falling back to the OpenAI adapter and routing the payload there.

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