OpenRouter tests RAG vs CAG accuracy and cost at three document scales
RAG vs CAG: We Measured Accuracy and Cost at 3 Sizes
OpenRouter tested RAG and CAG on 9K, 66K, and 330K-token corpora using 40 questions.
OpenRouter compares the accuracy and cost of RAG and CAG using measured data at three scales, and offers directly reusable optimizations such as pinning routing with session_id.

If you are building a chatbot or search tool that answers questions from your own documents, you have two main ways to give the model those documents. Retrieval-augmented generation (RAG) searches your documents for each question and sends the model only the few pieces that look relevant. Cache-augmented generation (CAG) sends the model all of your documents with every question and uses prompt caching to keep that affordable. That is the choice in RAG vs CAG. To compare them, we built a product catalog for an online outdoor store and asked the same 40 questions at three catalog sizes, about 9K, 66K and 330K tokens. We ran everything through the OpenRouter API on November 8, 2026. CAG answered more questions correctly at every catalog size. RAG cost much less once the catalog got large, and CAG’s cost on DeepSeek V4.1 Flash depended on how requests were routed.
Tl;dr
- On the largest catalog (3,000 products), CAG answered 31 of 40 questions correctly on GPT-6 Luna. Plain RAG, which uses embeddings only, answered 9, and hybrid RAG, which adds keyword search, answered 17.
- Plain RAG could not find products by their product code (SKU) in the largest catalog. Keyword search fixed that.
- RAG cost about the same at every size, $0.13 to $0.22 per 1,000 questions. On GPT-6 Luna, CAG cost rose from $0.13 to $8.70 per 1,000 questions as the catalog grew.
- On DeepSeek V4.1 Flash, CAG requests were spread across many providers, so the cache often missed. Sending the same session ID with every request kept them on one provider, and questions about one or two products cost about 3x less.
- Neither RAG nor CAG counted reliably across the whole catalog. CAG answered 4 or 5 of the 12 whole-catalog questions on the large catalog. A model that could query the catalog with tools answered every question.
What is the difference between RAG and CAG?
RAG sends the model a few relevant pieces of your documents. CAG sends all of them every time and relies on caching to keep the repeated part cheap. In RAG, you first split your documents into chunks and turn each chunk into an embedding with our embeddings API. An embedding is a list of numbers that captures what a piece of text is about, so two texts on the same topic get similar numbers. When a question comes in, you turn it into an embedding too and pick the chunks whose numbers are closest. A reranker, a second model that scores each chunk against the question, then keeps the best few. Our rerank API handles that step. Plain RAG uses only embeddings. Hybrid RAG also uses keyword search, which finds chunks that contain the exact words in the question. The usual keyword method is BM25, a standard way to rank text by the words it shares with the question. In CAG, you put all your documents at the start of the prompt, in the same order on every request. The provider stores that repeated start in its prompt cache, so later requests pay a lower price for it. The benefits are that you build no retrieval step and the model sees every document. The table sums up the differences.
| RAG | CAG | |
|---|---|---|
| What the model sees | A few chunks picked for each question | All of your documents |
| What you build | An index of embeddings and a retrieval step | Nothing beyond the prompt |
| Cost per question | About the same however many documents you have | Grows with the size of your documents |
| Works best for | Large or changing document sets | Small document sets that rarely change |
How we tested
We built a fake catalog of product pages for an online outdoor gear store, so we know the right answer to every question. Each product page lists its name, product code (SKU), price, weight, warranty and a few other details. Headlamps and trekking poles also list which tents or backpacks they work with. We made the catalog in three sizes. The small one has 80 products (8,871 tokens), the medium one has 600 (66,053 tokens), and the large one has 3,000 (329,303 tokens). We asked every method the same 40 questions at each size. There were three kinds of question.
| Question type | How many | Example |
|---|---|---|
| Single fact | 16 (8 by SKU, 8 by product name) | “What is the warranty, in years, on product CX-15350?” |
| Two-hop | 12 | “What is the warranty, in years, on the backpack that the Fjord Ridge Trekking Pole lists first under Compatible with?” |
| Whole-catalog | 12 | “How many headlamps were first sold in 2024?” |
A two-hop question needs two pages. The trekking pole’s page names the backpack, and the backpack’s page has the warranty. A whole-catalog question depends on many pages. We checked the number or SKU in each answer against the true value. The models that answered the questions were GPT-6 Luna and DeepSeek V4.1 Flash. We set reasoning.effort to “low”, which limits how long each model thinks before it answers. For RAG, each product page was one chunk. We created the embeddings with mongodb/voyage-4-lite, and embedding a whole catalog cost less than a cent. We reranked with mongodb/rerank-3-lite. Plain RAG took the 30 pages with the closest embeddings and had the reranker keep the best 5. Hybrid RAG took the 15 closest pages by embedding and the 15 best pages by keyword search, then had the reranker keep the best 5. For CAG, we put the whole catalog in the system message and the question in the user message. On the large catalog, we also tested a model that could look up and filter the catalog with two tools. Keep two limits in mind. The catalog is synthetic and every page follows the same template, which makes product-code lookups harder for embeddings than they would be on real pages. We also ran each setup once on two models, so treat small differences between results as noise.
Which is more accurate, RAG or CAG?
CAG was the most accurate at every catalog size, on both models. It answered 14 to 18 more questions than hybrid RAG, mostly because it could answer two-hop questions. Hybrid RAG was as good as CAG on single-fact questions. The table shows how many of the 40 questions each method answered correctly. Each cell shows GPT-6 Luna first and DeepSeek V4.1 Flash second.
| Catalog | Plain RAG | Hybrid RAG | CAG |
|---|---|---|---|
| 80 products (~9K tokens) | 23 / 23 | 26 / 26 | 40 / 40 |
| 600 products (~66K tokens) | 10 / 10 | 17 / 17 | 31 / 35 |
| 3,000 products (~330K tokens) | 9 / 9 | 17 / 16 | 31 / 32 |
This table splits the large catalog’s results by question type, in the same format. The number in brackets is how many questions of that type there were.
| Question type | Plain RAG | Hybrid RAG | CAG |
|---|---|---|---|
| Single fact (16) | 8 / 8 | 16 / 16 | 16 / 15 |
| Two-hop (12) | 0 / 0 | 1 / 0 | 11 / 12 |
| Whole-catalog (12) | 1 / 1 | 0 / 0 | 4 / 5 |
Why plain RAG misses SKU lookups
Plain RAG found products by name but not by product code. On the large catalog, it answered all 8 questions that used a product name and none of the 8 that used a SKU. Embeddings capture meaning, and a code like CX-15350 has almost none. Plain RAG only looks at the 30 closest pages. For SKU questions, the right page ranked between about 690th and 2,384th out of 3,000. The problem grows with the catalog. On the small catalog of 80 products, the right page was often still in the top 30, and plain RAG answered 5 of the 8 SKU questions. Keyword search fixes this. BM25 ranked the right page first for every SKU question, so hybrid RAG answered all 16 single-fact questions at every size.
Why RAG misses two-hop questions
Take the two-hop example from the table above. Retrieval searches once, using the question. The question names the Fjord Ridge Trekking Pole, so retrieval finds the pole’s page. The warranty is on the backpack’s page, and the question never names that backpack, so its page does not look relevant. On the large catalog, the backpack’s page ranked between 18th and 799th and was never sent. CAG has every page in the prompt, so it does not have this problem.
Why neither approach counts reliably across the catalog
Questions like “How many headlamps were first sold in 2024?” depend on hundreds of pages. RAG sends only 5, so it cannot answer them. CAG has every page but still struggles to count. It answered all 12 of these questions on the small catalog and only 4 or 5 of 12 on the large one. DeepSeek’s score on these questions ranged from 4 to 10 of 12 across the three routing setups in the DeepSeek section below. We ran each setup once, so we can’t say whether routing caused the difference. A model with two tools that query the catalog directly did much better. One tool looks up a product by SKU or name, and the other filters and sorts the catalog. With them, the model answered all 40 questions on the large catalog, on both models.
Which is cheaper, RAG or CAG?
RAG is cheaper on medium and large catalogs. Each RAG question sent 650 to 710 tokens at every size. Each CAG question sent the whole catalog, and most of it was billed at the lower cached price. On GPT-6 Luna, CAG cost the same as hybrid RAG on the small catalog and more on the larger ones. On DeepSeek with default routing, CAG cost more than RAG at every size. The table shows the average cost per 1,000 questions. RAG costs include embedding and reranking. DeepSeek CAG uses default routing, which the next section explains.
| Catalog | Luna plain RAG | Luna hybrid RAG | Luna CAG | DeepSeek plain RAG | DeepSeek hybrid RAG | DeepSeek CAG |
|---|---|---|---|---|---|---|
| 80 products | $0.15 | $0.13 | $0.13 | $0.20 | $0.17 | $0.73 |
| 600 products | $0.15 | $0.14 | $0.92 | $0.20 | $0.20 | $4.09 |
| 3,000 products | $0.15 | $0.14 | $8.70 | $0.22 | $0.21 | $21.92 |
The first CAG request costs more because it writes the catalog into the cache. On the large catalog it cost $0.08 on both models. The CAG numbers include that first request, while the RAG numbers leave out the one-time cost of creating embeddings. GPT-6 Luna also charges more for long prompts, and the large catalog is long enough to pay that rate. Above 272K tokens, its input and cached prices double.
Why did CAG cost more on DeepSeek?
On DeepSeek V4.1 Flash, CAG requests were spread across 11 providers, and each provider keeps its own cache. Many requests went to a provider that had not cached the catalog yet, so only 75% of the input was cached on the large catalog. GPT-6 Luna sent every request to OpenAI and cached 97%. We use provider sticky routing to send related requests to the provider that already holds the cache. By default, we decide which requests are related by looking at “the first system (or developer) message and the first non-system message.” In CAG, the first non-system message is the question, which changes every time. So each question looks unrelated to the last one. A session_id is a label you attach to related requests. Without one, sticky routing also “only activates after a cache hit is detected,” meaning after a request finds the catalog already cached. Until then, default routing spreads requests across providers. The fix is to send the same session_id with every question. It can be up to 256 characters, and it goes in the request body or the x-session-id header. This script prints which provider answered each question, how many tokens came from the cache, and the cost.
import os
import requests
catalog = open("catalog.md").read() # your documents, identical on every request
def ask(question):
resp = requests.post(
"https://openrouter.ai/api/v1/chat/completions",
headers={"Authorization": f"Bearer {os.environ['OPENROUTER_API_KEY']}"},
json={
"model": "deepseek/deepseek-v4.1-flash",
"session_id": "catalog-v1", # one constant value for every question
"messages": [
{"role": "system", "content": "Answer using only this catalog.\n\n" + catalog},
{"role": "user", "content": question},
],
},
).json()
usage = resp["usage"]
cached = usage["prompt_tokens_details"]["cached_tokens"]
print(resp["provider"], f"{cached}/{usage['prompt_tokens']} cached", f"${usage['cost']:.5f}")
return resp["choices"][0]["message"]["content"]
for q in ["What is the warranty, in years, on product CX-15350?",
"How many grams does the Ember Trail Trekking Pole weigh?"]:
print(ask(q))The table compares three routing setups for DeepSeek CAG on the large catalog, measured on November 8, 2026. Lookup questions are the 28 single-fact and two-hop questions.
| DeepSeek CAG at 3,000 products | Providers | Input cached | Correct | Cost per 1,000 questions | Lookup questions only |
|---|---|---|---|---|---|
| Default routing | 11 | 75% | 32/40 | $21.92 | $20.16 |
| session_id | 1 | 97% | 38/40 | $15.85 | $6.31 |
| session_id and sort: “price” | 1 | 95% | 30/40 | $7.35 | $1.97 |
With session_id, lookup questions cost about 3x less. If you leave out the first request, which writes the cache, lookup questions cost about 7x less, $2.69 per 1,000 questions instead of $18.02. Total cost fell less, from $21.92 to $15.85. The counting questions made DeepSeek think for up to three minutes each. That thinking is billed as output, and caching does not make output cheaper. The provider your session sticks to also affects the price. DeepSeek V4.1 Flash has more than 30 provider endpoints, and some charge more than 10 times as much as others for cached input. In our third run, we added provider.sort: “price” so requests went to the cheapest provider. Lookup questions then cost 10x less than with default routing. That provider ran an fp4 version of the model, which stores the model’s numbers at lower precision. This run answered 30 of 40 questions, compared with 38 for session_id alone. One run is not enough to say whether the lower precision caused the drop. If you want to avoid lower-precision versions, use the quantizations filter. Check cached_tokens in each response to confirm the cache is working. If your documents fit in the context window, try CAG with a constant session_id and measure cached tokens and cost on your own questions. Our prompt caching tutorial covers common reasons for cache misses.
When should you use RAG vs CAG?
Use CAG when your documents fit comfortably in the context window and change rarely. Use hybrid RAG when your document set is large, changes often, or needs a flat cost per question.
- Start with CAG for small document sets that rarely change, such as a product catalog. On GPT-6 Luna, CAG cost under $1 per 1,000 questions up to 66K tokens. Keep the documents at the start of the prompt, unchanged, and send a constant session_id.
- Use hybrid RAG for large document sets or ones that change often. Combine embedding search with keyword search so product codes and other exact terms are found, then rerank the results. The embeddings and rerank rankings show which models developers use for each step.
- For questions that need two documents, use CAG if your documents fit. Otherwise, use an agent that can search more than once.
- For counts and other questions about the whole data set, give the model a tool that queries the data directly.
Frequently asked questions
Is CAG better than RAG?
In OpenRouter’s CAG vs RAG tests, CAG was more accurate than RAG at every catalog size, because the model sees every page. That holds only while your documents fit in the context window. Hybrid RAG was much cheaper on large catalogs. On GPT-6 Luna at 330K tokens, hybrid RAG cost $0.14 per 1,000 questions and CAG cost $8.70.
Does CAG replace RAG?
No. CAG works best when your documents fit in the context window and rarely change, because the cache covers only a prompt start that is identical on every request. For large or changing document sets, use hybrid RAG. You can run its embedding and reranking steps through OpenRouter’s embeddings and rerank APIs.
How big can the documents be for CAG?
The limit is the model’s context window, which is about 1 million tokens for both models in OpenRouter’s tests. Accuracy on counting questions drops long before that. GPT-6 Luna CAG answered all 12 whole-catalog questions on the 9K-token catalog but only 4 of 12 at 330K tokens, where it cost $8.70 per 1,000 questions.
Next steps
To set up CAG, read the Provider Sticky Routing section of our prompt caching docs. To build hybrid RAG, follow our RAG cookbook.
Source: OpenRouter: Announcements · openrouter.ai