Features

Your OpenClaw Agent Is Burning Money on Heartbeats. Here Is How Smart Model Routing Fixes That.

Chris DiYanni·Founder & AI/ML Engineer·

Running OpenClaw in production?

Managed hosting with built-in AI agent security. 5-day free trial.

Your agent checks its inbox 48 times a day. Every check runs on Claude Opus 4.6. That is $4.70/day for "nothing new." Smart model routing fixes this at the config level, not the instruction level.

If you are running a self-hosted OpenClaw agent with a single model configured, every task your agent performs uses the same model: conversations, heartbeats, sub-agents, background checks. A Claude Opus heartbeat costs roughly $0.082 per cycle. A Claude Haiku heartbeat costs $0.004. Same result, 20x cheaper.

This is the single biggest cost optimization most OpenClaw operators miss. Not because the feature does not exist, but because it requires config-level routing, not prompt-level instructions.

The Problem: One Model for Everything

A typical self-hosted OpenClaw setup looks like this:

agents:
  defaults:
    model:
      primary: "anthropic/claude-opus-4-6"

That single line means every agent activity runs on Opus: your conversations, the 30-minute heartbeat checks, sub-agent coordination, memory synthesis. Opus is the right model for complex reasoning and conversations. It is the wrong model for "check inbox, nothing new, done."

The Real Cost of Unrouted Models

Task Frequency Cost on Opus Cost on Haiku Monthly Savings
Heartbeat checks 48x/day $0.082/cycle $0.004/cycle $112/mo
Sub-agent tasks 10-50x/day $0.05-0.15/task $0.002-0.008/task $40-130/mo
Memory synthesis 1x/day $0.20-0.50 $0.01-0.03 $6-14/mo

Total potential savings: $150-250/month per agent. For a single agent. Multiply by your fleet size.

The Solution: 3-Tier Model Routing

The fix is not telling your agent to use a cheaper model in its instructions. OpenClaw reads model assignments from its config file, not from markdown files. Adding "use Haiku for heartbeats" to HEARTBEAT.md does nothing.

Proper model routing requires three tiers in the OpenClaw config:

agents:
  defaults:
    model:
      primary: "anthropic/claude-opus-4-6"
      fallbacks:
        - "anthropic/claude-sonnet-4-6"
        - "anthropic/claude-haiku-4-5-20251001"
    heartbeat:
      every: "30m"
      model: "anthropic/claude-haiku-4-5-20251001"
    subagents:
      model: "anthropic/claude-haiku-4-5-20251001"
      maxConcurrent: 4

What Each Tier Does

Tier Config Key Used For Recommended Model
Primary model.primary Direct conversations, complex tasks Claude Opus 4.6 or Sonnet 4.6
Heartbeat heartbeat.model Periodic inbox/channel checks Claude Haiku 4.5 (cheapest reliable)
Sub-agents subagents.model Background tasks, file ops, coordination Claude Haiku 4.5 (cheapest reliable)
Fallbacks model.fallbacks Automatic failover on primary outage Sonnet 4.6 then Haiku 4.5

Why Instruction-Level Routing Does Not Work

This is the most common mistake. Operators add something like this to their agent's HEARTBEAT.md:

## Model Routing
- Switch to Haiku for this heartbeat check
- Only escalate to Opus if something needs action

This has zero effect. Here is why:

  • OpenClaw reads model assignments from the config file at startup. The heartbeat model is set in the JSON config, not in the agent's markdown instructions.
  • Mid-session model switching is blocked. OpenClaw restricts session_status(model=X) to the configured primary model. This is a security measure in OpenClaw itself that prevents prompt injection from downgrading to a weaker model.
  • The agent cannot override config-level settings. Even if the agent tried to switch models via an API call, OpenClaw would reject it.

The correct approach is always config-level: set heartbeat.model and subagents.model to your cheapest reliable model in the OpenClaw config file.

How ClawTrust Handles This Automatically

If you are using ClawTrust managed hosting, you do not need to touch any config files. Smart model routing is configured automatically for every agent from the moment it is provisioned.

Here is exactly what happens:

  1. You pick your primary model in the dashboard. This is the model for direct conversations. Pick the best model you can afford.
  2. ClawTrust generates a 3-tier config. The platform automatically sets heartbeat.model and subagents.model to the cheapest reliable model based on your connected providers.
  3. The config deploys to your agent's VPS. Every time you change your primary model, a config push updates the routing in seconds.
  4. Fallback chains are built automatically. Based on which providers you have connected (Anthropic, OpenAI, Google, MiniMax), ClawTrust builds the optimal fallback order.

Provider-Aware Cheap Model Selection

ClawTrust does not just pick Haiku every time. It selects the cheapest reliable model based on what you have connected:

Connected Provider Heartbeat Model Cost per Cycle
Anthropic (subscription or BYOK) Claude Haiku 4.5 ~$0.004
OpenAI BYOK GPT-4.1 Mini ~$0.003
Google AI BYOK Gemini 2.5 Flash ~$0.001
OpenRouter only (no BYOK) Claude Haiku 4.5 via OpenRouter ~$0.004

Bring Your Own Key: Insurance Against Budget Exhaustion

Every ClawTrust plan includes an AI budget via OpenRouter. When that budget runs out, your agent's fallback chain determines what happens next.

Without BYOK keys: the agent tries cheaper OpenRouter models until those also hit the budget limit, then stops responding until the next billing cycle or a manual top-up.

With BYOK keys: the fallback chain tries your own provider keys first. Since BYOK uses your own billing, there is no ClawTrust budget limit to hit. Your agent keeps running on your dime, but it keeps running.

This is why connecting a BYOK key is the single best thing you can do for agent reliability, even if you never select a BYOK model as your primary.

BYOK Security

Your API keys never touch the agent's VPS. They are encrypted in the ClawTrust database and decrypted only by a Cloudflare Worker proxy at request time. The agent authenticates with a platform token and sends requests through the proxy. Even a full server compromise cannot leak your API keys.

Supported providers: Anthropic (subscription or API key), OpenAI, Google AI, and MiniMax. Connect them in your agent's Integrations page.

The Fallback Chain: Zero-Downtime Model Failover

Model outages happen. Anthropic goes down, OpenRouter hits capacity limits, Google has a bad deploy. When your primary model fails, the fallback chain takes over automatically.

How the Chain Is Built

ClawTrust builds a custom fallback chain for each agent based on connected providers:

Anthropic subscription users:

Primary (your pick) → Claude Sonnet 4.6 → Claude Sonnet 4.5 → Claude Haiku 4.5

OpenRouter + BYOK users:

Primary (your pick) → BYOK fallbacks (Anthropic, OpenAI, Google if connected) → Claude Haiku 4.5 via OpenRouter → Llama 3.3 70B → Gemini 2.0 Flash

BYOK fallbacks are tried before OpenRouter models. This means if your OpenRouter budget is exhausted, the agent seamlessly falls back to your own provider keys without any interruption.

What ClawTrust Controls vs. What OpenClaw Controls

This is the part most people get confused about. ClawTrust is the managed hosting platform. OpenClaw is the open-source agent runtime. They each control different things.

ClawTrust (the platform)

  • Generates the 3-tier model config based on your primary model and connected providers
  • Validates model selection against the provider allowlist (dashboard only)
  • Deploys the config to your agent's VPS via secure config push
  • Encrypts and proxies BYOK API keys through a Cloudflare Worker
  • Sets heartbeat and sub-agent models to the cheapest available option
  • Does not restrict which models OpenClaw can use at runtime

OpenClaw (the agent runtime)

  • Reads the config file at startup and assigns models to each task tier
  • Routes heartbeats to the configured heartbeat model
  • Routes sub-agents to the configured sub-agent model
  • Uses the fallback chain when the primary model fails
  • Blocks mid-session model switching (security measure in OpenClaw, not a ClawTrust restriction)

If your agent tries to call session_status(model="claude-haiku") to switch models mid-conversation, OpenClaw will reject it. This is intentional. Mid-session switching is a security risk because prompt injection could downgrade the agent to a weaker, more manipulable model. The routing must happen at the config level, where it cannot be influenced by adversarial prompts.

Getting Started

If you are already on ClawTrust, smart model routing is already active. You can verify by checking your agent's config in the dashboard under Settings.

If you are self-hosting OpenClaw, add the heartbeat.model and subagents.model keys to your config file and restart your agent. The savings are immediate.

If you want all of this handled automatically, with BYOK support, encrypted key proxying, automatic fallback chains, and zero config management, start a free 5-day trial. Your agent will be provisioned with smart routing from minute one.

Read the full model routing documentation for technical details on provider selection, fallback chains, and BYOK security architecture.

Frequently Asked Questions

Can my OpenClaw agent switch AI models mid-conversation?

No. OpenClaw blocks mid-session model switching as a security measure. This prevents prompt injection attacks from downgrading your agent to a weaker, more exploitable model. The routing happens at the config level: your primary model handles conversations, while heartbeats and sub-agents automatically use the cheapest reliable model.

Does ClawTrust restrict which models my agent can use?

ClawTrust does not restrict runtime model usage. The model allowlist in the dashboard only validates what you can select as your primary model. Once deployed, OpenClaw handles all runtime behavior. Mid-session switching is blocked by OpenClaw itself, not ClawTrust.

How much does OpenClaw model routing save?

For an agent using Claude Opus 4.6 as primary, smart routing saves roughly 80% on background costs. Heartbeats drop from $0.082 to $0.004 per cycle (20x cheaper). Sub-agent tasks see similar savings. Direct conversations still use your full-power primary model.

Do I need to configure model routing in my agent's instructions?

No. Adding model routing instructions to HEARTBEAT.md, AGENTS.md, or any agent instruction file has no effect. OpenClaw reads the heartbeat and sub-agent model from its config file, not from the agent's markdown files. ClawTrust sets this config automatically when you pick your primary model.

What happens when my primary AI model has an outage?

ClawTrust configures an automatic fallback chain. For Anthropic subscription users: Sonnet 4.6, then Sonnet 4.5, then Haiku 4.5. For OpenRouter users: BYOK providers first (if connected), then Claude Haiku 4.5, Llama 3.3, Gemini 2.0 Flash. Failover is automatic with zero downtime.

Can I bring my own API keys for multiple providers?

Yes. ClawTrust supports Bring Your Own Key (BYOK) for Anthropic, OpenAI, Google AI, and MiniMax. Your keys are encrypted in the database and proxied through a Cloudflare Worker. The agent authenticates with a platform token and never sees your real API key.

What model does OpenClaw use for heartbeats?

ClawTrust automatically configures the cheapest reliable model for heartbeats. With Anthropic connected: Claude Haiku 4.5. With OpenAI BYOK: GPT-4.1 Mini. With Google BYOK: Gemini 2.5 Flash. With no BYOK keys: Claude Haiku 4.5 via OpenRouter. This is set at the platform config level and cannot be overridden by the agent.

Is there a free trial to test model routing?

Yes. ClawTrust offers a 5-day free trial on Starter and Pro plans. Your agent runs on a fully provisioned dedicated VPS with smart model routing active from minute one. The trial includes $5 in AI budget so you can see the routing in action.

Skip the setup.

Get your OpenClaw agent running in 5 minutes.

Start Free Trial →