Blog › Token saving, part 3
We audited browser-use: Claude on OpenRouter or Bedrock pays full price for every step
browser-use is one of the most cost-aware agent codebases we have read. It still has one leak: run it on Claude through OpenRouter or Amazon Bedrock and every step pays full price for the whole history, screenshots included. Turning the cache on should cut that bill by more than half.
Part 3 of a series on spending less per token. Part 2 audited GPT Researcher; part 1 explains caching if you're new to it.
The project and how we checked it
browser-use lets an AI agent drive a real browser: it looks at the page (as text and as screenshots), writes a step of code, runs it, and repeats until the task is done. A single task can take dozens of steps, and every step sends the conversation so far back to the model. That makes the prompt cache the most important cost setting in the whole project.
We ran our free LLM cost audit skill on commit 94784c1 (24 November 2026). The scanner found almost nothing, because browser-use calls models through Pydantic AI rather than a provider SDK, so we read the agent loop and the model setup by hand, along with the Pydantic AI version it pins (2.66.0). We did not run the agent; the numbers below are estimates, and we say what they rest on.
What it already does well
- Screenshot pruning that keeps the cache intact. Old screenshots are dropped 18 at a time instead of one per step, so the cached prefix stays identical between prunes. A comment in the code explains why: pruning every step turned each request into a cache miss on their own benchmark.
- Caching switched on for Claude on the direct Anthropic API. Another comment records the old state: "cache_read was always 0".
- Compaction of long histories, on the server where the API supports it and with a summary elsewhere.
- The end-of-run judge reuses the cache by resending the run's last request instead of a fresh prompt.
This is careful work. The leak below is the kind that survives careful work, because it only shows up on routes the team doesn't use day to day.
1. Claude on OpenRouter or Bedrock never caches
When browser-use builds the agent, it asks for prompt caching in exactly one case: when the provider is anthropic. Claude reached any other way gets no cache setting:
| How you pass the model | Cache requested? |
|---|---|
llm='anthropic:claude-...' | Yes |
llm='openrouter:anthropic/claude-...' | No |
ChatOpenAI('anthropic/claude-...', base_url='https://openrouter.ai/api/v1') | No |
llm='bedrock:...claude...' | No |
That matters because Claude only caches when asked. OpenRouter's documentation says caching for Anthropic models needs cache_control breakpoints, while OpenAI models cache automatically. Bedrock's Converse API works the same way, with cachePoint blocks. Pydantic AI knows how to add both, but only when the cache setting is on.
So on those routes, every step re-bills the system prompt, the tool definitions, the whole history and up to 20 screenshots at the full input price. The project's own benchmark comment puts the average step at about 39,000 input tokens.
The fix in browser-use (agent/loop.py, build_agent)
name = model if isinstance(model, str) else getattr(model, 'model_name', '')
if system == 'anthropic' or (system in ('openrouter', 'bedrock') and 'claude' in name.lower()):
if 'cache' not in own:
settings['cache'] = True
The workaround today: pass the model with caching on
from pydantic_ai.models.openrouter import OpenRouterModel
agent = Agent(task=task, llm=OpenRouterModel('anthropic/claude-sonnet-5.5', settings={'cache': True}))
On Bedrock, the same works with BedrockConverseModel(..., settings={'cache': True}). Check that cache_read tokens show up in the usage after a few steps.
What it's worth
Our estimate for a team running 10,000 agent steps a month (about 500 tasks of 20 steps), Claude through OpenRouter, prices including its 5.5% card fee:
| Model | Today | With caching |
|---|---|---|
| Claude Sonnet 5.5 | $895 / month | $255 to $404 −55 to 72% |
| Claude Opus 5.5 | $1,789 / month | $509 to $808 −55 to 72% |
How we got these numbers: 39,400 input tokens per step (from the project's own benchmark comment: 27.8M input tokens over 705 steps) and an assumed 600 output tokens per step. 70% to 85% of each request's input read from cache, with the new part billed as a 1.25× cache write. Anthropic list prices on 26 November 2026: Sonnet 5.5 $2 input, $0.10 cached, $10 output per million; Opus 5.5 twice that. Step size depends heavily on the pages and on vision, so trust the percentage more than the dollars.
2. A smaller one: the judge runs after every task
By default, browser-use sends one more request after each run to judge whether the task succeeded. On cached routes that's cheap, because it reuses the run's prefix. On the uncached routes above it's billed in full, and if the cached judge fails, the fallback sends up to 120,000 characters of trace plus screenshots as a fresh prompt. If you never read result.judgement, pass judge=False.
Where the tokens are bought
Caching is the big lever here; the price per token is the second. SayGM lists Claude Sonnet 5.5 at $1.03 input and $5.15 output per million tokens, against $2.11 and $10.55 on OpenRouter with its fee, about 51% less. SayGM has an Anthropic-compatible endpoint, so you can pass a Pydantic AI AnthropicModel pointed at it and browser-use's built-in Anthropic path turns caching on by itself. On the same assumptions as above, the Sonnet example comes to roughly $124 to $197 a month. The usual caveat applies: on Claude the model maker still processes the prompt whichever gateway you use.
Disclosure: we earn a reward if you sign up to SayGM through our links. Your price is the same.
Summary
| # | Finding | Fix | Effort |
|---|---|---|---|
| 1 | Claude on OpenRouter or Bedrock: no prompt caching, every step at full price | Request cache for Claude on those routes, or pass the model with settings={'cache': True} | Five lines |
| 2 | Judge request after every run, billed in full on uncached routes | judge=False if you don't use it | One argument |
Check your own agent for the same thing
- Look at
cache_read(or your provider's equivalent) in your usage data. If it's zero on a model that should cache, nothing else on this list matters as much. - If you support several providers, check that the cache setting reaches every route to the same model, not just the one you test on.
- Count how many images ride along on each request, and whether dropping them rewrites earlier messages.
Or let an agent do it: the LLM cost audit skill is free and runs locally. This audit is another reminder that its scanner needs to recognise framework calls like Pydantic AI, not just provider SDKs.
Sources: browser-use on GitHub (commit 94784c1), Pydantic AI 2.66.0, OpenRouter prompt caching docs, SayGM prices. We didn't run the agent; token counts are estimates.