Optimization

Reduce costs with engineering tactics

Founding engineers, staff engineers, ML engineers·5 modules · 49 min total

About this course

Cost optimization is an engineering problem, not a finance problem. The highest-leverage changes — prompt compression, caching, model switching, and retrieval optimization — are decisions engineers make every sprint. This course ranks the changes by effort vs savings, shows you how to evaluate model switches without regressions, and teaches you to measure whether the work actually moved the numbers.

What you will learn

  • How to rank optimization tactics by savings vs engineering effort
  • When RAG, fine-tuning, or full-context is the right economic choice for your workload
  • How to switch to a cheaper model without losing user-facing quality
  • How to measure cost improvement by provider, service, and category after rollout

How to use this course: Work through the modules in order for the full picture, or jump to the lesson that matches the problem in front of you right now. Each module is a standalone read — estimated total time is 49 minutes.

Course modules

5 lessons · 49 min total read time

112 min

LLM cost optimization playbook

Prioritize prompt compression, caching, smaller models, batching, and retrieval optimization with a clear savings vs effort ranking.

212 min

RAG vs fine-tuning cost tradeoffs

Choose RAG, fine-tuning, or full-context for knowledge-heavy or behavior-heavy workloads with a clear cost and maintenance comparison.

38 min

Switching to cheaper AI models without losing quality

Use a practical evaluation loop to cut cost while protecting user-facing quality and latency.

49 min

Track and attribute AI costs across your stack

Make optimization work measurable by tying spend to providers, services, categories, and projects across your stack.

58 min

LLM spend tracking for product teams

Use category-level and service-level analysis to see where optimization work will move margin the most.

Frequently asked questions

Answers to the questions teams ask before starting this course.

What is the fastest way to reduce LLM costs?

The fastest wins are usually prompt compression and model tier. Trimming an overgrown system prompt and cutting retrieved context reduce input tokens on every request immediately, and routing tasks that do not need a premium model to a smaller tier can cut per-request cost dramatically. Rank tactics by savings-vs-effort and ship two per sprint rather than attempting everything at once.

How much can a cheaper model actually save?

It depends on the price gap and how much of your volume tolerates the smaller model. At July 2026 rates a small tier can be roughly 15–20x cheaper per token than a flagship, so moving suitable classification, extraction, and simple-summarization workloads down a tier can meaningfully cut inference spend — provided each workflow is evaluated to confirm quality holds before the switch.

Does cutting AI cost hurt quality?

Not if the change is measured. Every cost tactic has a failure mode — over-compressing a prompt, routing a reasoning task to a small model, caching stale answers — so the discipline is to establish a quality baseline, test the change on a held-out sample, and roll out behind an A/B before full traffic. A change that drops quality is a regression with a cost side effect, not an optimization.

How do I prove an optimization actually worked?

Measure cost-per-request for the specific workflow for the 7 days before and after the change, alongside a quality metric from your eval harness. Attribute the change to a provider, service, and category so the improvement is visible in isolation rather than lost in aggregate spend.

Reduce costs with engineering tactics — AI Cost Academy | StackSpend