Keeping API Costs Under Control with Multiple OpenClaw Agents
The Question Everyone Asks
"Okay, multiple AI agents sound cool. But what does it actually cost?"
The honest answer: less than you think — if you build it right. More than necessary — if you don't.
Here are our real numbers and the decisions behind them.
---
Our Starting Point: 6 Agents, One Bill
We run 6 OpenClaw agents:
Each runs 24/7 on a Hetzner server. Our monthly Anthropic bill: under €500.
That sounds like a lot. Until you calculate what 40+ hours of manual work per week would otherwise cost.
---
Cost Driver #1: The Model
The biggest lever is model selection. The difference between Claude Opus and Claude Haiku isn't a small detail — it's a factor of 15 in price.
| Model | Input (1M tokens) | Output (1M tokens) |
|-----------------------------|-------------------|--------------------|
| claude-opus-4-5 | $15 | $75 |
| claude-sonnet-4-5 | $3 | $15 |
| claude-haiku-3-5 | $1 | $5 |
Choosing the right model for each agent is the most important cost control there is.
Our assignments:
Just through this differentiation, we save ~60% compared to "everyone on Opus."
---
Cost Driver #2: Heartbeat Frequency
OpenClaw can "wake" agents at regular intervals — the heartbeat system. By default, every 30 minutes.
Every heartbeat costs tokens. And when an agent performs unnecessary checks during a heartbeat — querying the email inbox, loading the calendar, starting a web search — it adds up.
What we optimized:
```
// HEARTBEAT.md for Alex (example)
Only act when:
```
Alex now responds to ~80% of all heartbeats with `HEARTBEAT_OK` — no tool call, minimal token consumption.
Rule of thumb: The clearer the conditions in HEARTBEAT.md, the fewer unnecessary actions.
---
Cost Driver #3: Cron Jobs vs. Heartbeats
Not every recurring task should run as a heartbeat. Cron jobs are often more efficient because:
1. They start isolated — no session history overhead
2. They can use an optimizable model (e.g., cheaper model for routine tasks)
3. They only run when there's actually something to do
Bad example (expensive):
Good example (cheap):
That's a 16x difference — for the same task.
---
Cost Driver #4: Context Windows and Session History
OpenClaw loads the session history on every turn. The longer a session, the more input tokens are sent with every turn.
Problem: Long-lived sessions get more expensive over time.
Our solution:
In OpenClaw, there's the `sessionTarget` field in cron jobs for this:
```json
{
"sessionTarget": "isolated",
"payload": {
"kind": "agentTurn",
"message": "Analyze the last 5 GitHub issues and summarize them."
}
}
```
`isolated` = no history overhead, cleaner result, cheaper execution.
---
Cost Driver #5: Tool Calls
Every tool call generates output tokens (for the function call itself) and input tokens (for the result that comes back). Web searches, email reads, file operations — everything has a price.
What helps:
---
Monitoring: What We Actually Track
The OpenClaw UI shows token consumption per session. Additionally we use:
1. Anthropic Console → daily token totals per API key
2. Weekly review → which agent got more expensive? Why?
3. Budget alerts set to daily limits in the Anthropic Console
When an agent suddenly consumes 3× more tokens than the previous week, that's a signal — often an infinite cron job loop, a forgotten tool-call chain, or an unexpectedly long session.
---
Our Cost Summary (Real Numbers)
| Agent | Model | Avg tokens/day | Avg cost/month |
|--------|---------|----------------|----------------|
| Sam | Sonnet | ~80,000 | ~€36 |
| Peter | Sonnet | ~60,000 | ~€27 |
| Maya | Sonnet | ~70,000 | ~€32 |
| Iris | Sonnet | ~90,000 | ~€40 |
| Alex | Haiku | ~50,000 | ~€5 |
| Atlas | Opus | ~30,000 | ~€68 |
Total: ~€208/month — plus server (Hetzner CX21: ~€6/month).
That's well under the €500 budget we set for ourselves. The buffer exists for weeks with more activity or when agents get larger tasks.
---
The Key Takeaways
1. Model selection is the biggest lever — Haiku where it's sufficient, Opus only where it counts
2. Define heartbeat conditions sharply — HEARTBEAT_OK costs almost nothing
3. Cron jobs for recurring tasks — isolated sessions are cheaper
4. Keep an eye on session history — long sessions get more expensive
5. Set up monitoring — budget alerts in the provider console
The detailed configuration — HEARTBEAT.md templates, cron job patterns, Docker Compose with model variables — is documented in the OpenClaw Setup Playbook. Including the monitoring setup we use for our weekly review.
Fully available in German too. 🇩🇪
Want to learn more?
Our playbook contains 18 detailed chapters — available in English and German.
Get the Playbook