10 recipes
Code you can paste
The parts of an LLM application everyone writes and nobody enjoys writing. Working code, why it is written that way, and what breaks in the obvious version.
Tokens
Cost
Streaming
Reliability
RAG
Agents
Safety
What these are for
Most code you find for these tasks is a forum answer from two model generations ago that no longer runs, or a documentation snippet that omits the error handling that makes it survive production.
Each recipe here includes the parts that get left out: the abort signal on a stream, the jitter in the backoff, the tool result you must send even when the tool failed, the stop reason you have to check because a truncated answer is not an error.
Where a recipe produces a number — a token count, a cost estimate, a chunk size — it links to whichever of the 102 tools checks it without you writing a script.
The two that matter most
Handling stop reasons prevents the most common silent failure in this field: a truncated answer arriving as a successful request and being rendered to a user mid-sentence.
Retry with backoff is the difference between an application that survives a rate limit and one that turns a brief overage into an outage by retrying from every worker at once.