RAG Chunking & Embedding Cost Calculator

Last updated

Splits a corpus into chunks document by document: a document of L tokens takes 1 + ⌈(L − C) ÷ (C − O)⌉ chunks of C tokens, with overlap O the chosen share of C, rounded down. Index RAM is chunks × (dimensions × bytes per value + 128 bytes of HNSW links) at FP32, FP16, int8 and binary. Indexing cost is tokens embedded × each model's rate per million; each query adds top-k chunks to the prompt.

Embedding dimensions
Total chunks –
Chunks per document –
Overlap per chunk –
Tokens embedded –
Prompt tokens added per query –
Vector index RAM by precision
Indexing cost by embedding model

Prices last verified October 27, 2026. Figures are estimates in US dollars; confirm with each provider before committing.

Enter how many tokens your corpus holds and how many documents they are spread across, then the chunk size and overlap your splitter uses, the size of your embeddings and how many chunks each query retrieves. The calculator counts the chunks document by document, sizes the vector index at four precisions, prices embedding the corpus on every listed model that produces vectors of that size, and shows how many tokens retrieval adds to each prompt. If you know your corpus in words or characters rather than tokens, convert it first with the LLM token calculator.

How the chunks are counted

A splitter slides a window of C tokens along each document and moves it on by the stride, the chunk size less the overlap O, until the window reaches the end. The overlap is your percentage of the chunk size rounded down to whole tokens, so the window always moves. A document no longer than one chunk stays whole, and a longer one takes as many more windows as it needs to cover what the first leaves over:

chunks per document = 1 + ⌈(L − C) ÷ (C − O)⌉

L is the average document length, the corpus divided by the number of documents. Every chunk after a document's first repeats O tokens of the one before it, so the embedding model reads the whole corpus plus one overlap for each of those chunks.

The defaults describe 100 million tokens in 50,000 documents of 2,000 tokens each, cut into 512-token chunks with 25% overlap. The overlap is 128 tokens and the stride 384, so each document takes 1 + ⌈1,488 ÷ 384⌉ = 5 chunks: four full ones and a fifth holding the last 464 tokens. That makes 250,000 chunks. The four repeated overlaps in each document add 25.6 million tokens, so 125.6 million reach the embedding model. Read as one continuous text, the same corpus would make 260,417 chunks, 4% too many, and with 1,000-token documents and 10% overlap the error runs the other way, 28% too few. Chunks stop where documents stop, which is why the calculator asks how many there are.

Where chunks came from

Cutting a corpus into equal pieces is older than the vector database. For Dense Passage Retrieval, published in 2020, Vladimir Karpukhin and colleagues took the English Wikipedia dump of 20 December 2018 and split every article into disjoint blocks of 100 words, 21,015,324 passages, each prefixed with its article's title and embedded as a 768-dimension vector. Building the FAISS index over them took 8.5 hours on a single server. Patrick Lewis and co-authors reused those passages in the 2020 paper that named retrieval-augmented generation: "Each Wikipedia article is split into disjoint 100-word chunks, to make a total of 21M documents." They retrieved five or ten per query in training, and the index needed about 100 GB of memory until compression brought it down to 36 GB.

Overlap arrived with the frameworks that made retrieval routine, and their defaults still disagree. LangChain's text splitters cut 4,000-character chunks with 200 characters of overlap, LlamaIndex's sentence splitter 1,024 tokens with 200, and OpenAI's file search 800 tokens with 400, the most its API allows, since overlap may not exceed half a chunk. Microsoft measured the trade-off for Azure AI Search in 2023. On its own benchmark of customer queries, using ada-002 embeddings, 512-token chunks recalled more than 1,024-, 4,096- or 8,191-token ones, and 25% overlap edged out 10%. Its documentation now recommends starting at 512 tokens with 25% overlap, 128 tokens, which are this calculator's defaults.

Embedding has become cheap along the way. OpenAI's first-generation embedding models, shut down on 4 January 2024, cost $4 to $200 per million tokens. The replacement its deprecations page names, text-embedding-3-small, costs $0.02. The third generation also takes a dimensions parameter that shortens its vectors, and OpenAI reports that text-embedding-3-large cut to 256 dimensions still outscores the 1,536-dimension text-embedding-ada-002 on the MTEB benchmark.

How much memory the index needs

HNSW, the graph index most vector databases search by default, keeps every vector in memory together with links to its nearest neighbours. At FP32 each dimension takes four bytes, so a 1,536-dimension vector takes 6,144. The links depend on M, the number of neighbours each vector keeps. Malkov and Yashunin's HNSW paper found twice M a good limit on the bottom layer, hnswlib allows exactly that, and M defaults to 16 in hnswlib, Qdrant and pgvector, so each vector carries 32 neighbour IDs of four bytes: 128 bytes. hnswlib's documentation puts the graph at roughly M × 8 to 10 bytes per stored element, and Qdrant's capacity guide sizes it as m × 2 × 4 bytes plus 20%. The calculator counts the bare 128 bytes and leaves out the upper layers, IDs and headroom.

index RAM = chunks × (dimensions × bits ÷ 8 + 2 × M × 4 bytes)

Quantization shrinks only the vectors. FP16 halves them, int8 scalar quantization cuts them by a factor of 4, and binary quantization, which keeps one bit per dimension, by a factor of 32. The links stay the same size, so at 1,536 dimensions a binary vector is 192 bytes of data and 128 of links, and the index shrinks 19.6 times rather than 32: 1.46 GiB at FP32 against 76.29 MiB at the defaults. The quantized rows assume the full-precision vectors stay on disk to rescore the best candidates, the layout Qdrant recommends for saving memory. In Hugging Face's 2024 tests across 15 MTEB retrieval benchmarks, a 1,024-dimension model kept 92.53% of its performance in binary and 96.45% with rescoring, and about 97% in int8 without it. Qdrant warns that one bit per dimension loses too much below about a thousand dimensions. In pgvector the FP16 row matters for large embeddings: its indexes take vector columns of up to 2,000 dimensions but halfvec columns of up to 4,000, so 3,072-dimension vectors are indexed at half precision or as binary-quantized bits.

What indexing costs, and what each query costs

The rates below are standard prices per million input tokens from OpenAI's and Google's pricing pages, checked in October 2026, and the table reads the same data file as the calculator. OpenAI's batch rates apply the 50% discount of its Batch API, which takes up to 50,000 embedding inputs per batch, so the default corpus would go in five batches. Google lists the batch price of gemini-embedding-2 directly.

Model Provider Per 1M tokens Batch per 1M Sizes in this calculator Note
text-embedding-3-small OpenAI $0.02 $0.01 1,536 1,536 dimensions natively, shortened with the dimensions parameter.
text-embedding-3-large OpenAI $0.13 $0.065 1,536 and 3,072 3,072 dimensions natively, shortened with the dimensions parameter.
text-embedding-ada-002 OpenAI $0.10 $0.05 1,536 Fixed at 1,536 dimensions; the dimensions parameter does not apply.
gemini-embedding-2 Google $0.20 $0.10 1,536 and 3,072 3,072 dimensions by default; Google recommends 768, 1,536 or 3,072.

At the defaults, text-embedding-3-small embeds the 125.6 million tokens for $2.51, or $1.26 in batches, and gemini-embedding-2 charges $25.12. The cost that keeps growing is the context each answer reads. Five chunks averaging 502.4 tokens add 2,512 tokens to every prompt, half a cent at $2 per million input tokens, so 500 queries cost as much as embedding the whole corpus once with text-embedding-3-small. Enter the prompt tokens in the LLM API cost calculator for a monthly bill on current models.

Chunk size pulls the two apart. At 256 tokens the defaults make 550,000 chunks and a 3.21 GiB FP32 index, but five chunks add only 1,200 tokens to a prompt. At 1,024 tokens there are 150,000 chunks in 897.22 MiB, and the prompt grows to 4,187 tokens.

What the estimate leaves out

Every document is treated as the average length. A corpus of many short documents and a few long ones usually makes more chunks than the average suggests, because each short document is still a chunk of its own. Token counts differ between providers, since each tokenizer splits text its own way, and the calculator applies one count to every model. Many pipelines prepend a title or heading path to each chunk before embedding it, which adds tokens to every chunk and every prompt. The RAM covers one copy of the vectors and the bottom layer of the graph; replicas multiply it, and IDs, payloads and filter indexes add to it. To price hosting the same vectors on a managed service, use the vector database cost calculator.

Prices change without notice and figures here are estimates, not quotes; this site is not affiliated with any provider named above. See the site disclaimer.

Frequently asked questions

How many chunks will my documents make?

Slide a window of the chunk size along each document, moving it by the chunk size minus the overlap, and count the windows. At the defaults, 50,000 documents of 2,000 tokens, cut into 512-token chunks with 25% overlap, take five chunks each, 250,000 in all. Read as one long text, the same 100 million tokens would give 260,417, because chunks stop where documents stop.

How much does it cost to embed a billion tokens?

At list prices, $20 with OpenAI's text-embedding-3-small, $100 with text-embedding-ada-002, $130 with text-embedding-3-large and $200 with Google's gemini-embedding-2, and half that in batches. Overlap is billed as well: a billion tokens in 2,000-token documents, cut into 512-token chunks with 25% overlap, becomes 1.256 billion tokens embedded, $25.12 with text-embedding-3-small.

Should I use 1,536 or 3,072 dimensions?

The larger size doubles the vector index, from 1.46 GiB to 2.89 GiB at FP32 with the defaults, while the price per token stays the same, since text-embedding-3-large and gemini-embedding-2 charge one rate at either size. OpenAI reports that text-embedding-3-large cut to 256 dimensions still outscores text-embedding-ada-002 at 1,536 on the MTEB benchmark, so test smaller sizes on your own queries before paying for the memory.

How much memory does binary quantization save?

Less than the 32 times its bit count suggests, because the HNSW graph's links do not shrink. A 1,536-dimension vector takes 6,144 bytes at FP32 and 192 in binary, but each also carries 128 bytes of neighbour links, so the index falls from 6,272 to 320 bytes per vector, 19.6 times smaller. At the defaults that is 1.46 GiB down to 76.29 MiB, with full-precision copies kept on disk for rescoring.

How much overlap should chunks have?

Tools disagree. LangChain's splitters default to 200 characters on 4,000-character chunks, LlamaIndex to 200 tokens on 1,024, and OpenAI's file search to 400 tokens on 800, the most its API allows. Microsoft recommends starting at 25% of 512 tokens, after its 2023 tests found 25% slightly ahead of 10%. Overlap is embedded again: at the defaults, 25% sends 125.6 million tokens to the model against 110.2 million at 10%.

Why does top-k matter more than the embedding price?

Embedding is paid once and retrieval on every query. At the defaults, five chunks add 2,512 tokens to each prompt, half a cent at $2 per million input tokens, so 500 queries cost as much as embedding the whole 100-million-token corpus with text-embedding-3-small. Retrieving three chunks instead of five cuts that recurring cost by 40%.

Sources

  1. Dense Passage Retrieval for Open-Domain Question Answering, ACL Anthology (EMNLP 2020), 2020
  2. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, arXiv, 2020
  3. Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs, arXiv, 2016
  4. HNSW algorithm parameters, hnswlib on GitHub
  5. Capacity Planning, Qdrant
  6. Quantization, Qdrant
  7. pgvector, pgvector on GitHub
  8. Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval, Hugging Face, 2024
  9. Azure AI Search: Outperforming vector search with hybrid retrieval and reranking, Microsoft Tech Community, 2023
  10. Chunk documents, Microsoft Learn
  11. langchain_text_splitters/base.py, LangChain on GitHub
  12. node_parser/text/sentence.py, LlamaIndex on GitHub
  13. Retrieval, OpenAI API documentation
  14. Vector embeddings, OpenAI API documentation
  15. Deprecations, OpenAI API documentation
  16. Pricing, OpenAI API documentation
  17. Batch API, OpenAI API documentation
  18. Gemini Developer API pricing, Google AI for Developers
  19. Embeddings, Google AI for Developers