systemdesign.academyAI EngineeringFree lessonsSign inGet the course
  1. Home
  2. AI Engineering: Data, RAG and Agents
Previous lessonRAG Evaluation: Localizing Failure Between Retrieval and GenerationNext lessonChoosing an Embedding Model: Why the Leaderboard Is Measuring Someone Else's Documents

System Design

  • Foundation
  • Intermediate
  • Advanced
  • Capstone

AI Engineering

  • Foundation
  • Data, RAG and Agents
  • Evaluation, LLM Ops and Security

systemdesign.academy

  • Home
  • Glossary
  • Interview prep
  • Reviews
  • About
  • Pricing
  • Privacy
  • Terms
  • Refunds
  • Delivery
  • Contact
  • Retrieval and RAG in Production
  • RAG Caching and Cost: Semantic Cache, Embedding Reuse, and the Bill
  • AI Engineering · Retrieval Rag

    RAG Caching and Cost: Semantic Cache, Embedding Reuse, and the Bill

    Free preview: the first part of this 15-part lesson.

    Already bought the course? Sign in to read the whole lesson.

    this lesson is part of

    AI Engineering

    Unlock this lesson and the 199 other paid lessons

    • 210 lessons in 16 chapters
    • 118 lessons built on a lab that really ran
    • An AI tutor beside every lesson that answers and draws
    • Lifetime access, every new lesson included

    $49 once, by PayPal

    See the AI Engineering course

    The rest of this lesson

    1. Four Bills a Plain Chat Call Never Pays
    2. Follow One Request and the Bill Sorts Itself
    3. The Whole Cost Gap Is Context You Chose to Attach
    4. Retrieve Wide, Rerank Down, Stuff Few
    5. A Cache That Matches Questions by Meaning, Not Spelling
    6. The Two Paths, and the One Number That Decides Between Them
    7. The Threshold Is a Precision Dial, and Loose Is Dangerous
    8. Put Your Own Numbers In and Read the Monthly Bill
    9. The Gap Compounds as You Grow, So Fix It Early
    10. Do Not Re-Embed What Did Not Change
    11. The Vector Store Is Infrastructure, and Four Things Drive It
    12. When a Semantic Cache Helps, and When It Quietly Hurts
    13. How Teams Actually Run This
    14. Knowledge Check

    read the rest of this lesson in

    AI Engineering

    Unlock this lesson and the 199 other paid lessons

    • 210 lessons in 16 chapters
    • 118 lessons built on a lab that really ran
    • An AI tutor beside every lesson that answers and draws
    • Lifetime access, every new lesson included

    $49 once, by PayPal

    See the AI Engineering course

    Continue this lesson

    in Retrieval Rag

    This lesson is part of the AI Engineering course. Unlock the full course, a separate one-time payment, for lifetime access.

    One-time payment. Lifetime access. No subscription.
    Global
    $49/lifetime

    One-time payment by card or PayPal

    Get Lifetime Access
    Foundation lessons free, try before you buy
    India Special
    India
    ₹999/lifetime

    One-time payment: UPI, card or netbanking

    Get Lifetime Access
    Foundation lessons free, try before you buy
    Every ML Platform lesson, Foundation to Advanced
    Real architecture diagrams with real tool logos
    MLOps, LLMOps, and data engineering in depth
    Quizzes with instant feedback
    Built and reviewed by senior engineers
    Lifetime access, all future content included

    Foundation lessons of this course are free, no payment needed. Try them now

    The Same Answer Now Costs Three Times as Much

    You measured your chat feature at roughly a tenth of a cent per answer. Then you added retrieval so the model would stop making up policy, and the same answer now costs closer to three tenths. Nothing about the model changed. The question the user typed did not get longer. What changed is that every request now carries a few thousand tokens of retrieved context into the prompt, and you pay for those tokens on every single call.

    That is the RAG cost surprise, and it catches teams because the shallow version of this topic talks about the price of an , which is the one number that barely matters. Embedding a query is a fraction of a cent. The bill is somewhere else. It is in the retrieved chunks you stuff into the prompt, which become input tokens metered on the generation call. It is in re-embedding a large corpus every time documents change. It is in the vector store you rent to serve searches at a latency your users tolerate. A RAG request pays several bills a plain LLM call never sees, and if you only optimize the model, you are polishing the smallest line item.

    The token cost engineering lesson in the LLMOps chapter covers the parts every LLM call shares: prompt caching of a stable prefix, output caps, batching, resend growth in an agent loop. This lesson is the part that is unique to . Where does the retrieval money go, and what are the levers that move it: caching whole answers by query similarity, reusing embeddings instead of recomputing them, and cutting the context you send. By the end you will have run two calculators, one that prints your monthly bill with and without a cache, and one that shows exactly how a too-loose cache serves wrong answers.