{T}
TokenMath.net
Information RetrievalVector Ingestion & Inference

RAG Pipeline Cost Calculator

Model the core API and compute costs of your enterprise RAG pipeline: document chunking, vector embedding ingestion, vector search querying, and generation synthesis.

Active Workload Architecture: 2,500 queries/day · 2.5k retrieved tokens · 400 output tokens ·Gemini 3.8 Flash
Standard API Pricing

RAG Corpus & Query Architecture

Ingestion + Retrieval
1. Document Ingestion Phase
Total Documents5,000 docs
Avg Tokens / Doc1,500 tokens
2. Vector Database & Reranking Architecture
3. Synthesis Generation Phase
Daily User Queries2,500
Retrieved Chunks / Query5 chunks (2.5k tok)
User Query Input Tokens150 tokens
LLM Generation Tokens400 tokens
One-Time Ingestion
$0.1500
7.50M tokens embedded (15,000 chunks • 0.11 GB index)
Recurring Monthly TCO
$337.06
75,000 queries/mo (Full Pipeline)
Full Pipeline Cost Per SearchTCO Breakdown
1. Query Vector Embedding:$0.000003
2. Vector DB Query Search IOPS:$0.000000
3. Neural Reranker (cohere):$0.00100
4. LLM Context Ingestion (2.6k tok):$0.00199
5. LLM Answer Generation (400 tok):$0.00150
Monthly Vector Storage Amortization:$0.000003
Total Cost Per User Search:$0.00449 / search
Gemini 3.8 Flash for RAG Synthesis
Verified: $0.75/M in · $3.75/M out · 1.05M ctx
Model Specs
ℹ️ Production TCO Architecture: Calculation reflects end-to-end RAG economics: corpus chunking, embedding generation, vector database cloud storage & indexing, query search IOPS, cross-encoder neural reranking, and synthesis generation.

How Much Does a RAG System Cost to Run?

A RAG pipeline has two cost centers. Ingestion is mostly one-time: you embed your document corpus once (plus updates). Querying is recurring: every question embeds the query, searches the vector database, and sends the retrieved chunks to an LLM. For almost every production system, the LLM generation step is 90%+ of the monthly bill, because retrieved context multiplies the input tokens of every request.

RAG Cost Formula

ingestion = corpus_tokens ÷ 1M × embedding_price
input_per_query = chunks × chunk_tokens + prompt_tokens
monthly_llm = queries × (input_per_query × input_price + output_tokens × output_price) ÷ 1M
monthly_total = monthly_llm + query_embeddings + vector_db_hosting

Worked Example

10,000 documents of 5,000 tokens, embedded with text-embedding-3-small, answering 100,000 questions a month with Gemini 3.8 Flash. Each query retrieves 5 chunks of 500 tokens and generates 400 output tokens.

One-time ingestion (50M tokens)$1.00
Monthly LLM input (300M tokens)$225.00
Monthly LLM output (40M tokens)$150.00
Monthly generation total$375.00

Vector database hosting is extra and varies by provider and index size; query embeddings add well under 1% at these volumes.

How to Reduce RAG Costs

  • Retrieve fewer, better chunks. Reranking to 3 chunks instead of 8 cuts input tokens by more than half.
  • Cache the static prefix. System prompts and instructions qualify for prompt caching discounts of up to 90%.
  • Route easy questions to a cheaper model. See the cheapest model finder.
  • Batch offline re-indexing. Batch APIs discount embedding and generation jobs by about 50%.

For the architecture behind these numbers, read the RAG cost architecture guide.