OpenClaw Model Fallback Chain Guide: Rate Limits, Failover & Cost Optimization

· Updated

A well-designed fallback chain is OpenClaw’s core availability architecture. It keeps your agent seamlessly operational when Anthropic rate-limits you or OpenAI goes down — users never notice the switch.

The Core Principle

Fallback should optimize for availability first, then cost, then style consistency.

Practical Chain Design

Use cross-provider interleaving:

  1. Primary high-quality model (e.g., Claude Opus)
  2. Different provider, similar quality (e.g., GPT Codex)
  3. Cost-effective model (e.g., MiniMax M2.1)
  4. Fast-response model (e.g., Gemini Flash)
  5. Safety net (e.g., GLM)

This prevents provider-level incidents from taking down the whole chain.

Full Configuration Example

In ~/.openclaw/openclaw.json:

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-opus-4-6",
        "fallbacks": [
          "openai-codex/gpt-5.3-codex",
          "minimax-portal/MiniMax-M2.1",
          "google/gemini-3-pro-high",
          "google/gemini-3-flash",
          "zai/glm-4.7"
        ]
      }
    }
  }
}

Why this order? Opus → Codex switches providers to avoid rate-limit collision. MiniMax provides cost-effective fallback. Gemini ensures availability. GLM is the final safety net.

Operational Rules

Per-Task Model Overrides

OpenClaw supports model overrides per session or cron job:

Prompt Compatibility Tips

FAQ

Q: How do I tell if it’s a rate limit vs. a network issue? A: 429 returns a clear HTTP status code — logs show 429 Too Many Requests. Network issues show ETIMEOUT or ECONNREFUSED.

Q: Will falling back to weaker models hurt the experience? A: Brief fallbacks are usually invisible to users — most daily conversations work fine on Sonnet or Flash. Only complex reasoning and long tool-call chains show differences.

Q: How do I know which model is currently active? A: Run openclaw status to see the current session’s model, or check the logs for model selection events.

Bottom Line

A fallback chain is not cost optimization — it’s your uptime architecture. A well-configured chain is more reliable than any single top-tier model.

To apply this in production, pair this guide with:

Frequently Asked Questions

Why does OpenClaw need a fallback chain?

AI providers have rate limits, outages, and degraded service. A fallback chain keeps your agent operational automatically — users won't notice when one provider is down or rate-limited.

Should I put two Claude models back-to-back in my fallback chain?

No. If Anthropic returns a 429 rate limit, a second Claude model will hit the same limit. Always interleave providers: Anthropic → OpenAI → Google → other providers.

How do I configure model overrides for cron jobs?

Use the `model` parameter when spawning a sub-agent or cron session. Set cheaper models like `google/gemini-3-flash` or `minimax-portal/MiniMax-M2.1` for automation tasks that don't need top-tier reasoning.

Can I mix paid and free models in the same fallback chain?

Yes. Many chains use a top-tier paid model first, then fall back to cost-effective or free models when needed. This gives you quality when you need it and availability when you don't.

How do I know if a model switch happened?

Check OpenClaw logs for model selection events, or run `openclaw status` to see the current session's active model. Failed fallback attempts are logged with the provider error code.

Was this article helpful?

đź’¬ Comments