Black Friday Deals For Authors Are On Now!

Leanpub Header

Skip to main content

Models Make Things Up

Building LLM Features That Survive Production

Models Make Things Up
This book is 100% completeLast updated on 2026-10-14

The model is one box. This book is about every other box: retries, contracts, evals, budgets, guardrails and agents for backend engineers shipping LLM features to production.

Minimum price

$19.00

$19.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
About

About

About the Book

Your LLM demo worked. Then production happened: a provider outage turned into a minute-long spinner, the model invented a refund policy, a retry loop quadrupled the bill, and a user talked the assistant into a discount code.

Models Make Things Up is for backend engineers who have been asked to "add AI" to a real product. It treats the language model as what it is in production: a slow, billed, sometimes-down, occasionally wrong dependency, and shows the engineering that makes features built on it reliable.

What you will learn

  • Treat model calls like any fallible dependency: latency budgets, deadlines, typed errors
  • Turn model text into validated, typed data, and repair once instead of looping
  • Version prompts like code, with the version on every request
  • Retry the right errors with jitter and Retry-After; add circuit breakers and tested fallbacks
  • Let models trigger actions without double refunds: idempotent tool calls
  • Know the cost of every request, cache safely, and stop runaway spend with budgets
  • Stream, queue or batch depending on who is waiting
  • Build evals that catch regressions before users do
  • Log enough to debug without leaking personal data
  • Measure RAG retrieval separately from answers
  • Contain prompt injection by limiting what the model can do, see and trigger
  • Use AI near money safely: the model is an analyst, not a cashier
  • Put agents on a leash: step, cost and time limits, escalation
  • Roll out with shadow mode, flags and a kill switch, and design an LLM system in 45 minutes

What is inside: 14 chapters, 5 appendices (glossary, production-readiness checklist, LLM API error taxonomy, eval set template, sources), 9 diagrams, and an Interview Corner, Production checklist and TL;DR in every chapter. Every Go snippet comes from a companion repository (standard library only, every package tested). PDF (146 pages) and EPUB.

No model rankings, no hype. Provider-agnostic engineering that stays useful when models change.

Who it is for: backend engineers and tech leads building or reviewing LLM features, and engineers preparing for "design a system with an LLM" interviews.

Who it is not for: people looking for ML theory, fine-tuning, or a prompt-tricks collection.

Facts that can change were checked October 2026. All incidents are composites.Code you can run today

Every Go snippet in the book comes from the open-source companion repository, github.com/AlwyAbdullah/models-make-things-up: 20 packages covering all 14 chapters, standard library only, every package tested in CI. go run ./cmd/kiko runs the whole book in one request flow, offline and with no API key: a provider outage answered by the fallback chain, a cached repeat, a refund that runs once, and a prompt-injection attempt whose made-up discount code is blocked before it reaches the customer.

Read the code for free. Buy the book for the why: the incidents behind each pattern, the trade-offs, and when a pattern is overkill.

Table of contents

  • Introduction: The Demo Worked. Production Didn't.
  • Part I: When the Model Is a Dependency. 1. The Least Reliable Dependency You Have · 2. Contracts for a Probabilistic API · 3. Prompts Are Code
  • Part II: Calls That Survive. 4. Timeouts, Retries and Fallbacks · 5. When the Model Can Do Things · 6. The Bill Is a Feature · 7. Streaming, Queues and Background Work
  • Part III: Knowing It Works. 8. Evals Before Vibes · 9. Observability Without Leaking Secrets · 10. Retrieval Without the Hype
  • Part IV: Safety, Money and Agents. 11. Prompt Injection Is an Architecture Problem · 12. When AI Touches Money · 13. Agents on a Leash · 14. Shipping It, and Designing One in 45 Minutes
  • Appendices: Glossary · Production-Readiness Checklist · LLM API Error Taxonomy · Eval Set Template · Further Reading and Sources

Part of a series: Agents Never Sleep (running agents in production) and The Tool Layer (MCP servers and agent tools). Each book stands alone.

Bundle

Bundles that include this book

Author

About the Author

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub