Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

  1. AI Academy
  2. /
  3. Path 4
  4. /
  5. LLM Cost Engineering
AdvancedFree coursePath 4 · Production AI at Scale · Part 4 of 4

LLM Cost Engineering

Know what each case costs in tokens, then cut that cost with caching, trimming, batching, routing, distillation and self-hosting, without losing quality.

2 modules · 8 lessons~20 hoursUpdated 2026-10-30Certificate included

See the curriculum
  • Lessons8
  • Quizzes8
  • Sources49
  • Of study~20h

About this course

About this course

An advanced course on the economics of an agent fleet. You build a per-step cost model of one case, then work through the levers in the order they usually pay: prompt caching designed at the system level, context trimming and compaction, batch and service tiers, model routing and cascades measured against a cost-quality curve, distillation into small open-weight models, and the break-even point for self-hosting on rented GPUs. The course ends with attribution: a per-customer, per-case cost ledger with budgets and alerts. Every lesson recomputes real prices and token counts in Python, cites the papers and docs behind each claim, and gives you exercises to run with Claude.

About the running example

The examples follow a fictional property-law (conveyancing) firm in England and Wales: what one property transaction costs, step by step, across a fleet of agents. It's a case study, chosen because its documents are long, structured and high-stakes. You don't need a legal background, and the same patterns apply to contracts, insurance claims, invoices, support tickets or patient records. In the lessons, a matter is one client's case and a solicitor is the lawyer who signs work off.

Outcomes

What you'll learn.

  1. 1Build a per-step token and cost model of an agent pipeline, and compute cost per completed case including thinking tokens, retries and failures
  2. 2Design prompt layouts, cache lifetimes and scheduling so that cache hit rates stay high across a fleet, and decide when trimming or compaction lowers cost
  3. 3Move the right workloads to batch and service tiers, and price the trade-off in latency and data handling
  4. 4Measure a cost-quality curve with evals and decide whether a router, a cascade, a distilled model or a single tuned model sits on its frontier
  5. 5Compute the break-even point for self-hosting an open-weight model on rented H100 or B200 GPUs against serverless and batch prices
  6. 6Attribute every token to a customer, case, agent and step, reconcile it with the invoice, and enforce budgets and alerts
Curriculum

2 modules, 8 lessons.

9h 40m of lessons

  1. Module 1 · 4 lessons · 4h 40m

    Spending less on the same work

    Model what a case costs, then apply the levers that leave the model choice unchanged: caching, context discipline and cheaper service tiers.

    1
    1. 1Token economics of an agent fleetWhat one case costs in tokens, step by step, why input re-reading and thinking dominate agent bills, and how to turn per-call prices into cost per completed case.1h 10m7-question quiz5 sources
    2. 2Prompt caching as system designTurning a per-request cache into a fleet-wide strategy, with layered prefixes, cache-aware scheduling, the arithmetic of cache lifetimes, and hit rate as a monitored objective.1h 15m6-question quiz6 sources
    3. 3Trimming and compacting contextThe four ways to send fewer tokens (select, clear, compact, compress), how each one interacts with the prompt cache, and the break-even arithmetic that tells you when trimming saves money and when it costs more.1h 10m6-question quiz6 sources
    4. 4Batch, flex and fast tiersPaying half price for work nobody is waiting for and a premium for work someone is, which workflow steps belong in which tier, and how to run batch jobs durably without breaking caching or data-handling commitments.1h 5m6-question quiz6 sources
  2. Module 2 · 4 lessons · 5h

    Changing the model, and governing the spend

    Measure the cost-quality frontier, then decide whether routing, distillation or self-hosting moves you along it, and put every dollar under attribution and budgets.

    2
    1. 5Cost-quality curves, routing and cascadesMeasuring the cost-quality frontier with evals, then deciding whether static routing, a learned router or a cheap-first cascade moves you along it, with the arithmetic that shows when a cascade beats the strong model and when its verifier caps it.1h 20m6-question quiz7 sources
    2. 6Distilling into small modelsWhen training a small open-weight model on a larger model's outputs pays for itself, how the pipeline works from teacher labels to LoRA fine-tuning and serving, and the break-even arithmetic that often says no.1h 15m6-question quiz7 sources
    3. 7Self-hosting break-evenTurning GPU hourly rates and measured throughput into a cost per million tokens, comparing it with serverless and batch prices for the same open-weight model, and finding the utilisation and volume at which running vLLM or SGLang yourself pays.1h 15m6-question quiz6 sources
    4. 8Attribution, budgets and alertsAttributing every token to a customer, case, agent and step through a gateway, an observability tool and your own ledger, allocating shared costs, reconciling with the invoice, and enforcing a hierarchy of budgets with alerts that catch runaway spend.1h 10m6-question quiz6 sources
Capstone

Cost-engineer an agent pipeline

Take a simulated agent fleet from an uncached baseline to a measured, attributed and budgeted pipeline, applying every lever in the course and proving each saving with numbers and evals.

Open the project brief
Certificate · free

Finish it. Get certified.

Complete every lesson of LLM Cost Engineering and you get a certificate with your name on it. Free, like the course.

  • A public page with a certificate ID anyone can check
  • Download it as a PDF
  • Add it to LinkedIn in one click
It also counts towards the Production AI at Scale path certificate, for finishing all 4 courses in Path 4.
Sample
FAQ

LLM Cost Engineering, answered.

Is LLM Cost Engineering free?

Yes, for everyone: all 8 lessons, 8 quizzes, the capstone brief and the certificate are free, with no card and no trial. The hands-on exercises need the tools listed under Prerequisites.

Do I get a certificate?

Yes. Finish every lesson of LLM Cost Engineering and you get a certificate with your name and a certificate ID, on a public page anyone can check. Finishing every course in a learning path earns the path certificate too. You can download each one as a PDF and add it to LinkedIn. They're certificates of completion from the Coders In Hoods AI Academy, not an accredited qualification.

How long does LLM Cost Engineering take?

About 20 hours: 2 modules and 8 lessons, at your own pace. Your progress is saved to your account, on every device.

Which roles is it for?

It's on the AI Engineer and Machine Learning Engineer roadmaps: the courses those jobs ask for, in the order to take them.

What do I need before I start?

LLMs for Engineers, especially the lessons on context and caching, and on choosing models. Agent Foundations and Evaluating and Scoring Agents, or equivalent experience building and evaluating agents. Comfortable writing Python and reading API usage objects.

Role roadmaps

Part of these roadmaps

  • Become an AI Engineer
  • Become a Machine Learning Engineer

Before you start

Prerequisites

  • LLMs for Engineers, especially the lessons on context and caching, and on choosing models
  • Agent Foundations and Evaluating and Scoring Agents, or equivalent experience building and evaluating agents
  • Comfortable writing Python and reading API usage objects
Path 4

More in Production AI at Scale.

See the whole path
  • AdvancedAI agents · Infrastructure

    Infrastructure for Agents

    Run a fleet of agents in production: compute, sandboxes, durable workflows, queues, state, tenant isolation, gateways and safe delivery.

    8 lessons ~16hFree
  • AdvancedAI agents · Security

    Production Agent Systems

    Take an agent from working demo to a system you can run for months: architecture, security, compliance, observability and safe change.

    6 lessons ~18hFree
  • AdvancedAI · Reliability

    Scaling AI Systems

    Keep a fleet of agents fast and available under real load: rate limits, flow control, retries, backpressure, caching, failover, latency budgets, load tests and capacity plans.

    7 lessons ~18hFree