RAG Pipeline Cost Calculator
Estimate the monthly cost of a Retrieval-Augmented Generation (RAG) pipeline including indexing, embeddings, and LLM inference.
Did this tool work for you?
How to use this calculator
- 1
Enter the total number of documents in your knowledge base and their average token length.
- 2
Set your expected monthly query volume and how many chunks are retrieved per query.
- 3
Select the embedding model and LLM you plan to use.
- 4
Review the one-time indexing cost and recurring monthly costs.
Frequently asked questions
How is the total monthly cost built?
Total monthly = monthly refresh embedding cost + monthly query embedding cost + monthly LLM cost. The one-time indexing cost is displayed separately and is not added to the monthly total. Cost per query = total monthly ÷ queries per month.
How is indexing cost calculated?
Indexing cost = documents × average tokens per document ÷ 1,000 × the embedding rate. It counts documents, not overlapping chunks, so chunk overlap is not reflected.
What does the monthly refresh assume?
The code assumes 10 percent of the indexing cost recurs each month, as if a tenth of the corpus is re-embedded. It is a fixed assumption with no input, so a corpus that changes faster or slower than that needs a manual adjustment to the document count.
How are query embeddings and LLM tokens counted?
Each query is embedded as a fixed 50 tokens. LLM input per query = chunks retrieved × tokens per chunk + 50, and output per query = the response tokens you enter. Both are priced at the chosen model’s input and output rates.
Which embedding and LLM prices are built in?
Two embedding entries and four LLM entries, listed in the table on this page. They are figures built into this tool, stored per 1,000 tokens. Providers revise prices and retire models, and the LLM entries carry no version numbers, so check current pricing pages.
What does the calculator not include?
Vector database hosting, reranking calls, conversation history, a system prompt beyond the 50 question tokens, query rewriting, chunk overlap, caching and retries are not modelled.
Why does the LLM line dominate the total?
With the default settings it is $19.87 of a $19.93 monthly total, because every query sends several chunks to the LLM and generates a response, while embeddings are priced at a much lower rate. Your own ratio depends on chunks retrieved, chunk size, response length and the model chosen.
How can I model a larger or smaller knowledge base?
Change documents and average tokens per document for the one-time indexing cost, and change queries, chunks and chunk size for the monthly lines. The monthly refresh scales with the indexing cost, so it moves with those two inputs.
RAG pipeline cost calculator: indexing, query embeddings and LLM calls
Four cost lines
The calculator separates a one-time indexing cost from three monthly lines. Indexing = documents × average tokens per document ÷ 1,000 × the embedding rate. The monthly refresh assumes 10 percent of that indexing cost recurs each month for changed documents. Each query is embedded as a fixed 50 tokens. The LLM line charges retrieved chunks × tokens per chunk plus 50 tokens for the question as input, and the response length as output. Total monthly = refresh + query embedding + LLM; the one-time indexing cost is shown but not added to it.
Rates stored in the code
These are figures built into this tool, expressed per 1,000 tokens in US dollars. Providers revise prices and retire models, and the Claude entries carry no version number, so check each current pricing page before using a result in a budget.
| Entry | Input or embedding rate | Output rate |
|---|---|---|
| text-embedding-3-small | $0.00002 | — |
| ada-002 | $0.0001 | — |
| GPT-4o-mini | $0.00015 | $0.0006 |
| GPT-4o | $0.0025 | $0.01 |
| Claude Haiku | $0.00025 | $0.00125 |
| Claude Sonnet | $0.003 | $0.015 |
Worked examples
RAG cost runs. The columns show Run, Indexing (one-time), Refresh, Query embedding, LLM, Total monthly and Per query, one line per case.
| Run | Indexing (one-time) | Refresh | Query embedding | LLM | Total monthly | Per query |
|---|---|---|---|---|---|---|
| 10,000 docs × 500 tokens, 50,000 queries, 5 × 200-token chunks, 400-token reply, 3-small, GPT-4o-mini (defaults) | $0.10 | $0.0100 | $0.0500 | $19.87 | $19.93 | $0.00040 |
| 200,000 docs × 800 tokens, 300,000 queries, 8 × 300-token chunks, 500-token reply, ada-002, GPT-4o | $16.00 | $1.6000 | $1.5000 | $3,337.50 | $3,340.60 | $0.01114 |
| 5,000 docs × 1,000 tokens, 10,000 queries, 3 × 250-token chunks, 250-token reply, 3-small, Claude Haiku | $0.10 | $0.0100 | $0.0100 | $5.13 | $5.14 | $0.00051 |
Where the money goes
In all three runs the LLM line dominates: $19.87 of $19.93 in the default case and $3,337.50 of $3,340.60 in the large run. Indexing a corpus is cheap by comparison, so the levers that move the bill are chunks retrieved per query, chunk size, response length and model choice. In the large run each question sends eight 300-token chunks plus the question, and generates a 500-token reply, on a higher-priced model. Retrieving fewer or smaller chunks, if answer quality holds on your data, is the first change worth testing.
Not in the estimate
Vector database hosting, reranking calls, conversation history, a system prompt, query rewriting and chunk overlap are not modelled, and indexing counts documents rather than overlapping chunks. The 10 percent monthly refresh and the 50-token query are fixed assumptions in the code, so a corpus that changes heavily or users who write long questions would cost more than shown. Adjust the document and chunk inputs upward to approximate those effects, and compare with a real invoice after launch.
Learn more from an authoritative source:
OpenAI Platform DocsGPU Cloud Cost Calculator
Compare GPU rental costs across AWS, GCP, Azure, Lambda Labs, and Vast.ai for ML training and inference workloads.
AI Chatbot ROI Calculator
Calculate the return on investment of deploying an AI chatbot for customer support, including payback period and annual ROI.
LLM Latency Calculator
Estimate expected LLM response latency — time-to-first-token and total response time — for planning real-time AI applications.
AI Token Counter
Estimate the number of tokens in your text for GPT-4, Claude, Gemini, and other LLMs. Useful for staying within context limits.
AI Prompt Cost Calculator
Calculate the cost of an AI API call based on input/output tokens and model pricing.
Words to Tokens Converter
Convert between words, characters, tokens, and pages for AI models and content planning.
Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →