Skip to content
ByteMath

How much does a RAG application cost to run on an LLM API?

A RAG app answering 5,000 queries a day with 8,000 input and 500 output tokens costs about $4,725 a month at example prices of $3/$15 per million tokens.

Last updated:

Inputs

Cost per month

$4,725.00

Cost per request
$0.0315
Cost per 1,000 requests
$31.50
Cost per year
$56,700
Tokens per month
1,275 M tokens
Share from output tokens
24 %

Results are engineering estimates for planning. Final designs must follow your local code and be checked by a qualified professional.

This scenario at a glance

Input
Requests5,000 per day
Input tokens per request8,000 tokens
Output tokens per request500 tokens
Input price per 1M tokens3 $/1M
Output price per 1M tokens15 $/1M
Share of input served from cache0 %
Discount on cached input90 %
Batch API (50 % off)No (real-time)
Calculated
Cost per month$4,725.00
Cost per request$0.0315
Cost per 1,000 requests$31.50
Cost per year$56,700
Tokens per month1,275 M tokens
Share from output tokens24 %

Engineering notes for this workload

Retrieval-augmented generation (RAG) pipelines send retrieved document chunks to the model with every question, so input tokens dominate. This scenario models an internal knowledge assistant answering 5,000 queries a day, 150,000 a month, with 8,000 input tokens (system prompt, question and roughly eight retrieved chunks of 900 tokens) and 500 output tokens per answer.

At example prices of $3 per million input and $15 per million output tokens, each query costs about $0.0315 and the month about $4,725. Here input is about 76 % of the cost, the reverse of a typical chatbot. The biggest lever is therefore how much context you retrieve, not how long the answers are.

Retrieval tuning pays off directly. Reducing the context from eight chunks to four with a better reranker cuts input by roughly 3,600 tokens per query and the monthly bill by about a third. Smaller, well-segmented chunks, deduplication of near-identical passages and a relevance threshold that drops weak matches all shrink the context without hurting answer quality, and often improve it.

Caching helps when part of the context repeats. If the system prompt and a shared set of reference documents form a stable prefix, prompt caching can bill those tokens at a large discount; the separate page on prompt caching on this site models the same workload with 70 % of the input cached, which roughly halves the cost. Retrieved chunks that change per query cannot be cached that way.

Do not forget the rest of the pipeline. Embedding generation for indexing and for each query, vector database hosting and re-indexing after document updates add cost, though embedding prices are usually small next to generation. For high-volume internal tools, compare the monthly API bill with a dedicated deployment, but include engineering and GPU costs in that comparison.

Log tokens per query from day one; it is the fastest way to spot runaway context.

Reference table

Typical token counts by LLM workload
WorkloadInput tokensOutput tokensNotes
Chat turn with system prompt500–2,000150–600History grows each turn
RAG answer3,000–10,000300–800Retrieved chunks dominate
Document summary2,000–20,000200–500Batch-friendly
Classification / tagging100–5001–20Ideal for small models
Coding assistant10,000–50,000500–3,000Large cached context
Agent tool step5,000–50,000200–2,000Many steps per task

Rule of thumb for English: 1 token ≈ 4 characters ≈ 0.75 words. Other languages and code usually need more tokens per word.

Questions about this scenario

How much does RAG cost per query?

About $0.03 per query in this example: 8,000 input and 500 output tokens at $3/$15 per million tokens.

How can I reduce RAG token costs?

Retrieve fewer, more relevant chunks with a reranker, deduplicate passages, cache stable prefixes and route simple questions to smaller models.

Are embeddings a big part of RAG cost?

Usually not. Embedding prices per token are typically far below generation prices, but re-indexing large corpora adds up.