openclaw - 💡(How to fix) Fix [Bug] 2026.5.7: OpenRouter provider prefix not stripped from API request body — every agent with openrouter/* primary 400's silently and falls to local fallback

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…

Error Message

OpenClaw 2026.5.7 sends the OpenClaw-internal provider-prefixed model id (openrouter/stepfun/step-3.5-flash) to the OpenRouter API. OpenRouter expects the bare model id (stepfun/step-3.5-flash) and returns HTTP 400. The error is surfaced in agent trajectories as: 5. Direct curl to https://openrouter.ai/api/v1/chat/completions with model: "stepfun/step-3.5-flash" and the same API key returns 200. With model: "openrouter/stepfun/step-3.5-flash" it returns 400 with the same error string. Confirms the prefix is being passed through to the API call body.

Root Cause

Routing the same logical model through LiteLLM works because litellm is OpenClaw's provider name and step-flash is the bare model alias inside LiteLLM's config — no prefix stripping required by OpenClaw, and LiteLLM's own routing handles the OpenRouter call cleanly with the correct bare slug.

Fix Action

Fix / Workaround

Workaround that works

Code Example

errorMessage: "400 openrouter/stepfun/step-3.5-flash is not a valid model ID"
provider: openrouter

---

{
  "model": {
    "primary": "litellm/step-flash",
    "fallbacks": ["llamacpp-bosgame/qwen3.5-122b"]
  }
}
RAW_BUFFERClick to expand / collapse

Symptom

OpenClaw 2026.5.7 sends the OpenClaw-internal provider-prefixed model id (openrouter/stepfun/step-3.5-flash) to the OpenRouter API. OpenRouter expects the bare model id (stepfun/step-3.5-flash) and returns HTTP 400. The error is surfaced in agent trajectories as:

errorMessage: "400 openrouter/stepfun/step-3.5-flash is not a valid model ID"
provider: openrouter

This affects every direct OpenRouter call from agents whose primary or fallback uses an openrouter/... model id. The session falls through to the next configured fallback and OpenClaw caches an auto override (modelOverrideSource: "auto") that locks the agent on the fallback for the rest of the session.

Reproduction

  1. Have an agent configured with model.primary: "openrouter/stepfun/step-3.5-flash" and any local fallback (e.g. llamacpp-bosgame/qwen3.5-122b).
  2. Provider config (top level or per-agent) for openrouter has correct baseUrl: "https://openrouter.ai/api/v1" and a valid OPENROUTER_API_KEY.
  3. Send a prompt to the agent.
  4. Observe: trajectory shows provider=openrouter, modelId=stepfun/step-3.5-flash for the attempt, then immediately a new session on the local fallback. Trajectory errorMessage (under data.messages[] and data.messagesSnapshot[]) shows "400 openrouter/stepfun/step-3.5-flash is not a valid model ID".
  5. Direct curl to https://openrouter.ai/api/v1/chat/completions with model: "stepfun/step-3.5-flash" and the same API key returns 200. With model: "openrouter/stepfun/step-3.5-flash" it returns 400 with the same error string. Confirms the prefix is being passed through to the API call body.

Expected

OpenClaw should strip the OpenClaw-internal provider prefix when constructing the API request body for an OpenAI-compatible provider, sending only the slug after the first / as the model parameter.

Actual

The full prefixed id is passed through to the API call. OpenRouter rejects it with 400.

Workaround that works

Routing the same logical model through LiteLLM works because litellm is OpenClaw's provider name and step-flash is the bare model alias inside LiteLLM's config — no prefix stripping required by OpenClaw, and LiteLLM's own routing handles the OpenRouter call cleanly with the correct bare slug.

{
  "model": {
    "primary": "litellm/step-flash",
    "fallbacks": ["llamacpp-bosgame/qwen3.5-122b"]
  }
}

Scope of impact on this fleet

20 agents on a single self-hosted fleet had at least one OpenRouter model in their primary or fallback list and were silently degrading to local fallbacks. Pipeline cost was lower than expected (cloud calls were 4xx'ing) but pipeline quality was lower than expected too. Bake-offs comparing cloud vs local quality may have been comparing local-vs-local without realizing it.

Related closed issues (possible regression)

  • #73014 — parseStaticModelRef strips provider prefix, breaks NVIDIA NIM (and OpenRouter-style ids) on direct invocation (closed 2026-05-01)
  • #50711 — Control UI model picker strips openrouter/ prefix from model IDs (closed)
  • #70572 — Session model pin stored without openrouter/ prefix — bare provider slugs persist across restarts and route to native plugins (closed)
  • #77234 — [cron] Model override rejected despite being in agents.defaults.models allowlist (provider prefix normalization mismatch) (closed 2026-05-07)

The earlier fixes appear to preserve the prefix in storage and resolution, but the runtime that builds the actual OpenAI-compatible API request body is no longer stripping it before transmission. This may be a regression introduced when one of the above was fixed.

Environment

  • OpenClaw 2026.5.7 (eeef486)
  • Node v22.22.1 on Linux 6.17.0-23-generic x64
  • Self-hosted gateway, no managed plugins on the affected agents
  • LiteLLM proxy (litellm/... provider) is unaffected

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 [Bug] 2026.5.7: OpenRouter provider prefix not stripped from API request body — every agent with openrouter/* primary 400's silently and falls to local fallback