RAG Cost Calculator
Price a complete Retrieval-Augmented Generation pipeline — document indexing, vector storage, per-query retrieval, and LLM answer generation — in USD and LKR. Plug in your knowledge-base size, query volume, and chosen models to see the one-time and monthly cost, and exactly which line dominates the bill.
How it works
A RAG pipeline has four cost centres, and this calculator prices each one separately so you can see where your money actually goes. Most single-purpose calculators price only indexing or only storage; the recurring per-query generation cost — the line that dominates a real bill — gets left out. The math is intentionally plain, and every per-token and per-GB rate comes from the vendor pricing pages cited at the bottom of this page, hand-verified on 2026-06-09.
total_tokens = documents × avg_tokens_per_doc
step = max(1, chunk_size − overlap)
chunks = ceil(total_tokens / step)
index_cost = total_tokens / 1e6 × embed_price_per_M (one-time)
storage_bytes = chunks × dimensions × 4 (float32)
storage_gb = storage_bytes / 1024³
monthly_storage = storage_gb × storage_price_per_GB_month
context_tokens = top_k × chunk_size
gen_input = system_prompt + query_tokens + context_tokens
gen_cost/query = gen_input / 1e6 × gen_in_price
+ output_tokens / 1e6 × gen_out_price
query_embed/query= query_tokens / 1e6 × embed_price_per_M
per_query = query_embed/query + gen_cost/query
monthly_total = queries/mo × per_query
+ monthly_storage
+ index_cost × reindex_per_month
first_month = monthly_total + (reindex = 0 ? index_cost : 0)
lkr = usd × usd_to_lkr_rateThe one-time indexingcost embeds your whole corpus once, at the embedding model's per-million-token rate — the same rate the standalone embedding cost calculator uses, so the two tools agree on any corpus you check in both. Storageis computed from the real vector size — chunk count × the embedding model's dimensions × 4 bytes for float32 — so a 3,072-dimension model like text-embedding-3-large costs twice the storage of a 1,536-dimension model. Storage GB uses binary GiB (1024³ bytes), which slightly overestimates against the decimal GB some clouds bill, erring toward a safer number.
Everything upstream of those formulas depends on one input: average tokens per document. A token is roughly 0.75 English words, so a 1,500-word article is about 2,000 tokens and a dense A4 PDF page lands near 750. Sinhala and Tamil text tokenises far less efficiently — commonly two to four times more tokens per character than English on the same tokenizers, a penalty the language token tax calculator quantifies per language — so a bilingual knowledge base can carry several times the token count its page count suggests. Paste a representative document into the AI token counter and divide by the document count rather than guessing; every line on this page scales linearly from that one number, so an error there propagates straight through to the monthly total.
The recurring generation line is where RAG bills live. Every query sends the system prompt, the question, and all top_k retrieved chunks to the LLM as input tokens, then bills the answer as output tokens. Because chat-model rates run many times the embedding rate and apply on every single query, generation routinely exceeds 95% of the monthly total — which is why raising top-k or the chunk size is the fastest way to push the bill up. The calculator's breakdown bar shows the exact split. If top_k × chunk_size starts approaching the model's context limit, check the ceiling in the context window calculator before raising retrieval depth further — a request that overflows the window fails outright rather than costing more.
Re-indexing is the line most estimates forget. If the corpus is static you index once and the charge never repeats, so the tool reports it separately as a one-time cost and folds it into the first month only. If you rebuild the index on a schedule — nightly product-catalogue refreshes, a weekly policy-document sync — set re-indexes per month and the same one-time figure becomes recurring: index_cost × reindex_per_month. Thirty full re-indexes a month on an eight-million-token corpus turns a $1.04 one-off into $31.20 a month, at which point it can outweigh storage several times over. Incremental indexing — embedding only changed documents — is almost always cheaper; model it by setting document count to the changed subset.
Chunk counting uses ceil(total_tokens / step), which counts every sliding window across the corpus. A real text splitter such as LangChain produces an equal or slightly smaller count once overlap is large, so this figure is a conservative upper bound on stored chunks. Overlap is the sharpest edge here: because step is chunk_size − overlap, an 80% overlap does not add 80% more chunks — it multiplies them fivefold, and storage with them. To see the split your settings would actually produce on real text, run a sample document through the text chunker, and to choose the size and overlap on retrieval quality rather than cost alone, start from the RAG chunk size calculator. The page cross-checks the two formulas and confirms they agree exactly at zero overlap: chunk-count cross-check passes.
Worked-example self-test (computed live on this page) — each line reconciles the formula above with the hand-derived numbers in the code header:
- A · Small KB · 3-small · GPT-4o-mini · monthly total → expected $5.89, got $5.89
- A · Small KB · first month incl. one-time index → expected $5.91, got $5.91
- B · Larger KB · 3-large · Claude Haiku 4.5 · monthly total → expected $276.77, got $276.77
- C · Zero docs, zero queries · first month → expected $0.00, got $0.00
- E · 1e9 tokens · no queries · first month incl. $20 index → expected $21.89, got $21.89
Worked examples
Which levers actually cut a RAG bill
Because generation is almost always the dominant line, the savings worth chasing are the ones that reduce input tokens per query or the price of those tokens. Ranked by how much they typically move the monthly total:
- Change the generation model. The spread between the cheapest and most expensive model in the list below is 25× on input tokens. Moving the chat-with-PDFs example from GPT-4o to GPT-4o mini drops the monthly bill from roughly $98 to $5.88 — a 94% cut with no change to retrieval at all. Try the cheap tier first and only escalate on the queries that measurably need it.
- Lower top-k.Retrieval depth multiplies straight into every query's input. Going from top-k 8 to top-k 4 on a 500-token chunk size removes 2,000 input tokens per question. If answer quality holds, that is a permanent saving on every query for the life of the system.
- Shrink the chunk size. Halving chunks from 1,000 to 500 tokens halves context tokens at the same top-k, though it also doubles the chunk count and the storage line. Storage is cheap relative to generation, so this trade is usually worth taking.
- Trim the system prompt. A 600-token instruction block sent on 50,000 monthly queries is 30 million billed input tokens — $4.50 a month on GPT-4o mini, $75 on GPT-4o. Prompt length is fixed overhead you pay on every single call.
- Cache the static prefix. System prompts and unchanging instructions can be cached by most providers at a heavy discount on repeat reads. This calculator deliberately excludes that saving so its figure stays an upper bound; the prompt caching cost calculator models it separately.
- Index incrementally. Re-embed only changed documents instead of the whole corpus. On a nightly-refresh setup this is often the single largest saving after model choice, as the freelancer example above shows.
What barely matters: the embedding model's per-token price and the vector-database storage rate. Both are usually under 1% of the monthly total. Pick the embedding model on retrieval quality and language coverage — Cohere's multilingual variant handles Sinhala and Tamil at the same per-token price — not on its price per million tokens. Storage only becomes a real line when you combine a 3,072-dimension model with heavy chunk overlap on a large corpus.
Per-token prices used in this calculator
Every figure below is hand-verified against the vendor pricing page linked in the sources section, last checked on 2026-06-09. These are standard-tier, pay-as-you-go list prices in USD; batch tiers, cached-input tiers, and enterprise commitments are cheaper and are not modelled here.
Embedding models (indexing + query retrieval)
| Model | Vendor | USD / 1M tokens | Dimensions |
|---|---|---|---|
| text-embedding-3-small | OpenAI | $0.02 | 1,536 |
| text-embedding-3-large | OpenAI | $0.13 | 3,072 |
| embed-v3.0 (English / multilingual) | Cohere | $0.10 | 1,024 |
| gemini-embedding-001 | $0.15 | 3,072 |
Dimensions drive storage, not price: at the same chunk count, a 3,072-dimension model stores exactly twice the bytes of a 1,536-dimension one and three times a 1,024-dimension one.
Generation models (the answer step)
| Model | Vendor | USD / 1M input | USD / 1M output |
|---|---|---|---|
| GPT-4o mini | OpenAI | $0.15 | $0.60 |
| GPT-4o | OpenAI | $2.50 | $10.00 |
| Claude Haiku 4.5 | Anthropic | $1.00 | $5.00 |
| Claude Sonnet 4.5 | Anthropic | $3.00 | $15.00 |
| Gemini 2.5 Flash | $0.30 | $2.50 | |
| Gemini 2.0 Flash | $0.10 | $0.40 |
Input price is the number to watch in RAG: retrieved context makes input tokens outweigh output tokens several times over on a typical query, which is the opposite of a normal chat workload.
Frequently asked questions
Sources & references
- OpenAI — API Pricing (text-embedding-3-small / 3-large, GPT-4o / 4o-mini)
- Anthropic — Claude API Pricing (Claude Haiku 4.5, Sonnet 4.5)
- Google — Gemini API Pricing (Gemini 2.5 / 2.0 Flash, gemini-embedding-001)
- Cohere — Pricing (embed-v3.0 English / multilingual)
- Pinecone — Pricing (serverless storage $/GB-month)
- Central Bank of Sri Lanka — Daily indicative exchange rates (USD→LKR)
Every price was last cross-checked against its vendor pricing page on 2026-06-09. The default storage rate is Pinecone serverless ($0.33/GB-month). Spotted a price that has moved? Email the address below — most fixes ship within 24 hours.
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 price that has moved, or an edge case the calculator doesn't cover?
Email me at [email protected] — most fixes ship within 24 hours.