$ ssh clawdbot.space --loading...
$ ssh clawdbot.space --loading...
Find out where the money is going, then cut the parts that cost you nothing to lose.
An agent bills differently from a chatbot: it re-sends accumulated context on every turn and it wakes itself up on a schedule. Both multiply, and neither is visible in a per-token price comparison. This guide is about finding which of the four drivers is dominating your bill before changing anything, because the fix that costs you the least capability is rarely the model swap people reach for first.
| Task | Model | Cost | Saving |
|---|---|---|---|
| Heartbeat/status checks | Gemini Flash | ~$0.001/call | 99% vs Opus |
| Simple formatting/summaries | Claude Haiku | ~$0.01/call | 95% vs Opus |
| Core agent tasks | Claude Sonnet | ~$0.05/call | 70% vs Opus |
| Complex reasoning only | Claude Opus | ~$0.15/call | Baseline |
# openclaw.config.yaml
models:
heartbeat: gemini-2.0-flash
simple: claude-haiku-4-20250514
default: claude-sonnet-4-20250514
complex: claude-opus-4-20250514
routing:
- match: "heartbeat|status|ping"
model: heartbeat
- match: "summarize|format|extract"
model: simple
- match: "analyze|decide|plan"
model: complex
- default: defaultSet max daily spend per provider. Agent pauses when limit hit.
openclaw config set limits.daily_usd 5.00Cap input+output tokens per API call to prevent bloat.
openclaw config set limits.max_tokens_per_call 4000Summarize old messages instead of keeping full history.
openclaw config set context.sliding_window 15Cache identical queries. Weather checks, status lookups, repeated questions. Saves 30-50% on routine tasks.
openclaw config set cache.enabled true openclaw config set cache.ttl 3600
Cache web scrapes and API responses. Don't re-fetch data that hasn't changed.
openclaw config set cache.skills true
Run Llama 3.1 8B locally for heartbeat/status tasks. Zero API cost.
ollama pull llama3.1:8b
openclaw config set agents.defaults.heartbeat.model ollama/llama3.1:8bLocal for simple tasks, cloud API for complex reasoning. Best cost/quality balance.
Opus for all, no limits, 100K context, no cache
Haiku for simple, Sonnet default, Opus for reasoning
Context pruned to 15K, per-call limits
Ollama heartbeats, response cache enabled
Cost discussions default to comparing per-token prices between providers, which is the least useful lever available. An agent differs from a chatbot in that it re-sends accumulated context on every turn and it wakes up on its own. Both of those multiply, and neither shows up in a price-per-million-tokens comparison.
| Driver | Why it compounds | Usual size of the win |
|---|---|---|
| Context length | Charged on every turn, and agent transcripts grow monotonically until something truncates them. | Large. Halving context roughly halves input cost across the board. |
| Heartbeats and cron jobs | Wake the agent when no human asked. A five-minute heartbeat is 288 turns a day that nobody reads. | Large, and frequently invisible until you look. |
| Retries after failed tool calls | A failing tool can loop, and each attempt carries the full context with it. | Spiky. Usually fine, occasionally the entire bill. |
| Model tier | The thing everyone tunes first. | Moderate, and it costs you capability. |
The ordering is the point. Switching to a cheaper model degrades every response; trimming context and removing a heartbeat you never wanted degrades nothing. Work top to bottom and you will usually find the bill drops enough that the model question stops being interesting.
Three commands tell you where you actually are. Changing settings before running them is how people end up with a slower agent and a bill that did not move.
# Find out what you are actually spending before changing anything. openclaw gateway usage-cost
This is the number the rest of the exercise is measured against. Write it down before you touch a setting, or you will not be able to tell whether anything you did helped.
# What is waking the agent when nobody asked it to? openclaw cron list openclaw config get agents.defaults.heartbeat
Scheduled jobs and heartbeats are the most common source of cost that nobody remembers configuring. Every entry here should be something you deliberately want.
# Which model is actually being used, and what are the fallbacks? openclaw models status openclaw models fallbacks
Fallbacks mean the model you configured may not be the model answering. A fallback to a more expensive tier during an outage is a legitimate and entirely invisible way to spend money.
Apply these in sequence and re-check usage after each one. Changing several things at once means you will not know which of them worked, and one of them is likely making the agent worse for no saving.
# 1. Context is charged on every turn. Trim what gets injected. # There is no single "context length" knob β these are the budgets # that decide how much is pushed into the prompt each time: openclaw config set agents.defaults.bootstrapTotalMaxChars 30000 openclaw config set agents.defaults.bootstrapMaxChars 10000 # Heartbeat runs can skip workspace bootstrap files entirely: openclaw config set agents.defaults.heartbeat.lightContext true
Start here. There is no single context-length dial; what you control is how much workspace material is pushed into the prompt, through the bootstrap character budgets. Cutting these also reduces the chance of the model losing the thread mid-transcript. Halve them, see whether anything breaks, and raise them back only where something does. lightContext on heartbeats is close to free money β those runs rarely need the workspace at all.
# 2. Route cheap turns to a cheap model instead of the default. openclaw models list openclaw models set <cheap-model-id>
Classification, routing and short acknowledgements do not need a frontier model. This is the point at which running something locally becomes attractive: the marginal cost of a local turn is electricity, which makes high-volume trivial work effectively free.
# 3. Cap the blast radius of a runaway loop. openclaw cron list # remove anything you did not deliberately add openclaw sessions cleanup # orphaned sessions still hold context
An unattended loop is the only failure mode here that can produce a genuinely alarming bill. Cron entries you did not add and orphaned sessions holding context are both worth clearing out on a schedule.