Skip to main content

Cost Management

OpenClaw's default configuration sends everything to one model, includes full conversation history, and heartbeats fire every 30 minutes. Without tuning, active use can cost $300-750/month. This guide covers what drives costs, how to control them, and real strategies that have achieved up to 97% cost reductions.

Real Horror Stories

These are documented incidents, not hypotheticals:

  • $3,600/month — Federico Viticci's "Navi" assistant consumed 180M Anthropic tokens in one month
  • $20 overnight — Benjamin De Kraker's heartbeat drained his entire balance checking "is it daytime yet?" every 30 minutes at $0.75/check
  • $200/day — An automated task stuck in an infinite loop, churning tokens while accomplishing nothing
  • $8 per 30 min — Processing Moltbook browsing content, adding up to $380+/day

Where Does the Money Go?

Cost Breakdown by Component

Heartbeat Costs

The heartbeat is the biggest silent cost driver. Each heartbeat sends the entire context window to the API:

ModelCost per Heartbeat (~120K tokens)Monthly (48/day)
Claude Opus 4.5~$0.75~$1,080
Claude Sonnet 4.5~$0.45~$648
Claude Haiku~$0.15~$216
Gemini 2.5 Flash~$0.05~$72
Gemini 2.5 Flash-Lite~$0.01~$14
Local (Ollama)$0.00$0

"Using Opus for a heartbeat is like hiring a lawyer to check your mailbox."

Context Accumulation

Every request sends the full conversation history. One user's session grew to 1.4 MB / 100K tokens of pure overhead. System prompts alone are 5,000-10,000 tokens and are resent with every API call.

What Causes Runaway Costs

CauseImpactExample
Infinite loopsTokens burn on repeated failuresTool validation fails, error appended to context, model retries endlessly
Context snowballCost per request grows over timeSession at 56-58% of 400K window means 200K+ cached tokens per query
Wrong model for task60x overpaymentOpus for heartbeat vs. Flash-Lite
Thinking mode10-50x token explosionExtended reasoning on simple tasks
No spending limitsUnpredictable billsOvernight drain with no caps configured
Large tool outputsMassive context per loop1M file paths sent with full history on every iteration

Optimization Strategies

1. Model Routing (Biggest Impact)

Use different models for different tasks. The cost difference between Opus and Flash-Lite is 60x.

Task TypeRecommended ModelCost/1M TokensNotes
Heartbeat checksGemini 2.5 Flash-Lite$0.50No quality difference for simple checks
Simple tasksGemini 3 Flash$0.15Quick lookups, status checks
Long contextKimi K2.5$0.50Large document handling
CodingGemini 3 Pro$1.25Mid-tier reasoning
Quick responsesClaude Haiku$1.00/$5.0090% of Sonnet quality at 1/3 price
Mid-tier generalClaude Sonnet$3.00/$15.00Good balance
Complex reasoningClaude Opus 4.5$5.00/$25.00Reserve for complex tasks only
Budget alternativeDeepSeek V3.2$0.5360x cheaper than Opus

Configure hybrid routing:

~/.openclaw/config.yml
brain:
provider: "anthropic"
model: "claude-sonnet-4"

# Use local model for heartbeat
heartbeat_override:
provider: "local"
local:
endpoint: "http://localhost:11434"
model: "qwen3:14b"
type: "ollama"

2. Context Window Management

StrategyHowImpact
Start fresh sessionsUse /new or /reset regularlyPrevents context snowball
Compact contextUse /compact to summarize old messagesFrees window space
Limit context sizeopenclaw config set max_context_tokens 8000Per-session cost dropped from $0.40 to $0.05
Limit response sizeopenclaw config set max_tokens_per_request 4000Prevents verbose responses
Daily auto-resetDefault 4:00 AM local timeCreates fresh session automatically

3. Heartbeat Tuning

Configure active hours to stop overnight token drain:

~/.openclaw/openclaw.json
{
"heartbeat": {
"every": "1h",
"activeHours": {
"start": "08:00",
"end": "22:00"
}
}
}
SettingCost Impact
Increase interval from 30m to 1h-50% heartbeat cost
Increase interval from 30m to 2h-75% heartbeat cost
Set active hours (14h/day vs 24h)-42% heartbeat cost
Use local model for heartbeat-100% heartbeat cost
Set to 0mDisables heartbeats entirely

4. Disable Thinking Mode for Routine Tasks

Thinking/reasoning mode can increase token usage by 10-50x. Disable it for routine tasks:

~/.config/openclaw/config.json5
{
"thinking": "disabled"
}

5. Leverage Prompt Caching

Anthropic prompt caching charges cache hits at only 10% of normal cost:

  • OpenClaw automatically applies cacheRetention: "short" (5-minute cache)
  • System prompts (5K-10K tokens) only charged once during cache validity
  • High-frequency users save 30-50% with caching
  • Extend with cacheRetention: "long" in model config

6. Use Existing Subscriptions (Zero Additional Cost)

If you already pay for a subscription, connect it to OpenClaw with no additional API costs:

SubscriptionMonthly CostHow to Connect
Claude Pro$20/monthAuthenticate via claude-cli
Claude Max$100/monthSame method, higher limits
ChatGPT Plus$20/monthConnect API key
Google One AI Premium$20/monthConnect API key

During onboarding, select "Anthropic" as your provider, then choose "Claude Code CLI" as the auth method to use your existing subscription.


Budget Controls

Set Spending Limits

# OpenClaw built-in limits
openclaw config set daily_budget_usd 5.00
openclaw config set monthly_budget_usd 50.00

Provider-Level Alerts

ProviderHowRecommendation
AnthropicDashboard spending alertsSet alerts at 50%, 75%, 90% of budget
OpenAIHard monthly spending capsConfigure directly in dashboard
OpenRouterBuilt-in spending trackingMonitor across all routed models

Model Failover Chain

~/.openclaw/openclaw.json
{
"models": {
"primary": "anthropic/claude-sonnet-4",
"fallback": "anthropic/claude-haiku",
"complex": "anthropic/claude-opus-4.5"
}
}

Real Cost Data

Monthly Spending by Usage Pattern

Usage PatternMonthly CostDescription
Free / Minimal$0-8Local models (Ollama) or existing subscription
Light / Casual$10-30Few commands per day, basic automation
Moderate$30-70Regular file tasks, research, moderate chat
Power User$70-200Constant automation, long sessions
Heavy / Always-On$300-750Full proactive assistant, multiple integrations
Enterprise / Opus$500-5,000Full-time Opus agent, heavy tool usage

The median: 90% of users spend under $12/day, and the average developer spends roughly $100-200/month.

Additional Costs

ComponentCostNotes
OpenClaw software$0MIT open source
Local hardware$0Your own machine
VPS hosting$5-20/monthOptional, for always-on
API keysVariableSee usage patterns above

The $1,200 to $36 Case Study

A documented case achieved a 97% cost reduction by combining five changes:

ChangeEffect
1. Local search (QMDskill with BM25 + vector)Token usage dropped 95%
2. Session context reduction (50KB to 8KB)Per-session cost: $0.40 to $0.05
3. Free web search via Exa AIEliminated paid search tokens
4. Automatic model routingRight model for each task
5. Local heartbeat handlingEliminated recurring paid heartbeats

These reductions compound multiplicatively — $1,200/month became $36/month.


Monitoring Tools

Built-in

CommandWhat It Shows
/statusAgent reachability, context usage, current model
/usage fullToken usage for every response

Third-Party Dashboards

ToolFeatures
ClawalyticsReal-time spending dashboard, per-agent breakdowns, daily cost charts, suspicious activity alerts
ClawWatcherReal-time token usage, cost per model, skills/actions tracking
claw-dashSessions, tokens (24h), costs, model info, cron jobs, system health gauges
openclaw-dashboardBrowser notifications for usage limits, cost analysis by model
OpenClaw Cost CalculatorPre-deployment cost estimation

OpenRouter Auto-Routing

For centralized model routing, OpenRouter can automatically select the most cost-effective model per prompt using openrouter/openrouter/auto — single API key for all providers with built-in cost tracking.


Quick-Start: Cut Costs Today

If you're spending too much right now, apply these changes immediately:

  1. Switch heartbeat to a cheap model — biggest single savings
  2. Set active hours — stop overnight token drain
  3. Set daily and monthly budget limits — prevent surprises
  4. Use /compact regularly — prevent context snowball
  5. Disable thinking mode for routine tasks
~/.openclaw/config.yml — Minimum cost configuration
brain:
provider: "anthropic"
model: "claude-sonnet-4"

heartbeat_override:
provider: "local"
local:
endpoint: "http://localhost:11434"
model: "llama3.1:8b"
type: "ollama"
~/.openclaw/openclaw.json — Budget limits
{
"heartbeat": {
"every": "1h",
"activeHours": {
"start": "08:00",
"end": "22:00"
}
}
}
openclaw config set daily_budget_usd 5.00
openclaw config set monthly_budget_usd 50.00

See Also