Skip to content
Greatest Calculators

RAG Cost Calculator

Estimate what retrieval-augmented generation costs: embedding your documents once, keeping them fresh, storing the vectors and answering each question. Prices come from the providers' own pages, with the date they were read.

Estimated monthly RAG cost

$276.90per month

text-embedding-3-small + GPT-6.1 Sol · 30,000 questions a month

One-off indexing
$0.33
Per 1,000 questions
$9.23
Biggest cost
44.7%

Retrieved context (input tokens)

Your documents
tokens

About 750 words of English is 1,000 tokens.

tokens
tokens

Overlapping tokens are embedded and stored twice.

Embedding and storage

1,536 dimensions by default; the API's dimensions parameter can shorten the vector. Standard tier; Batch is priced separately. Read October 27, 2026.

$
$

Pinecone storage on the Standard plan, read October 27, 2026. Its $50 monthly plan minimum goes in Other monthly costs.

%

The share of the corpus that changes each month.

Questions and answers

Standard pricing for prompts up to 272K input tokens (longer prompts cost 2× input and 1.5× output). Batch, Flex, Fast, Ultrafast and regional uplifts excluded. Read October 27, 2026.

30,000 is about 1,000 a day.

Often called k, or top-k.

tokens
tokens
tokens

Include billed thinking tokens.

Generation rates, prompt caching and other costs
$
$
$
$
%

Hits pay the cached price; misses pay the cache-write price. Providers cache only prefixes above a minimum length (512 to 4,096 tokens).

$

Vector-database plan minimum, read units, reranking, hosting.

Biggest cost: Retrieved context (input tokens), $123.75 a month (44.7% of the total). Halving it would save $61.88 a month, 22.3% of the total. To halve it, retrieve fewer or smaller chunks, or use a model with a lower input price.

Where the monthly cost goes

  • Re-embedding changed documents$0.0165 · <0.1%
  • Embedding the questions$0.03 · <0.1%
  • Vector storage$0.1029 · <0.1%
  • Retrieved context (input tokens)$123.75 · 44.7%
  • Instructions and question (input tokens)$33.00 · 11.9%
  • Answers (output tokens)$120.00 · 43.3%
  • Other monthly costs$0.00 · 0%
Total per month$276.90

Indexing the corpus (the embedding cost)

Chunks
40,000
Average chunk
413 tokens
Tokens in the documents
15,000,000
Tokens embedded (overlap included)
16,500,000 (+10%)
One-off embedding cost
$0.33
Re-embedded each month
825,000 tokens
Vector storage
0.31 GB

Each question

Chunks retrieved
5
Retrieved context
2,063 tokens
Input tokens sent to the model
2,613
Variable cost per question
$0.009226

Price sources

Embedding and storage prices read October 27, 2026; generation presets read October 27, 2026. Standard prices; confirm with the provider before you commit.

What this calculator assumes
  • Every question and every chunk is the average one; fixed-size chunks with a sliding overlap.
  • Vectors are 32-bit floats (4 bytes per dimension); stored text is about 4 bytes per token of English.
  • Standard, short-context, direct-API prices in USD; batch, long-context and regional prices are excluded.
  • Vector-database read and write units, index overhead, replicas, reranking and hosting are not modelled: add them to Other monthly costs.
  • Prompt caching applies to the fixed instructions only; retrieved chunks change with every question.

How this is calculated

I teach data analysis and SQL on The Data Science Tutor.

Formulas, assumptions, and rounding are documented in our calculator methodology.

Built by Will Henschell, data scientist. Formula checked against OpenAI, Anthropic, Google and Pinecone pricing pages and OpenAI's and Google's embedding guides, verified . Editorial policy.

Disclaimer: A planning estimate from average token counts and the prices you enter, not a quote or a bill. Presets use standard short-context prices read on October 27, 2026; providers change prices often, two of the Google prices are promotional, and vector databases bill storage, reads, writes and plan minimums in different ways. Confirm current prices with each provider before you commit.

Where the Money Goes

In most RAG workloads the documents are cheap and the questions are not. Embedding prices are a few cents per million tokens, so even large corpora index for dollars, while every question pays for thousands of retrieved tokens at the generation model's input price. The calculator names the largest line and works out what halving it would save. Retrieving fewer or smaller chunks, a cheaper generation model, shorter answers or prompt caching on fixed instructions usually move the total far more than a cheaper embedding model.

Prices and Sources — Read October 27, 2026

Embedding presets come from OpenAI's model pages (text-embedding-3-small at $0.02 and text-embedding-3-large at $0.13 per million tokens) and Google's Gemini API pricing page (Gemini Embedding 2 at $0.20 per million text tokens). Generation presets are the same constants as the LLM API Cost Calculator, read from OpenAI's, Anthropic's and Google's pricing pages. The storage default is Pinecone's $0.33 per GB-month storage price on its Standard plan. Every one of these prices is checked against its source page each morning, and a change raises an alert so the preset can be corrected.

Assumptions Worth Checking

Every question is treated as the average question, and every chunk as the average chunk. Chunkers that split on sentences or headings make chunks of varying size; the average is what drives cost. If you enter the corpus as total tokens, document boundaries are ignored, which slightly undercounts chunks. Questions answered from your own response cache never reach the model, so enter only the queries that do.

How This Is Calculated

How the Cost Is Calculated

The corpus is cut into fixed-size chunks with a sliding overlap: a document of T tokens with chunks of C tokens and O tokens of overlap becomes 1 chunk if it fits, otherwise ⌈(T − C) ÷ (C − O)⌉ + 1 chunks, and T + (chunks − 1) × O tokens are embedded. Indexing costs the embedded tokens times the embedding price; the monthly refresh costs the churn share of that. Storage is chunks × (4 bytes × dimensions, plus about 4 bytes per token of stored text) ÷ 1,000,000,000 GB, times the price per GB-month. Each question embeds the question, sends k retrieved chunks, the instructions and the question to the model at its input price, and pays the output price for the answer. Monthly cost is the sum of those lines plus any fixed costs.

Formulas

Chunks per document = 1 if T ≤ C, else ceil((T − C) ÷ (C − O)) + 1

Tokens embedded = N × (T + (chunks − 1) × O); indexing = tokens embedded × p_e

Storage = N × chunks × (4 × d + 4 × average chunk tokens) ÷ 10⁹ GB × p_s

Monthly = churn × indexing + storage + Q × (q × p_e + k × chunk × p_in + (I + q) × p_in + A × p_out)

  • N, T documents and tokens per document (count, tokens)
  • C, O chunk size and overlap (tokens)
  • d embedding dimensions (numbers per vector)
  • Q, k questions a month and chunks retrieved per question (count)
  • q, I, A question, instruction and answer tokens per question (tokens)
  • p_e, p_in, p_out embedding, model input and model output prices (dollars per token)
  • p_s vector storage price (dollars per GB-month)

Assumptions and defaults

  • Each vector stores 4 bytes per dimension (32-bit floats), plus about 4 bytes per token of chunk text when the text is stored with it. Source: OpenAI embeddings guide (32-bit float vectors); Pinecone pricing, as of October 27, 2026.
  • Default prices: OpenAI text-embedding-3-small $0.02 per million tokens, Pinecone storage $0.33 per GB-month, GPT-6.1 Sol $2 input and $10 output per million tokens. Source: OpenAI and Pinecone pricing pages, as of October 27, 2026.

Inputs it refuses or treats specially

  • Overlap must be smaller than the chunk size; counts must be whole numbers; churn and cache hit rate must be between 0 and 1.
  • A document no longer than one chunk is one chunk, and a question never retrieves more chunks than exist.

Worked example

10,000 documents of 1,500 tokens in 500-token chunks with 50 overlap: 4 chunks each, 16.5 million tokens embedded, $0.33 to index. With 30,000 questions a month retrieving 5 chunks, the monthly cost is about $276.90, most of it the retrieved context ($123.75) and the answers ($120).

Checked by the test “defaults: $0.33 to index, about $276.90 a month, retrieved context the driver” in src/__tests__/rollout-batch-0012.test.ts.

Check it yourself

The calculation is the function calculateRagCost(input: RagCostInput): RagCostResult | null in src/lib/calculators/ragCost.ts. These lines reproduce the example and print 276.90.

Show the JavaScript and Python

JavaScript

const docs = 10000, T = 1500, C = 500, O = 50;
const perDoc = Math.ceil((T - C) / (C - O)) + 1;
const embedded = docs * (T + (perDoc - 1) * O);
const avgChunk = embedded / (docs * perDoc);
const pe = 0.02 / 1e6, pin = 2 / 1e6, pout = 10 / 1e6;
const gb = docs * perDoc * (4 * 1536 + 4 * avgChunk) / 1e9;
const Q = 30000;
const monthly = 0.05 * embedded * pe  // re-embedding
  + gb * 0.33                         // storage
  + Q * 50 * pe                       // question embeddings
  + Q * 5 * avgChunk * pin            // retrieved context
  + Q * (500 + 50) * pin              // instructions + question
  + Q * 400 * pout;                   // answers
console.log(monthly.toFixed(2));

Python

import math
docs, T, C, O = 10000, 1500, 500, 50
per_doc = math.ceil((T - C) / (C - O)) + 1
embedded = docs * (T + (per_doc - 1) * O)
avg_chunk = embedded / (docs * per_doc)
pe, pin, pout = 0.02 / 1e6, 2 / 1e6, 10 / 1e6
gb = docs * per_doc * (4 * 1536 + 4 * avg_chunk) / 1e9
Q = 30000
monthly = (0.05 * embedded * pe   # re-embedding
    + gb * 0.33                   # storage
    + Q * 50 * pe                 # question embeddings
    + Q * 5 * avg_chunk * pin     # retrieved context
    + Q * (500 + 50) * pin        # instructions + question
    + Q * 400 * pout)             # answers
print(f"{monthly:.2f}")

I teach data analysis and SQL on The Data Science Tutor.

Sources

Last verified October 27, 2026.

45 automated tests cover this calculator. How calculations are documented and checked.

Frequently Asked Questions

How much does a RAG system cost per month?

It depends mostly on queries, not documents. With the calculator's example (10,000 documents of 1,500 tokens, 30,000 questions a month, five chunks of about 413 tokens retrieved per question, GPT-6.1 Sol and text-embedding-3-small), embedding the whole corpus costs about $0.33 once, while answering questions costs about $277 a month, and the retrieved context the model reads is the largest share. Change any input to see your own split.

How do I calculate the cost of embedding my documents?

Count the tokens you will actually send to the embedding model, which is more than the corpus when chunks overlap, and multiply by the model's price per million tokens. 16.5 million tokens at $0.02 per million (text-embedding-3-small) is $0.33. Re-embedding the share of documents that change each month costs that share of the same amount, every month.

Why does chunk overlap increase cost?

Each overlap region belongs to two chunks, so it is embedded twice and stored twice. A 1,500-token document cut into 500-token chunks with 50 tokens of overlap becomes 4 chunks and 1,650 embedded tokens, 10% more than the document. Very large overlaps multiply the corpus: 499 tokens of overlap on 500-token chunks embeds a 1,000-token document about 250 times (each token can land in up to 500 chunks).

How much storage do embeddings need?

Each vector is its number of dimensions times 4 bytes (32-bit floats): 1,536 dimensions take 6,144 bytes and 3,072 take 12,288. If the chunk text is stored with the vector, add about 4 bytes per token of English text. 40,000 chunks of 1,536 dimensions plus their text come to about 0.31 GB. Indexes, replicas and metadata add provider-specific overhead on top.

Does prompt caching lower RAG costs?

It lowers the cost of the part of the prompt that repeats, usually the instructions, not the retrieved chunks, which change with every question. Turn it on and set the hit rate: hits are billed at the provider's cached-input price and misses at its cache-write price. Providers only cache a prompt prefix above a minimum length: 512 tokens on the Claude 5.5 models, 1,024 on OpenAI's GPT-5.6 and later, and 4,096 on Gemini 4 Argon and 3.8 Flash. With Claude Sonnet 5.5 and an 80% hit rate, 2,000 tokens of instructions cost $0.00116 per question instead of $0.004.

What is not included in the estimate?

Read and write units, index overhead and plan minimums on the vector database (Pinecone's Standard plan has a $50 monthly minimum), reranking, batch discounts, long-context surcharges, hosting, and answers served from your own response cache. Put fixed amounts in Other monthly costs and use custom rates for any price the presets do not cover.