Qaynaq LABS · TOOLS

LLM COST · GOOGLE · RETRIEVAL-AUGMENTED GENERATION (RAG)

Gemini 1.5 Flash: $1.35/mo

At 10.00M input tokens ($0.75) and 2.00M output tokens ($0.60) per month, on retrieval-augmented generation (rag) workload.

Pricing: $0.075/M input · $0.3/M output · 1,000,000 token context

How this workload behaves

In a Retrieval-Augmented Generation (RAG) workload, the dominant cost driver is the input tokens used to retrieve and pass relevant context to the model. Each user query triggers a retrieval step that fetches documents or snippets, which are then concatenated into the prompt. The output tokens, while significant, are typically smaller in volume compared to the input. This makes the input token pricing and context window utilization critical factors in cost optimization. Models with smaller context windows may require more frequent retrievals or truncation, indirectly increasing input costs, while models with larger windows can reduce the need for repeated retrievals.

Compare against 5 alternatives

ModelVendorMonthly costvs primaryΔ
Gemini 2.0 FlashGoogle$1.351.00×+$0.0000
Gemini 1.5 ProGoogle$22.5016.67×+$21.15
Mistral SmallMistral$3.202.37×+$1.85
GPT-4o miniOpenAI$2.702.00×+$1.35
Claude Haiku 4.5Anthropic$20.0014.81×+$18.65

Recommendation

Stick with Gemini 1.5 Flash as the primary model. It delivers the lowest total cost ($1.35/month) while maintaining a large 1M token context window, which is ideal for RAG where context length directly impacts retrieval efficiency. Alternatives like Mistral Small ($3.20) or GPT-4o mini ($2.70) are 2-3x more expensive with no clear intelligence advantage for this use case. The only comparable model, Gemini 2.0 Flash, offers identical cost but lacks proven RAG performance at scale, making the current choice the safest option.

Cost-saving tactics for this workload

  • Use prompt caching for repeated queries with the same or similar context to avoid reprocessing the same input tokens.
  • Implement context compression techniques (e.g., summarization or chunk filtering) to reduce input token volume without losing critical information.
  • Batch API calls for multiple user queries to amortize the fixed cost of retrieval and model inference across a larger input/output payload.
  • Set a maximum context window (e.g., 500K tokens) to avoid over-fetching irrelevant data, which inflates input costs.
  • Cache retrieval results (e.g., vector DB hits) to avoid redundant queries and reduce the need for large context windows.

About LLM API cost planning

LLM API costs scale linearly with token volume, but the right model for your workload depends on three axes: intelligence, speed, and price. Picking the cheapest model can mean paying for outputs that don't meet quality thresholds; picking the most expensive can mean burning budget on tasks a smaller model would have solved.

The Qaynaq Labs LLM Cost Calculator combines deterministic pricing math with workload-aware recommendations across 20+ models from Anthropic, OpenAI, Mistral, Google, Meta (via Groq), Cohere, DeepSeek, and xAI. Plug in your monthly token volume, pick your workload, and see exact monthly cost plus alternatives ranked by total.

Frequently asked

Why is the input token cost so much higher than output in RAG?

RAG requires retrieving and embedding large chunks of context (e.g., documents, snippets) for each query, which are then passed as input tokens. The output is typically a concise answer or summary, resulting in fewer tokens.

Would a smaller context window model reduce costs further?

Not necessarily. A smaller context window may force more frequent retrievals or truncation of relevant context, potentially increasing input token usage and offsetting savings. The 1M token window of Gemini 1.5 Flash is optimal for RAG.

Is there a risk of hallucinations with cheaper models like Mistral Small?

While intelligence varies, RAG mitigates hallucinations by grounding responses in retrieved context. For non-critical use cases, Mistral Small may suffice, but for high-stakes applications, the cost difference to Gemini 1.5 Pro ($22.50) is justified.

How does prompt caching work in RAG?

Prompt caching stores the retrieved context (e.g., embeddings or snippets) for reuse across multiple queries. This avoids reprocessing the same input tokens, reducing costs by up to 90% for repeated queries.

Can I use a smaller model for routing queries to reduce costs?

Yes. A lightweight model (e.g., Mistral Small) can triage queries and route only relevant ones to the primary RAG model, reducing overall input/output volume. This adds complexity but can cut costs by 30-50%.