Working with LLM APIs · TRACK 03/05
Streaming & Structured Outputs
Tokens as they arrive, and JSON you can actually parse.
// THE TRACK
01 · START HEREStreaming & SSEUnderstand how token-by-token streaming works over server-sent events and how to consume a stream without mangling the output.BEGINNERStructured OutputsUnderstand how JSON mode and schema-constrained generation let you treat an LLM's response as reliable structured data your code can directly consume.INTERMEDIATEJSON Mode vs Structured vs FunctionsUntangle the three JSON-extraction mechanisms, what each one actually guarantees, and a simple rule for picking the right one.INTERMEDIATEParsing Stream EventsLearn the actual event shapes a stream emits and how to accumulate deltas into a complete message, capture the stop reason, and read final token usage.INTERMEDIATEStreaming Structured OutputUnderstand why streaming and strict JSON pull in opposite directions and the partial-parse patterns that let you show progress before the object is complete.ADVANCEDStreaming vs Non-StreamingDecide when token-by-token streaming is worth its extra complexity and when a simple blocking call is the better, more reliable choice.INTERMEDIATEMid-Stream ErrorsLearn what to do when a stream dies after it starts — detecting the failure, salvaging partial output, and retrying safely without paying twice.ADVANCEDInstructor + PydanticYou will understand how Instructor uses Pydantic models to extract validated, typed data from LLMs, retrying automatically when a response fails validation.INTERMEDIATEOutlinesYou will understand how Outlines constrains an LLM's token sampling so the output is guaranteed to match a JSON Schema, regex, or grammar.INTERMEDIATEBAMLYou will understand how BAML lets you define LLM functions in a dedicated DSL that compiles to type-safe Python, TypeScript, or Go with reliable structured outputs.INTERMEDIATEZodYou will understand how Zod defines TypeScript schemas that validate and type LLM responses at runtime, and why it became the standard schema layer for JS/TS AI apps.INTERMEDIATE