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

Course overview

LLM Cost Engineering

Free · sign in to start and track progress

1 · Spending less on the same work

  • 1Token economics of an agent fleet

    Exercise answers

    • Answer: Build a per-matter cost model from usage logs
    • Answer: Calibrate the model against real token counts
  • 2Prompt caching as system design
  • 3Trimming and compacting context
  • 4Batch, flex and fast tiers

2 · Changing the model, and governing the spend

  • 5Cost-quality curves, routing and cascades
  • 6Distilling into small models
  • 7Self-hosting break-even
  • 8Attribution, budgets and alerts
CapstoneCost-engineer an agent pipelineReference implementation

Module 1 · Spending less on the same work · Lesson 1

Token economics of an agent fleet

What 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.

70 min 1 video 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uv

By the end of this lesson you can

  • Write the cost of a model call in terms of uncached input, cache writes, cache reads and output tokens, including thinking
  • Explain why an agent loop's input grows quadratically with steps, and compute it for a given step count and context growth
  • Build a per-step cost model of a case and identify which steps and token classes dominate
  • Compute cost per completed case, including retries, human correction and cases that fall through

On this page

  • Intuition: the fixed-fee problem
  • The cost of one call
  • Tokens you don't see
  • Why agents re-read: the quadratic term
  • Thinking costs twice
  • A worked example: one leasehold purchase
  • Cost per completed matter
  • Where the levers act
  • Misconceptions and limits
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Intuition: the fixed-fee problem
  2. 02The cost of one call
  3. 03Why agents re-read: the quadratic term
  4. 04A worked example: one leasehold purchase
  5. 05Cost per completed matter
  6. 06Where the levers act
  7. 07Misconceptions and limits
  8. 08Connections
  9. 09Summary

Sources & further reading

  • FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving PerformancePaper · Chen, Zaharia, Zou · 2023The paper that made LLM cost a research topic. Section 2 surveys price heterogeneity across providers and frames the three families of savings (prompt adaptation, LLM approximation, cascades) that the rest of this course develops.
  • Total Cost of Agency: Exact Attribution of Memory Injection Cost in Multi-Agent LLM WorkflowsPaper · Singh, Priyam, Bhowmick · 2026A recent preprint that decomposes multi-agent workflow cost into base prompt, inference, memory injection and context-accumulation terms. Useful as a model for itemising your own bill; its figures are uncached, so read them as an upper bound.
  • Pricing (Claude API docs)Docs · AnthropicThe price table used throughout this course (base input, 5-minute and 1-hour cache writes, cache hits, output), plus batch, long-context, data-residency and tool-use token overheads. Read the model table and the tool use pricing section.
  • Optimizing for cost and intelligence (Claude docs)Docs · AnthropicAnthropic's measured guidance on cost per completed task, effort sweeps, caching and batching, with numbers from internal benchmarks. The single best companion to this course.
  • Steering thinking (Claude docs)Docs · AnthropicThe Pricing section explains that thinking is billed as output at its full length, not the summarised length you see, and that thinking blocks kept in context are billed again as input.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 9 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks