Blog › Token saving, part 4
We audited mem0: Claude users pay full price for an 8,400-token prompt on every save
Every time mem0 saves a memory, it sends the model the same 8,400-token instruction prompt. OpenAI and Gemini cache that prompt on their own. Claude only caches when asked, and mem0 never asks, so Claude users pay full price for it on every save. One line per provider fixes it.
Part 4 of a series on spending less per token. Part 3 audited browser-use, part 2 GPT Researcher, and part 1 explains caching if you're new to it.
The project and how we checked it
mem0 is a memory layer for AI apps. You hand it a conversation with add(), an LLM pulls out the facts worth keeping, and later search() brings back the ones that matter. Many agents and assistants plug it in, so a cost leak in mem0 shows up on a lot of other people's bills.
We ran our free LLM cost audit skill on commit cae3d8c (27 November 2026), then read every flagged file and the whole add() pipeline by hand. We didn't run mem0; the numbers below are estimates, and we say what they rest on.
What it already does well
- One LLM call per save. The current pipeline extracts new memories in a single call. Older versions made a second call to decide what to update.
- A cache-friendly prompt layout. The big instruction prompt goes first as a fixed system message. Today's date, recent messages and custom instructions come after it, so they don't break the cached part.
- Batched embeddings and duplicate memories dropped by hash before anything is written.
- An output limit of 2,000 tokens by default. Our scanner flagged the calls for having no limit; that was wrong, because the limit is set in the shared config.
So the structure is right. The leak is a missing switch, and it only matters on Claude.
1. The extraction prompt is never cached on Claude
The system prompt for each save, ADDITIVE_EXTRACTION_PROMPT, is 33,653 characters: roughly 8,400 tokens. It is the same for every user and every save. That is exactly what prompt caching is for: after the first request, a cached copy is billed at a tenth of the input price.
| How you run mem0 | Prompt cached? |
|---|---|
| OpenAI or Azure OpenAI | Yes, automatically |
| Gemini | Yes, automatically |
Anthropic (provider: anthropic) | No |
| Claude on Amazon Bedrock | No |
| Claude through OpenRouter or LiteLLM | No |
Claude needs a cache_control marker on the part to cache (Bedrock calls it a cachePoint). None of mem0's LLM classes add one. The Anthropic class sends the system prompt as a plain string.
The fix in mem0 (llms/anthropic.py, generate_response)
params.update({
"model": self.config.model,
"messages": filtered_messages,
"system": [{"type": "text", "text": system_message,
"cache_control": {"type": "ephemeral"}}],
})
Because the prompt is identical for every user, one warm cache serves all your traffic. The cache lasts five minutes after its last use, so any app saving memories more often than that keeps it warm, and the one-off cost of writing it is negligible.
2. The default Claude model is a generation behind
If you don't pick a model, mem0 uses Claude Sonnet 4.6, at $3 input and $15 output per million tokens. Sonnet 5.5 is $2 and $10: a third cheaper and newer. On Bedrock the default is older still, Claude 3.5 Sonnet from June 2024. Set the model yourself:
Pick the model in your mem0 config
config = {"llm": {"provider": "anthropic",
"config": {"model": "claude-sonnet-5-5"}}}
Pulling facts out of a chat is a fairly simple job, so a smaller model may do it well too. Test that on your own conversations before switching, because missed memories cost more than tokens.
What it's worth
Our estimate for an app making 100,000 add() calls a month on Claude, at Anthropic list prices:
| Setup | Per month |
|---|---|
| Today: default Sonnet 4.6, no cache | $3,450 |
| Sonnet 4.6 with the cache | $1,182 −66% |
| Sonnet 5.5 with the cache | $704 −80% |
How we got these numbers: about 10,000 input tokens per save (the 8,400-token prompt plus up to 10 recent messages and 10 existing memories, estimated at 1,600 tokens) and an assumed 300 output tokens. 84% of input read from cache. List prices on 26 November 2026: Sonnet 4.6 $3 input, $0.30 cached, $15 output per million; Sonnet 5.5 $2, $0.10 and $10. Token counts are character estimates; Claude's tokenizer may count more. The dollars scale with your volume, so trust the percentages more.
3. A smaller one: the LLM reranker calls the model once per result
mem0 can rerank search results with an LLM. It's off unless you configure it, but when it's on it makes one model call per result, one after another. With the default of 20 results, that's up to 20 calls for every search, which adds latency as well as cost. Scoring all results in one call, or using one of mem0's non-LLM rerankers, avoids both.
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.00 and $10.00 from Anthropic, about 51% less than OpenRouter. mem0's Anthropic class accepts anthropic_base_url, so pointing it at SayGM's Anthropic-compatible endpoint takes one config line. 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 | 8,400-token extraction prompt never cached on Claude (Anthropic, Bedrock, OpenRouter, LiteLLM) | Add cache_control (or a Bedrock cachePoint) to the system prompt | One line per provider |
| 2 | Default Claude model is Sonnet 4.6; Bedrock default is Claude 3.5 Sonnet | Set model in your config | One line |
| 3 | Optional LLM reranker: one call per result, up to 20 per search | Score in one call, or use a non-LLM reranker | Moderate |
Check your own app for the same thing
- Look for a large prompt that never changes between requests. If you run Claude, it should carry a cache marker.
- Check
cache_read_input_tokensin your Anthropic usage. Zero on a fixed prompt means you're paying full price for it. - If a library picks the model for you, check which one and what it costs today.
Or let an agent do it: the LLM cost audit skill is free and runs locally.
Sources: mem0 on GitHub (commit cae3d8c), Anthropic prompt caching docs, Anthropic pricing, SayGM prices. We didn't run mem0; token counts are estimates.