Why Your OpenClaw Bot Might Be Burning Through Tokens
If you've been running an OpenClaw bot for a few weeks, you've probably noticed that API costs can add up faster than expected. A casual personal assistant might cost $5-10/month, but a heavily-used bot with long conversations and expensive models can easily hit $50-100/month or more.
The good news: most of that spend is unnecessary. With the right configuration and model choices, you can cut your token costs by 60-80% while maintaining — and sometimes even improving — the quality of your bot's responses.
I've spent months optimizing OpenClaw configurations for cost efficiency, and these are the strategies that actually work.
Strategy 1: Choose the Right Model for the Job
This is the single biggest lever you have. The difference in cost between models is staggering:
- Claude Opus 4.6: ~$15 per million input tokens, ~$75 per million output tokens
- GPT-5.2: ~$10 per million input tokens, ~$30 per million output tokens
- Claude Sonnet 4.6: ~$3 per million input tokens, ~$15 per million output tokens
- Gemini 2.5 Flash: ~$0.15 per million input tokens, ~$0.60 per million output tokens
- DeepSeek V3.2: ~$0.27 per million input tokens, ~$1.10 per million output tokens
That's roughly a 100x cost difference between the most expensive and cheapest options. And here's the thing that surprises most people: for many common tasks, the cheaper models perform nearly as well as the premium ones.
When to Use Cheap Models
For the vast majority of everyday tasks, a model like Gemini 2.5 Flash or DeepSeek V3.2 is more than capable:
- Answering factual questions
- Summarizing text
- Basic writing and editing
- Simple code generation
- Translation
- Casual conversation
When to Use Premium Models
Save the expensive models for tasks where the quality difference actually matters:
- Complex reasoning and analysis
- Long-form creative writing where nuance matters
- Difficult coding tasks (architecture decisions, debugging complex issues)
- Tasks requiring very precise instruction following
How to Switch in OpenClaw
In your OpenClaw configuration, the model is set under agents.defaults.model.primary. You can change it anytime without restarting your bot — OpenClaw hot-reloads model configuration. On OpenClaw Launch, you can switch models from the dashboard with a single click.
Strategy 2: Manage Your Context Window
Every time your bot responds, it sends the entire conversation history to the AI model. A conversation that's been going for 50 messages might be sending 10,000+ tokens of context with every single reply. You're paying for all of that, every time.
Set a Conversation History Limit
Most bots don't need to remember the entire conversation. Set a reasonable history limit — 10-20 messages is enough for most use cases. In OpenClaw, you can configure this with the session settings:
{
"agents": {
"defaults": {
"maxHistoryMessages": 20
}
}
}
This alone can reduce your costs by 30-50% for long-running conversations.
Use Session Isolation
If your bot serves multiple users, make sure sessions are isolated per user with session.dmScope: "per-channel-peer". Without this, all users share the same context, which means you're paying for everyone's messages in every request.
Keep System Prompts Concise
Your system prompt is sent with every single API call. A 2,000-token system prompt costs you 2,000 extra input tokens on every message. Write tight, focused system prompts. Cut the fluff. Every word in your system prompt has a recurring cost.
Bad example (500+ tokens):
You are a helpful, friendly, and knowledgeable AI assistant named BotBuddy.
You were created to help users with a wide variety of tasks including but
not limited to answering questions, writing content, providing advice...
[three more paragraphs of generic instructions]
Good example (80 tokens):
You are a concise technical assistant. Answer questions directly.
Use code blocks for code. If unsure, say so. Keep responses under
200 words unless asked for more detail.
Strategy 3: Use Free-Tier Models Strategically
Several model providers offer free tiers through OpenRouter that are genuinely good enough for many tasks:
- Gemini 2.5 Flash — Google's fast model has a generous free tier on OpenRouter. Excellent for general-purpose tasks.
- DeepSeek V3.2 — very cost-effective, sometimes available with promotional free credits.
- Qwen 3 series — Alibaba's models offer competitive quality at very low costs.
You can start with a free-tier model and only upgrade when you hit its limitations. Many users find they never need to.
Strategy 4: Optimize Skill Usage
OpenClaw skills (web browsing, code execution, file management) are powerful but can dramatically increase token consumption. Every skill invocation adds tool descriptions to the context and generates additional API calls for the model to process the results.
Only Enable Skills You Actually Use
If your bot is a simple Q&A assistant, it doesn't need web browsing, code execution, or file management skills enabled. Each enabled skill adds token overhead to every single message, even when the skill isn't being used, because the model needs to see the tool descriptions to decide whether to use them.
Disable skills you don't need. You can always re-enable them later.
Set Skill Budgets
For skills like web browsing, consider how many pages your bot really needs to fetch per conversation. A bot that fetches 10 web pages to answer a simple question is wasting tokens. Configure reasonable limits on skill usage.
Strategy 5: Monitor and Set Spending Limits
You can't optimize what you can't measure. Most API providers (OpenRouter, OpenAI, Anthropic) offer usage dashboards and spending alerts.
- Set a monthly budget on your API key. OpenRouter lets you set hard limits that stop requests when exceeded.
- Check usage weekly. Look for unexpected spikes that might indicate runaway conversations or misbehaving skills.
- Use OpenRouter's per-key limits if you're running multiple bots — give each bot its own key with its own budget.
Strategy 6: Caching and Response Optimization
Some advanced strategies can further reduce costs:
- Prompt caching — Anthropic and Google offer prompt caching that can reduce costs by 90% for repeated system prompts. If your system prompt is the same across all conversations (which it usually is), cached tokens cost a fraction of regular tokens.
- Max token limits — set
maxTokenson your model configuration to prevent unexpectedly long responses. A 4,000-token response costs 4x as much as a 1,000-token one. For most assistant tasks, 1,000-2,000 tokens is plenty. - Temperature settings — lower temperature (0.3-0.5) tends to produce shorter, more focused responses compared to higher temperature (0.8-1.0) which can be more verbose.
Real-World Cost Examples
To put this in perspective, here's what typical monthly costs look like with different configurations:
- Unoptimized (Claude Opus, unlimited history, all skills enabled, verbose system prompt): $40-80/month for moderate usage
- Partially optimized (Claude Sonnet, 20-message history, selective skills): $10-20/month
- Fully optimized (Gemini Flash, 15-message history, minimal skills, concise prompts): $2-5/month
That's the 80% cost reduction in action. And honestly, option three is good enough for most personal assistant use cases.
Try It Without the Hassle
OpenClaw Launch ships with optimized default configurations that implement many of these strategies out of the box. You can tweak model selection, history limits, and skill settings directly from the dashboard without editing JSON files. Plans start at $3/month — which, combined with a cost-efficient model, means you can run a capable AI assistant for under $10/month total.
The most expensive part of running an AI bot shouldn't be the bot itself — it should be the amazing things you build with it.