Skip to content
induwara.lk
Premium
induwara.lkAI · Cost calculator

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.

By Induwara AshinsanaUpdated Aug 5, 2026
RAG pipeline cost
Knowledge base (one-time indexing)

Whole number, 1 or more.

≈ 750 words per 1,000 tokens. PDF page ≈ 500–600 tokens.

Tokens per stored chunk. 50–8,000.

Overlap between chunks. Must be below chunk size.

Per-million-token prices from the vendor pricing page.

0 = index once, never re-embed. 1 = monthly refresh.

Query workload (recurring)

Total questions answered per month.

Typical short user question: 20–80 tokens.

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

Instructions prepended to every generation.

Per-million-token prices from the vendor pricing page.

Length of each generated answer. 1–8,000.

$

Default is Pinecone serverless ($0.33/GB-month). Edit for Qdrant, Weaviate, or pgvector.

Rs

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

Workload presets
Monthly cost
$5.8882
Rs 1,766
First month (incl. indexing)
$5.9082
Rs 1,772
One-time indexing
$0.02
2,223 chunks
Cost per query
$0.0006
2,720 input tokens

What drives the monthly bill

LLM generation
$5.8899.86%
Vector storage
$0.00420.07%
Query embedding
$0.0040.07%
Re-indexing
$0.000%

Derived stats

Total tokens indexed
1,000,000
Chunks stored
2,223
Vector storage
0.0127 GB
Retrieved context / query
2,500 tok
Generation input / query
2,720 tok
Monthly storage cost
$0.0042
All math runs in your browser. No documents, queries, or API keys leave the page.

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_rate

The 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

Chat-with-PDFs bot · 1,000 docs × 1,000 tokens · 10,000 queries/mo

OpenAI text-embedding-3-small + GPT-4o-mini. Chunk 500, overlap 0, top-k 5. Rs 300/USD.

  1. Total tokens: 1,000 × 1,000 = 1,000,000
  2. Chunks: ceil(1,000,000 / 500) = 2,000
  3. Indexing: (1,000,000/1e6) × $0.02 = $0.02 one-time
  4. Storage: 2,000 × 1,536 × 4 = 12.29 MB → 0.01144 GB × $0.33 = $0.0038/mo
  5. Gen input/query: 200 + 20 + (5 × 500) = 2,720 tokens
  6. Gen cost/query: 2,720/1e6 × $0.15 + 300/1e6 × $0.60 = $0.000588
  7. Monthly queries: 10,000 × $0.000588 = $5.88
  8. Monthly total: $5.88 + $0.0038 ≈ $5.89 (≈ Rs 1,766) + $0.02 one-time

Support bot · 10,000 docs × 800 tokens · 50,000 queries/mo

text-embedding-3-large + Claude Haiku 4.5. Chunk 400, overlap 0, top-k 8. Rs 300/USD.

  1. Total tokens: 10,000 × 800 = 8,000,000
  2. Chunks: ceil(8,000,000 / 400) = 20,000
  3. Indexing: (8,000,000/1e6) × $0.13 = $1.04 one-time
  4. Storage: 20,000 × 3,072 × 4 = 245.76 MB → 0.2289 GB × $0.33 = $0.0755/mo
  5. Gen input/query: 300 + 30 + (8 × 400) = 3,530 tokens
  6. Gen cost/query: 3,530/1e6 × $1.00 + 400/1e6 × $5.00 = $0.00553
  7. Monthly queries: 50,000 × $0.005534 = $276.70
  8. Monthly total: $276.70 + $0.0755 ≈ $276.77 (≈ Rs 83,031) + $1.04 one-time

Edge case · top-k turned up from 5 to 10

Same chat-with-PDFs bot, but retrieving 10 chunks instead of 5. Shows why retrieval depth is the cost lever.

  1. Context tokens jump: 5 × 500 = 2,500 → 10 × 500 = 5,000
  2. Gen input/query: 200 + 20 + 5,000 = 5,220 tokens (was 2,720)
  3. Gen cost/query: 5,220/1e6 × $0.15 + 300/1e6 × $0.60 = $0.000963
  4. Monthly queries: 10,000 × $0.000963 = $9.63 (was $5.88)
  5. Lesson: doubling top-k raised the monthly bill ~64%, all from input tokens.

Edge case · 80% chunk overlap on a single document

1 doc × 1,000 tokens, chunk 500, overlap 400. Shows how overlap multiplies chunk count and storage.

  1. Step: max(1, 500 − 400) = 100 tokens
  2. Chunks: ceil(1,000 / 100) = 10 (at zero overlap it would be 2)
  3. Indexing is unchanged: (1,000/1e6) × $0.02 = $0.00002 one-time
  4. Storage: 10 × 1,536 × 4 = 61,440 bytes → 0.0000572 GB × $0.33 ≈ $0.00002/mo
  5. Lesson: overlap does not raise indexing cost — you embed the same corpus once —
  6. but it multiplies stored vectors 5×. On a 10M-token corpus at 1,536 dims that
  7. same 80% overlap turns 20,000 chunks (0.114 GB, $0.038/mo) into 100,000 chunks
  8. (0.572 GB, $0.189/mo) — five times the storage for identical source text.

Freelancer client quote · 500 docs × 1,200 tokens · 3,000 queries/mo · nightly re-index

Cohere embed-v3.0 (1,024d, Sinhala/Tamil capable) + Gemini 2.0 Flash. Chunk 600, overlap 0, top-k 4. Rs 300/USD.

  1. Total tokens: 500 × 1,200 = 600,000
  2. Chunks: ceil(600,000 / 600) = 1,000
  3. Indexing: (600,000/1e6) × $0.10 = $0.06 one-time
  4. Re-index 30×/mo: $0.06 × 30 = $1.80/mo (this is the line most quotes miss)
  5. Storage: 1,000 × 1,024 × 4 = 4.10 MB → 0.003815 GB × $0.33 = $0.0013/mo
  6. Gen input/query: 250 + 25 + (4 × 600) = 2,675 tokens
  7. Gen cost/query: 2,675/1e6 × $0.10 + 350/1e6 × $0.40 = $0.0004075
  8. Monthly queries: 3,000 × $0.0004075 = $1.22
  9. Monthly total: $1.22 + $1.80 + $0.0013 ≈ $3.02 (≈ Rs 907)
  10. Note: nightly re-indexing costs more than every query combined here —
  11. switching to incremental indexing of changed docs would cut the bill ~60%.

Edge case · bilingual Sinhala + English KB · 800 docs × 2,500 tokens · 6,000 queries/mo

Cohere embed-v3.0 multilingual (1,024d) + Gemini 2.5 Flash. Chunk 800, overlap 100, top-k 5. Rs 300/USD. Token counts assume a 2.5× Sinhala inflation over the English word count.

  1. Total tokens: 800 × 2,500 = 2,000,000 (the same pages in English only would be ~800,000)
  2. Step: max(1, 800 − 100) = 700
  3. Chunks: ceil(2,000,000 / 700) = 2,858
  4. Indexing: (2,000,000/1e6) × $0.10 = $0.20 one-time
  5. Storage: 2,858 × 1,024 × 4 = 11.71 MB → 0.010902 GB × $0.33 = $0.0036/mo
  6. Gen input/query: 250 + 40 + (5 × 800) = 4,290 tokens
  7. Gen cost/query: 4,290/1e6 × $0.30 + 600/1e6 × $2.50 = $0.002787
  8. Monthly queries: 6,000 × $0.002791 = $16.75
  9. Monthly total: $16.75 + $0.0036 ≈ $16.75 (≈ Rs 5,025) + $0.20 one-time
  10. Lesson: the 2.5× token inflation raised indexing from $0.08 to $0.20 — still
  11. trivial. The real cost of Sinhala is on the query side: longer chunks and
  12. longer questions inflate the input tokens billed on all 6,000 queries.

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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)

ModelVendorUSD / 1M tokensDimensions
text-embedding-3-smallOpenAI$0.021,536
text-embedding-3-largeOpenAI$0.133,072
embed-v3.0 (English / multilingual)Cohere$0.101,024
gemini-embedding-001Google$0.153,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)

ModelVendorUSD / 1M inputUSD / 1M output
GPT-4o miniOpenAI$0.15$0.60
GPT-4oOpenAI$2.50$10.00
Claude Haiku 4.5Anthropic$1.00$5.00
Claude Sonnet 4.5Anthropic$3.00$15.00
Gemini 2.5 FlashGoogle$0.30$2.50
Gemini 2.0 FlashGoogle$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

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 price that has moved, or an edge case the calculator doesn't cover?

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