Skip to content
induwara.lk
Premium
induwara.lkAI · Architecture cost

RAG vs Long-Context Cost Calculator

Retrieve the relevant chunks, or paste the whole document into the context window? Enter your corpus size, query volume and model to price both approaches per query and per month — with prompt caching and the break-even corpus size. No signup, no ads, sources cited below.

By Induwara AshinsanaUpdated Jul 18, 2026
RAG vs long context
Your workload

Whole knowledge base. ~750 words ≈ 1,000 tokens.

Total questions answered per month.

Typical user question: 50–300 tokens.

Typical generated answer: 200–800 tokens.

Generation model used by both approaches.

RAG retrieval settings

Chunks fed to the model per query. 1–50.

Tokens per stored chunk. 50–2,000.

Used only on the RAG side.

$

Default Pinecone serverless ($0.33). Edit for Qdrant/pgvector.

Rs

CBSL daily indicative rate. Edit to match your bank or Wise.

Scenarios
RAG is 25× cheaper

At 150,000 corpus tokens and 5,000 queries/month, rag saves $2,189.98 per month versus long context.

Break-even: below a corpus of about 4,001 tokens, long context becomes the cheaper option at this top-k and chunk size.

Long context
Send the whole corpus every query
$2,283.00/mo
$0.4566/query
150,200 prompt tokens/query · standard tier
RAG
Retrieve top-8 chunks per query
Cheaper
$93.02/mo
$0.0186/query
4,000 retrieved tokens/query · $0.003 one-time embed

Monthly cost vs query volume

Long contextRAG
0 queries/mo15,000 queries/mo

The dashed line marks your 5,000 queries/month. Both lines are near-linear, so whichever sits lower at your volume stays lower as you scale.

Long-context breakdown
Prompt tokens / query
150,200 tok
Input rate applied
$3/M
Uncached input / query
$0.4566
Cache writes / month
Effective monthly
$2,283.00
RAG breakdown
Chunks stored
300
Retrieved / query
8 chunks · 4,000 tok
One-time embedding
$0.003
Vector storage / month
$0.0006 · 0.0017 GB
Generation + query embed / query
$0.0186
Monthly total
$93.02

Caching is on but does not help at this volume: with only 5,000 queries/month, each cache write (1 per 5-minute window, up to 8,640/month) costs more than the read discount saves. Uncached ($2,283.00) beats cached ($3,070.50), so the tool uses the uncached price above.

All math runs in your browser over a dated price table. No corpus, queries, or API keys leave the page.

How it works

Both approaches answer the same question with the same generation model; the only difference is how many tokens you feed it. Long context sends the entire corpus every query; RAG sends only the top-k retrieved chunks. The calculator prices each side from a dated static table of vendor per-token rates — no network calls — so results are deterministic.

Write C for corpus tokens, q for question tokens, a for answer tokens, k for top-k, s for chunk size, and per-token prices pin, pout.

  • Long context, uncached: per query = (C + q)·pin + a·pout. Monthly = queries × that.
  • Long context, cached: per query = C·pcr + q·pin + a·pout where pcr = 0.1·pin (Anthropic cache-read). The cache is re-written once per 5-minute window, so writes per month = min(queries, 8640) each costing C·pcw (pcw = 1.25·pin). If caching ends up more expensive than uncached — which happens at low volume — the tool uses the uncached price, because a rational operator would turn caching off.
  • Long-context premium: Google and Anthropic reprice the whole request once input exceeds 200,000 tokens, so a large corpus is billed entirely at the higher rate.
  • RAG: a one-time embedding of C·pemb; storage for ceil(C/s) vectors at ${0.33}/GB-month (binary GiB, 4 bytes per dimension); and per query q·pemb + (min(k, chunks)·s + q)·pin + a·pout. Retrieval is capped by the corpus — RAG never sends more than exists.

The break-evenis a corpus size, not a query count. Because RAG's per-query cost flattens once the corpus is bigger than one retrieval (it always fetches the same top-k), while long context grows with corpus size, the two cross at about k·stokens. Below that corpus, long context is cheaper and simpler; above it, RAG pulls ahead and the gap widens with corpus size. Every rate cites the vendor page in the source module and is cross-checked by an independent per-1,000-token arithmetic path (the same technique the site's tax calculator uses against IRD Table 01).

Worked examples

Large corpus, moderate volume — RAG wins ~24×

150K tokens · 5,000 queries/mo · Claude Sonnet 4.5 · caching on

  1. Long context (uncached): (150,000 + 200) × $3/M + 400 × $15/M = $0.4506 + $0.006 = $0.4566/query
  2. Monthly: 5,000 × $0.4566 = $2,283
  3. Caching check: reads $0.0516/query, but 5,000 writes × $0.5625 = $2,812 → cached $3,070 > uncached $2,283, so caching does NOT help here
  4. RAG: retrieve 8 × 500 = 4,000 tokens → (4,000 + 200) × $3/M + 400 × $15/M + query-embed = $0.018604/query
  5. RAG monthly: 5,000 × $0.018604 + ~$0.0006 storage = $93.02
  6. Verdict: RAG $93 vs long context $2,283 → RAG ~24.5× cheaper.

Same corpus, high volume — caching helps, RAG still wins

150K tokens · 100,000 queries/mo · Claude Sonnet 4.5 · caching on

  1. Long context uncached monthly: 100,000 × $0.4566 = $45,660
  2. Cached: 100,000 reads × $0.0516 + 8,640 writes × $0.5625 = $5,160 + $4,860 = $10,020 → caching HELPS (below $45,660)
  3. RAG monthly: 100,000 × $0.018604 + storage = $1,860
  4. Verdict: caching cut long context to $10,020, but RAG ($1,860) is still ~5.4× cheaper.

Tiny corpus — long context wins (edge case)

3,000 tokens · 5,000 queries/mo · Claude Haiku 4.5 · caching off

  1. Corpus (3,000) is smaller than one retrieval (8 × 500 = 4,000), so RAG can only fetch the whole 3,000 anyway
  2. Long context: (3,000 + 200) × $3/M + 400 × $15/M = $0.0156/query → $78.00/mo
  3. RAG: same 3,000 tokens + a $0.000004 query embed + vector storage = $0.015604/query → ~$78.02/mo
  4. Verdict: near tie on cost — long context wins because it needs no embeddings and no vector database.

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.