๐Ÿ“‰Cost Optimization

How to Set Up Token Budgets in OpenClaw

Beginner20-40 minutesUpdated 2025-01-15

OpenClaw ships with no default token limits, which means every conversation can use unlimited tokens and rack up unexpected API costs. This guide walks you through setting up global, per-conversation, and per-skill token budgets to control spending while maintaining a smooth user experience.

Why This Is Hard to Do Yourself

These are the common pitfalls that trip people up.

๐Ÿ’ธ

No default limits

OpenClaw ships with no token limits. Every conversation can use unlimited tokens.

๐Ÿค”

Unclear budget sizing

How many tokens does a typical conversation use? What's a reasonable daily limit? No guidance exists.

โš ๏ธ

Hard vs soft limits

Hard limits cut off mid-response. Soft limits warn but don't stop. Neither is obvious to configure.

Step-by-Step Guide

Step 1

Understand token costs

Learn what you're paying for.

# Rough token costs (per 1M tokens, as of 2025):
# Claude Opus:   $15 input / $75 output
# Claude Sonnet: $3 input  / $15 output
# Claude Haiku:  $0.25 input / $1.25 output
#
# A typical conversation: 2,000-10,000 tokens
# A complex task: 20,000-100,000 tokens
Step 2

Create the budgets config file

# Create config/budgets.yaml
mkdir -p ~/.openclaw/config
touch ~/.openclaw/config/budgets.yaml
Step 3

Configure global budgets

# In config/budgets.yaml:
global:
  daily_limit: 500000       # ~$7.50/day with Sonnet
  monthly_limit: 10000000   # ~$150/month with Sonnet
  warning_threshold: 0.8    # Warn at 80% of limit
  hard_limit_action: pause  # "pause" or "reject"
Step 4

Configure per-conversation limits

# In config/budgets.yaml (continued):
per_conversation:
  max_tokens: 50000
  warning_at: 40000
  on_limit: warn  # "warn", "pause", or "end"
  message: "This conversation is approaching its token limit."

Warning: Setting per-conversation limits too low (under 10,000) will cause conversations to feel cut short. Start with 50,000 and adjust based on your usage patterns.

Step 5

Verify budgets are active

# Restart OpenClaw to load new config
npm restart

# Check budget status
curl http://localhost:3000/api/budgets
# Should return current usage and limits

Need Help Sizing Your Budgets?

Getting token budgets right requires understanding your usage patterns. Our experts analyze your actual token consumption and configure optimal limits โ€” not too tight, not too loose.

Get matched with a specialist who can help.

Sign Up for Expert Help โ†’

Frequently Asked Questions