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.
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·poutwherepcr = 0.1·pin(Anthropic cache-read). The cache is re-written once per 5-minute window, so writes per month =min(queries, 8640)each costingC·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 forceil(C/s)vectors at ${0.33}/GB-month (binary GiB, 4 bytes per dimension); and per queryq·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
Frequently asked questions
Sources & references
- Anthropic — Claude model pricing, prompt caching, and 1M-context beta rates
- OpenAI — API and embedding (text-embedding-3-small / -large) pricing
- Google — Gemini API pricing (incl. the >200K long-context tier)
- Pinecone — serverless vector storage pricing ($/GB-month)
- Central Bank of Sri Lanka — indicative USD→LKR exchange rate
Prices were last cross-checked against the vendor pages on 2026-07-18. This is a cost comparison only — it does not model answer quality or latency, which depend on your data and setup.
Related tools
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.