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
| Model | Vendor | Monthly cost | vs primary | Δ |
|---|---|---|---|---|
| Gemini 2.0 Flash | $1.35 | 1.00× | +$0.0000 | |
| Gemini 1.5 Pro | $22.50 | 16.67× | +$21.15 | |
| Mistral Small | Mistral | $3.20 | 2.37× | +$1.85 |
| GPT-4o mini | OpenAI | $2.70 | 2.00× | +$1.35 |
| Claude Haiku 4.5 | Anthropic | $20.00 | 14.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.