Comparison

RAG vs Long-Context Models: When to Stuff the Prompt and When to Retrieve

The Kopik team9 min read

Long-context models can now accept hundreds of thousands of tokens in a single prompt, which makes it tempting to skip retrieval entirely and just paste the whole document set. In practice, retrieval-augmented generation (RAG) is usually cheaper, faster, and more accurate once your document set grows past a few files or gets queried more than a handful of times. The short answer: use long context for one-off analysis of a bounded set of documents, and use RAG for anything you query repeatedly, anything that grows over time, or anything where you need to show which passage an answer came from.

What "long context" actually means today

A context window is the maximum number of tokens (roughly, word fragments) a model can read and write in a single call. A few years ago that number was around 4,000 to 8,000 tokens, barely a few pages. Many current large language models now advertise context windows in the 100,000 to 1,000,000+ token range, enough to fit a few hundred pages of text in one request. That capability genuinely changed what's possible: you can drop a full contract, a codebase, or a stack of PDFs into one prompt and ask a question directly.

The catch is that a bigger window doesn't mean the cost or the accuracy scales the way you'd hope. Every token you send, whether the model needs it or not, is billed as input, and every token also competes for the model's attention. For a deeper look at how retrieval pipelines work under the hood, see How RAG Works, Step by Step.

The real cost comparison

The core difference between the two approaches is what gets sent to the model on every single query. With long context, you typically re-send the same large block of documents on every question, because the model has no memory between calls unless you pay for context caching (and even cached tokens aren't free). With RAG, you send only the handful of passages that are actually relevant to the question, usually a few hundred to a couple thousand tokens, regardless of how large the underlying document collection is.

Stuffing the prompt vs retrieving relevant passages

ApproachTokens sent per queryCost behavior as documents growCost behavior as query volume grows
Long context (stuff everything)Tens of thousands to the full window size, resent every timeGrows linearly with corpus size; a 500-page manual costs roughly the same every queryMultiplies: 1,000 queries against a 100-page doc costs 1,000x the per-query input cost
RAG (retrieve then answer)A few hundred to a few thousand tokens (only the matched passages)Stays roughly flat; indexing cost happens once, not per queryScales with number of queries, not document size, so it stays predictable

Two numbers matter when you do this math for your own use case: how many documents you have, and how many times they'll be queried. If you have one document and you'll ask it three questions today, long context is simpler and the cost difference is negligible. If you have a knowledge base that gets queried hundreds of times a day, or that keeps growing as new documents are added, the input-token bill for stuffing everything into every call adds up fast, and it adds up faster than most teams expect because it's easy to forget that cost scales with queries, not just with document size.

A quick rule of thumb

If the same document set will be queried more than roughly 10 to 20 times, or if the collection will keep growing, the token cost of re-sending it on every call usually exceeds the cost of building a retrieval index once. Below that threshold, long context is often simpler and cheap enough to not bother optimizing.

When long context genuinely wins

Long context isn't a legacy approach to be replaced; it's the right tool for specific jobs. It tends to win when:

  • The task is a one-off analysis: summarizing a single contract, reviewing a pull request, or extracting data from one report, where you won't ask the same corpus more than a few questions.
  • The question requires reasoning across the entire document at once, like finding every internal inconsistency in a 200-page filing, something retrieval's top-k passages might miss because the relevant pieces aren't textually similar to the query.
  • The document set is small and stable, so the per-query cost of re-sending it stays low and predictable.
  • You need zero setup time and can't invest in building an index, chunking strategy, or embedding pipeline before getting an answer.

That second point deserves attention: retrieval only returns passages that match the query well, so tasks that require holistic reasoning (cross-referencing clause 4 with clause 47, checking for contradictions across a whole document) genuinely benefit from the model seeing everything at once. RAG is a precision tool for targeted questions, not a universal substitute for reading comprehension.

When RAG wins

RAG tends to win once the use case moves from a one-off task to a recurring system. Concretely:

  • Repeated querying: a support team, a customer-facing chatbot, or an internal assistant that gets asked questions all day against the same knowledge base.
  • Growing collections: documentation, policies, or case files that get added to weekly, where re-indexing a few new pages is far cheaper than re-sending the whole archive every time.
  • Multi-tenant or multi-source setups: when different users should only see answers grounded in specific subsets of documents, which retrieval can filter per query while a single stuffed prompt cannot.
  • Any requirement to cite sources: RAG naturally returns which chunk an answer came from, which matters for compliance, customer support, and any workflow where someone needs to verify the answer. See What Is RAG (Retrieval-Augmented Generation)? A Practical Guide for how that grounding works.
  • Latency-sensitive applications: sending a few hundred tokens of context is faster to process than tens of thousands, which matters for chat interfaces where users expect a quick reply.

Accuracy: the "lost in the middle" problem

Cost isn't the only factor, and it's often not even the deciding one. Independent evaluations of long-context models have repeatedly found that accuracy degrades for information buried in the middle of a very long prompt, a pattern commonly called "lost in the middle." Models are noticeably better at using information near the start or end of a long context than information in the middle, which means stuffing a 300-page manual into a prompt doesn't guarantee the model will actually use page 150 correctly, even though it technically fit.

RAG sidesteps this by handing the model only the passages that matched the question, so there's no haystack to get lost in. The tradeoff is that retrieval quality now depends on how well the search step finds the right passages in the first place. A pure keyword search can miss a passage that uses different wording than the question, and a pure vector search can surface something topically similar but not actually relevant. That's why production systems generally combine both; see Hybrid Search: Why BM25 + Vectors Beats Either Alone for RAG for how that combination closes the gap. How documents get split into chunks also matters a lot for retrieval quality, which is covered in Chunking Strategies for RAG.

The hybrid approach: use both

In practice, the best-performing systems rarely pick one approach exclusively. A common pattern is to use RAG as the default retrieval layer for most queries (cheap, fast, grounded, scales with volume) and fall back to a long-context pass only for the subset of questions that genuinely require reading the whole document, like "list every inconsistency between sections 3 and 9." Another pattern is to retrieve a generous set of candidate chunks (say, the top 20 instead of the top 5) and let a long-context model reason over that larger but still bounded set, getting some of the holistic reasoning benefit without resending the entire corpus.

If you're deciding between RAG and fine-tuning a model on your documents instead, that's a separate but related question covered in RAG vs Fine-Tuning: Which One for Your Business Documents?. For most knowledge-base use cases, retrieval (not fine-tuning, and usually not raw long context) ends up being the most maintainable choice because new documents can be added without retraining or re-sending the archive.

A practical decision checklist

Before building either pipeline, answer these questions:

  1. How many documents do you have today, and will that number grow over the next six months?
  2. How many times per day or per month will this document set realistically be queried?
  3. Do typical questions need a handful of specific facts, or do they require reasoning across the entire document?
  4. Do you need to show the user which passage an answer came from?
  5. Is latency a concern (a live chat widget) or not (a batch summarization job)?

If most answers point toward "repeated queries, growing corpus, need for citations, latency matters," build a retrieval pipeline. If you're answering "one-off task, small stable document, needs holistic reasoning," a long-context call is simpler and often cheaper for that single use.

Setting up retrieval from scratch (chunking, embeddings, a hybrid index, an API) is a real engineering project, which is one reason teams use a managed service instead of building it in-house. Kopik lets you upload documents and get a queryable knowledge base with hybrid search in minutes, without managing a vector database or an indexing pipeline yourself. You can also compare the general cost structure of self-hosted vector databases against managed options in Vector Database Pricing: What You Actually Pay For.

Stop re-sending the whole document every query

Upload your files once, let Kopik chunk and index them for hybrid search, and query only the passages that matter, through the website, a REST API, or an MCP client like Claude or Cursor.

Frequently asked questions

Frequently asked questions

Is RAG obsolete now that context windows are so large?

No. Large context windows solve the problem of fitting documents into a single prompt, but they don't solve cost at scale, latency, source citation, or the "lost in the middle" accuracy issue. RAG remains the better default for any knowledge base that gets queried repeatedly or keeps growing.

How much does it cost to stuff a 100-page document into every query?

It depends on the model's input pricing, but the key point is that the cost is paid again on every single query because the model has no memory between calls (unless you pay separately for context caching). Over hundreds of queries, that repeated cost typically exceeds the one-time cost of building a retrieval index.

Does RAG reduce hallucinations compared to long context?

RAG tends to reduce hallucinations because it grounds answers in specific retrieved passages that can be cited and checked, rather than asking the model to recall a fact correctly from tens of thousands of tokens of context. See Document Q&A With Citations: How to Check an AI Answer for how citation-based verification works.

Can I combine RAG and long context in the same system?

Yes, and many production systems do. A common pattern is to use retrieval as the default for most questions and reserve a long-context pass for queries that genuinely require reasoning across an entire document, or to retrieve a larger candidate set and let a long-context model process that bounded set instead of the full corpus.

Does context caching change the cost math?

Caching can lower the cost of re-sending an identical block of text across calls, but it still generally costs more than sending only the few relevant passages that retrieval would have selected, and it doesn't address the accuracy drop seen with information buried in a long prompt.

At what document collection size should I switch from long context to RAG?

There's no fixed size threshold; it depends more on query volume and growth. As a rule of thumb, if the same documents will be queried more than about 10 to 20 times, or the collection keeps growing, building a retrieval index usually pays for itself quickly.

Get the Kopik newsletter

New knowledge bases, RAG guides and product news. One email every week or two, unsubscribe in one click.

By subscribing you agree to receive our newsletter. We never share your address.