Own Weights

RAG cost: embeddings, retrieval and the tokens you add

How much RAG costs to run: embedding calls, vector storage and the extra input tokens each query adds, with a worked per-query example and ways to cut it.

Updated

RAG costs three things per query: an embedding call to turn text into vectors, vector storage and search, and the retrieved text you send to the model with every question. In most designs the last one is the largest line, because retrieved passages often make up most of the prompt.

How much does RAG cost to run?

The bill has two parts. Indexing is the work of splitting documents, embedding them and writing them to a vector store. Serving is the work each user question triggers: one embedding for the question, one vector search, and one model call with the retrieved chunks added to the prompt.

A small internal tool with a few thousand questions a month costs little to run. A customer-facing product with millions of queries a month spends most of its money on the model call, and that call grows with every chunk you add. Storage and search are smaller lines, but they are recurring, and they do not shrink when traffic drops.

Embedding costs at scale

Embedding providers charge per token of text they embed. Cost therefore follows two things: how much text you index, and how often you index it again. The first pass over a large corpus is often the biggest embedding bill.

Re-embedding is the hidden repeat. A new chunk size, a fix to the text cleaning code or a switch to another embedding model means embedding the corpus again. Mixing embedding models inside one index also breaks search, so a model change is a full re-index, not a small update. Embed only the documents that changed, and batch model and chunking decisions together. Check your provider’s current pricing page for rates.

Does RAG increase LLM costs?

Yes. RAG adds input tokens to every query that retrieves text. In a hypothetical with round numbers, a 50-token question plus five retrieved chunks of 500 tokens each comes to 2,550 input tokens. Those retrieved tokens are billed on every call, whether or not the model used them.

The output side can grow too. A model given more context sometimes writes longer answers, and output tokens are the more expensive ones. RAG adds little cost when the retrieved text is short and the questions are simple, so measure your own prompts instead of guessing.

Retrieval augmented generation cost per query

Here is a hypothetical with round numbers. Assume 100,000 queries a month. Each query sends a 100-token question plus 2,500 tokens of retrieved text, so 2,600 input tokens per query and 260 million input tokens a month.

At the Claude Opus list price of $4 per million input tokens, that input comes to about $1,040 a month, or roughly $0.0104 per query. At the Claude Haiku list price of $0.10 per million input tokens, it comes to $26 a month, or about $0.00026 per query. These figures leave out output tokens, embeddings, storage and search, so the full bill is higher. Your real chunk size and query volume will change the result.

How to reduce RAG token costs

Start with the chunk count. Retrieve more candidates than you need, rerank them, and send only the top few to the model. Smaller chunks waste fewer tokens, but chunks that are too small cut off the context the answer needs, so test both.

Keep the system prompt short. If the prefix of your prompt is the same on every call, prompt caching can cut what you pay for that prefix. For work that can wait, such as nightly re-indexing reports or bulk question answering, Anthropic’s Batch API is half price. See prompt caching savings and batch APIs versus real-time calls for when each one pays.

Fine-tuning is another option when the same narrow task runs on a large retrieved prompt every time. It is not always the answer. RAG is still the right tool when the answers must come from documents that change every day, and fine-tuning versus RAG covers that choice. A corpus small enough to fit in the prompt can also be cheaper with no retrieval step, though long prompts carry their own cost, as long context costs explains.

If you try it, run the RAG setup and the trained model on the same questions with checked answers, and compare cost per correct answer, counting the embedding and retrieval calls on the RAG side, not only the model call. The full method is in how to build a test set.

If you want to see where your own pipeline spends money, run the free AI cost audit in your repository. It reads your code as text on your machine and uploads nothing. Or ask us for a call through the homepage.

Questions

how much does rag cost to run

Price it per query, then multiply by monthly volume. Add the embedding calls for new content, the vector store fee, and the model's input and output tokens. Run those numbers on a sample of real queries before you commit to a design.

embedding costs at scale

Embedding cost follows how much text you embed and how often you embed it again. Plan for re-embedding, because a change to chunk size, cleaning code or the embedding model means paying to embed the corpus again. Batch those changes together and check your embedding provider's current pricing page for the rate.

does rag increase llm costs

Yes, if the retrieved text goes into the prompt. Each chunk is billed as input on every query that includes it. Longer context can also lead to longer answers, and those answers are billed as output.

retrieval augmented generation cost per query

Per query, add the question tokens and the retrieved tokens and multiply by the input rate. Then add the output tokens and the cost of one embedding call. Divide your monthly bill by monthly queries to check the estimate against the real invoice.

reduce rag token costs

Send fewer, better chunks, cache any prompt prefix that stays the same, and move work that can wait to a batch job. Count chunks per query before you change anything else, since that number drives most of the input bill.