← Back to Bot Resources

💰 Save Money on Your Bot

You're using my API keys. Let's not burn through them.

The Two Models

ModelAliasCost (in/out)Use For
Claude Opus 4opus$15 / $75Direct chat, complex reasoning
Claude Sonnet 4.5sonnet$3 / $15Cron jobs, reminders, simple tasks

Sonnet is 5x cheaper and handles 90% of background tasks just fine.

Step 1: Add Sonnet to Your Config

Patch your config to include both models with prompt caching:

{
  "agents": {
    "defaults": {
      "models": {
        "anthropic/claude-sonnet-4-5": {
          "alias": "sonnet",
          "params": { "cacheRetention": "long" }
        },
        "anthropic/claude-opus-4-6": {
          "alias": "opus",
          "params": { "cacheRetention": "long" }
        }
      },
      "model": {
        "primary": "anthropic/claude-sonnet-4-5",
        "fallbacks": ["anthropic/claude-opus-4-6"]
      }
    }
  }
}
⚠️ Model IDs must be exact. Use anthropic/claude-sonnet-4-5 (lowercase, hyphens). NOT Claude Sonnet 4.5 — that will break your bot completely.

How to Apply

Step 2: Set Cron Jobs to Sonnet

Every cron job with payload.kind: "agentTurn" accepts a model field:

{
  "payload": {
    "kind": "agentTurn",
    "message": "Your task here...",
    "model": "sonnet"
  }
}

Run on Sonnet

Keep on Opus

Step 3: Prompt Caching

The cacheRetention: "long" setting gives 1-hour prompt caching. System prompts (huge in OpenClaw) get cached instead of reprocessed every turn.

SettingDurationDefault?
"none"No caching
"short"5 minutesYes (API key)
"long"1 hourNo (enable it)

With "long" caching, you'll see cacheRead in token usage instead of input, at a 90% discount.

Step 4: Use Subagents on Sonnet

When spawning background tasks:

sessions_spawn(task="...", model="sonnet")

Runs the task on Sonnet in an isolated session. Great for research, summaries, and anything that doesn't need Opus.

Quick Checklist

Model ID Reference

Always use these exact strings. Typos will break your bot.

anthropic/claude-opus-4-6      (alias: opus)
anthropic/claude-sonnet-4-5    (alias: sonnet)
⚠️ Do NOT use: Claude Sonnet 4.5, claude-sonnet-4, anthropic/claude-sonnet-4, or any variation. Exact strings only.