#400 Error when using anything but gpt-4o-mini

1 messages · Page 1 of 1 (latest)

cedar aurora
#

Trying to switch between models. However, whenever I switch the default model to anything but 4o, it gives me the following error:

400 Provider returned error
{"message":"You invoked an unsupported model or your request did not allow prompt caching. See the documentation for more information."}

Trying to use anthropic/claude-3.5-sonnet.

Via Openrouter, Mac mini, Docker, Configured via dashboard Raw JSON.

Any idea how to solve this? Greatly appreciated 🙏

lean cedarBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

split geyserBOT
# cedar aurora Trying to switch between models. However, whenever I switch the default model to...

Two things to check here (this error message is almost always one of these):

1) Make sure you’re using the OpenRouter model ref (provider prefix)

In OpenClaw, model refs are always provider/model.

So if you want Claude via OpenRouter, it must be:

  • openrouter/anthropic/claude-3.5-sonnet

If you set:

  • anthropic/claude-3.5-sonnet

…that’s not OpenRouter anymore (it’s the native Anthropic provider), and OpenRouter-style model IDs can fail in weird ways.

Docs: https://docs.openclaw.ai/providers/openrouter

#

2) Disable prompt caching for that model (workaround for the 400)

That exact 400 commonly happens when the request includes prompt-caching directives but the route/model doesn’t support/allow it.

In your config (Raw JSON), add a per-model override to disable caching:

{
  agents: {
    defaults: {
      model: { primary: "openrouter/anthropic/claude-3.5-sonnet" },
      models: {
        "openrouter/anthropic/claude-3.5-sonnet": {
          params: { cacheRetention: "none" }
        }
      }
    }
#
  }
}

(If you already have agents.defaults.models, just merge that entry in—note that agents.defaults.models also acts as an allowlist.)

Anthropic prompt caching docs (OpenClaw side): https://docs.openclaw.ai/providers/anthropic#prompt-caching-anthropic-api


If it still fails after those two changes, paste:

  • your openclaw --version
  • the exact model string you set
  • and (redacted) the relevant agents.defaults.model + agents.defaults.models section

…and I can tell you whether it’s hitting Anthropic directly vs OpenRouter, or still sending caching knobs.

cedar aurora
#

Version: 2026.2.6

Model string paste:

    "defaults": {
      "model": {
        "primary": "openrouter/anthropic/claude-3.5-sonnet",
        "fallbacks": [
          "openrouter/openai/gpt-4o-mini"
        ]
      },
      "models": {
        "openrouter/anthropic/claude-3.5-sonnet": {
          "params": {
            "cacheRetention": "none"
          }
        },
        "openrouter/openai/gpt-4o-mini": {},
        "openrouter/openai/gpt-4o": {},
        "openrouter/meta-llama/llama-3.2-3b-instruct:free": {}```
split geyserBOT
# cedar aurora Version: 2026.2.6 Model string paste: ```"agents": { "defaults": { "m...

Short answer — it’s not a bug in OpenRouter: OpenClaw is automatically injecting an Anthropic-style cache_control breakpoint when you use the built-in openrouter provider for any model whose id starts with "anthropic/…". That causes OpenRouter → upstream Anthropic to receive a prompt-caching request. Claude 3.5 Sonnet (the 3.5 Sonnet builds you picked) does NOT support that caching breakpoint, so the upstream returns the 400:

"You invoked an unsupported model or your request did not allow prompt caching."

Why your config didn’t help

  • You set params.cacheRetention: "none" under the openrouter provider. The code that injects the OpenRouter/Anthropic cache_control only looks at model.provider === "openrouter" and model.id starting with "anthropic/…", and it unconditionally adds a cache_control { type: "ephemeral" } part. The params.cacheRetention handling only applies when the provider is the direct "anthropic" provider — not when you go via the openrouter provider — so your "none" setting has no effect.

What you can do (pick one)

  1. Easiest: stay on OpenRouter but use a Claude model that supports prompt caching
  • Set primary to an OpenRouter Anthropic model that supports caching (e.g. Claude Sonnet 4 / Sonnet 4.5 / Opus 4.x / Haiku 3.5 — see OpenRouter docs).
  • Example: change primary to "openrouter/anthropic/claude-sonnet-4" (or another supported instance).
  • No code change needed besides switching the model ref in your Dashboard JSON.
  1. Use the Anthropic provider directly (recommended if you need Sonnet 3.5)
  • Authenticate the Gateway to Anthropic (API key or setup-token) and use the direct provider ref "anthropic/claude-3.5-sonnet".
  • Then you can set params.cacheRetention:"none" and OpenClaw will not force the cache_control injection via OpenRouter.
#
  • Example config snippet (Dashboard raw JSON):
    {
    "agents": {
    "defaults": {
    "model": { "primary": "anthropic/claude-3.5-sonnet" },
    "models": {
    "anthropic/claude-3.5-sonnet": { "params": { "cacheRetention": "none" } }
    }
    }
    }
    }
  • To auth Anthropic on the gateway host:
    • For API key: set ANTHROPIC_API_KEY on the gateway host (or rerun onboarding): openclaw onboard --anthropic-api-key "$ANTHROPIC_API_KEY"
    • For Claude subscription setup-token: run on the gateway host: openclaw models auth setup-token --provider anthropic (or paste token with openclaw models auth paste-token --provider anthropic)
  • Restart gateway: openclaw gateway restart
  1. Workaround: add a custom OpenRouter provider alias (avoid the special-case injection)
#
  • Define a custom provider that points to OpenRouter but with a different provider name (so model.provider !== "openrouter") — OpenClaw’s injector only looks for provider === "openrouter".
  • Example minimal models.providers entry to add to your config (top-level models.providers):
    {
    "models": {
    "providers": {
    "openrouter-no-cache": {
    "baseUrl": "https://openrouter.ai/api/v1",
    "api": "openai-completions",
    "apiKey": "${OPENROUTER_API_KEY}",
    "models": [
    {
    "id": "anthropic/claude-3.5-sonnet",
    "name": "Claude 3.5 Sonnet (via OpenRouter no-cache)",
    "reasoning": false,
    "input": ["text"],
    "cost": { "input": 3, "output": 15, "cacheRead": 0, "cacheWrite": 0 },
    "contextWindow": 200000,
#

"maxTokens": 8192
}
]
}
}
}
}

  • Then set your agent primary to "openrouter-no-cache/anthropic/claude-3.5-sonnet". This uses OpenRouter but bypasses OpenClaw’s hardcoded cache_control injection.
  • Note: you still need your OPENROUTER_API_KEY available to the gateway (env or provider apiKey).

Which to pick?

  • If you want to keep using OpenRouter and don’t care about Sonnet 3.5 specifically, switch to a cache‑supported Claude model (Option 1).
  • If you need Sonnet 3.5 specifically, the safest is to authenticate Anthropic directly and use the direct provider (Option 2).
  • If you can’t/do not want to add Anthropic auth but still want Sonnet 3.5 via OpenRouter, use the custom-provider workaround (Option 3).

If you want, I can:

  • Prepare the exact JSON to paste into your Dashboard for Option 2 or 3.
#
  • Or I can verify your current raw JSON and point out the minimal edits to make and the commands to run to re-auth or restart. Which approach do you want to try?
cedar aurora
#

Lets use sonent 3.5 directly for now, help me set it up please. Paste the jason for option 2

split geyserBOT
# cedar aurora Lets use sonent 3.5 directly for now, help me set it up please. Paste the jason ...

Here’s the Option 2 JSON you can paste (direct Anthropic Sonnet 3.5, with your existing OpenRouter fallback kept):

{
agents: {
defaults: {
model: {
primary: "anthropic/claude-3.5-sonnet",
fallbacks: ["openrouter/openai/gpt-4o-mini"],
},

// Optional but recommended: explicitly disable Anthropic prompt caching for now
// (remove this block if you *want* caching)
models: {
"anthropic/claude-3.5-sonnet": {
params: { cacheRetention: "none" },
#
},

// keep your fallback listed so it shows up in the model allowlist/catalog
"openrouter/openai/gpt-4o-mini": {},
},
},
},
}

Critical next step (auth), otherwise you’ll get “No API key found for provider anthropic”

  • If using Anthropic API key: make sure the Gateway container has ANTHROPIC_API_KEY set (best via Docker/Compose env, not pasted into the dashboard).
  • If using Claude subscription (setup-token): run this on the gateway host/container:
  • openclaw models auth setup-token --provider anthropic

Then restart the gateway/container after changing config.