Preface
Every AI feature demos beautifully.
You wire a model into a controller, type a sentence, and something remarkable comes back. The room goes quiet. Somebody says ship it.
Then it meets production, and you discover that the remarkable part was never the hard part. The hard part is the request that took ninety seconds. The one that came back as prose when you asked for JSON. The one where a user pressed the button eleven times and each press cost you money. The one where the model, asked politely, created the same paid resource twice.
None of those are AI problems. They are the ordinary engineering problems you already know how to solve — timeouts, idempotency, rate limits, trust boundaries, retries — wearing an unfamiliar hat.
That is the whole argument of this book.
The model is the least interesting part of your AI feature.
What This Book Is About
This book is about building AI features in Laravel that survive real users: features that cost what you expected, fail in ways you planned for, and can be handed to another developer without a séance.
It uses a production system as its running example — a platform where a conversational agent gathers what somebody wants, checks it, verifies their email, and provisions a real, live, billable website while they watch. That agent calls tools. Those tools have side effects that cannot be taken back. It has been wrong, it has been slow, and it has been talked into things. Everything in this book was learned by fixing that.
You will not find prompt-engineering folklore here, and you will not find a benchmark of six models. You will find the code around the model: the manager that isolates the provider, the queue job that survives a turn that runs too long, the tool that refuses to create the same thing twice, the logging that tells you what happened when you cannot reproduce it.
Who This Book Is For
This book is for Laravel developers who are comfortable with HTTP, queues, and testing, and who are about to put a model in front of their users — or who already did and are now living with the consequences.
You do not need to know anything about machine learning. Nothing in this book requires it. If you can write a FormRequest, dispatch a job, and fake an HTTP client in a test, you have every skill this book asks for.
You should be suspicious of AI features. That is a qualification, not a flaw.
If you have shipped a chat widget and then watched your provider bill, this book is for you. If you are being asked to add "AI" to a product and you would like the result to still be maintainable next quarter, this book is for you. If your AI feature works and you cannot explain why, this book is very much for you.