Skip to main content
RAG cost comes from ingestion-time work and query-time work. Optimize them separately: ingestion cost is mostly embedding and storage, while query cost is retrieval, optional reranking, query rewriting, history compaction, and answer generation.
Model prices and availability change. Treat the local model catalog as package metadata, then verify provider pricing before publishing a production cost estimate.

Query-time cost

Example chat config that keeps context bounded:
SDK

Ingestion-time cost

Reranking cost choices

Rewrite cost choices

Query rewriting is useful for ambiguous follow-ups, but unnecessary for standalone questions. Use a smaller LLM for rewrite when your final answer model is larger.

Maintenance savings

Do not re-ingest everything for every source change. Use stable IDs and a source manifest.
  1. Re-ingest the changed source.
  2. Upsert new chunks by ID.
  3. Delete old IDs that disappeared.
  4. Leave unchanged sources untouched.
See Knowledge Base Maintenance for the full refresh loop.

Practical baseline