# OpenClaw Token Usage & Cost Control Guide

Track token usage, set budgets, and keep AI spending predictable.

## Why OpenClaw Costs Can Get Out of Hand

Agents become expensive with long prompts, large tool outputs, growing memory, browser actions, repeated calls. Cost depends on how the agent uses tokens during real workflows.

## What Is a Token?

- 1 token ≈ 4 English characters or 3/4 of a word
- 1,000 words ≈ 1,300 tokens
- Charged per million tokens (MTok)

```
1,000 input + 500 output = total billable tokens
```

## Input vs Output Tokens

- **Input:** prompt, system message, history, files, tool results, memory
- **Output:** model reply, reasoning, plans, summaries, code

In many APIs, output costs more than input.

## How OpenClaw Uses Tokens

| Source | Type | Why It Adds Up |
|--------|------|----------------|
| System prompts | Input | Sent every request |
| Conversation history | Input | Grows per message |
| Tool outputs | Input | Web/file dumps |
| Memory files | Input | Can bloat |
| Agent planning | Output | Multi-step is expensive |
| Final response | Output | Longer = more |
| Retries | Both | Failed tasks repeat |

## Why Costs Increase Quickly

- Long history sent every message
- Large browser/tool outputs
- Repeated failed retries
- Expensive default model
- Too many always-on workflows
- Large files in context
- No spending limits
- No model routing

Most cost problems come from small inefficient workflows running again and again.

## Token Cost Formula

```
Monthly cost =
(input tokens / 1M × input price) +
(output tokens / 1M × output price)
```

Example $3 input / $15 output model: 1M input = $3, 1M output = $15.

## Example Model Pricing

Prices change often. Always check provider pricing pages.

| Model Type | Input | Output | Best For |
|-----------|-------|--------|----------|
| Low-cost fast | Low | Low | Simple tasks |
| Mid-range | Medium | Medium | Daily workflows |
| Strong reasoning | Higher | Higher | Complex tasks |
| Large-context | Varies | Varies | Long documents |

## How to Check Token Usage

### OpenClaw CLI
```bash
openclaw models list
openclaw gateway status
openclaw logs --follow
```

Check help if commands vary: `openclaw --help`

### Provider Dashboards
OpenAI, Anthropic, Google Cloud, OpenRouter, Groq.

### Per-Agent Tracking
Separate API keys per workflow.

## Set Hard Spending Budgets

- Provider-level spending limits
- Soft alerts at 50% and 80%
- Prepaid credits where possible
- Disable unused keys

| Provider | Budget Control |
|----------|---------------|
| OpenAI | Usage limits, billing alerts |
| Anthropic | Monthly spend limits |
| Google | Cloud budget alerts |
| OpenRouter | Prepaid credits |
| Groq | Usage dashboard, account limits |

## Smart Monitoring

1. Daily usage check
2. Weekly cost review
3. Per-workflow API keys
4. Watch failed retries
5. Track output token growth

## Tactical Ways to Reduce Token Usage

- Shorten system prompts
- Keep SOUL.md, AGENTS.md, memory files clean
- Summarize old conversations
- Limit browser output
- Avoid pasting full documents
- Cheaper models for simple tasks
- Stronger models only for complex work
- Cap response length
- Fix failed retries
- Remove unused workflows
- Use prompt caching when supported

## Model Routing

| Workflow | Recommended Model |
|----------|-------------------|
| Reminders | Cheap fast model |
| Short summaries | Low-cost or mid-range |
| Coding | Strong reasoning |
| Research | Large-context |
| Browser automation | Reliable tool-calling |
| Final review | Stronger only when needed |

Do not use your most expensive model for every task. That is billing self-harm.

## Token-Based vs Flat-Rate

| Usage | Pay-Per-Token | Flat-Rate |
|-------|---------------|-----------|
| Light | Often cheaper | May be unnecessary |
| Medium | Unpredictable | Easier to budget |
| Heavy | Expensive | More predictable |
| Multiple workflows | Hard to track | Easier to manage |
| Business | Can spike | Better cost planning |

## When Flat-Rate Makes Sense

Use Ampere.sh for: predictable monthly cost, managed hosting, less tracking, less maintenance, always-on workflows, easier setup.

## Warning Signs

- Daily usage doubled suddenly
- One workflow uses most tokens
- Output tokens consistently high
- History too large
- Browser pulls huge pages
- Repeated failed retries
- Rate limits often
- Bill rising without new workflows
- Expensive default model

## Quick Reference

```bash
openclaw models list
openclaw gateway status
openclaw logs --follow
openclaw --help
openclaw models --help
openclaw gateway --help
```

## Final Recommendation

- Track tokens early
- Set hard provider budgets
- Cheaper models by default
- Route expensive models to complex work only
- Clean memory and prompts
- Watch tool outputs and retries
- Use Ampere.sh for predictable hosting

## FAQ

**Token usage in OpenClaw?**
Amount of text agent sends/receives from API. Counts prompts, responses, tool outputs, memory.

**Check usage?**
openclaw models list, gateway status, logs --follow. Provider dashboards for detail.

**Bill higher than expected?**
Long history, large tool outputs, failed retries, expensive default model, hidden workflows.

**Input vs output?**
Input is what you send. Output is what model generates. Output often costs more.

**Daily cost?**
Few dollars/mo for light personal smart routing. Hundreds for heavy unoptimized. $39 Ampere.sh flat.

**Reduce costs?**
Shorten prompts, summarize conversations, limit tools, cheaper models, fix retries, caching.

**Set budget?**
Provider-level hard limits + alerts.

**Track per agent?**
Yes - separate API keys per workflow.

**Browser tools cost more?**
Significantly - can pull tens of thousands of tokens per page.

**Does Ampere.sh help?**
Yes - $39 flat, pooled access, smart routing, predictable cost.

---

Predictable costs: https://www.ampere.sh/setup
