Level 7: Streaming — Briefing
Advanced Streaming — Custom Data Parts, Message Metadata, Stream Transforms, and Error Handling for production apps. You’ll learn how to transport structured data alongside text in the stream, cleanly separate metadata from LLM content, smooth out stuttering streams, and catch errors without crashing your app.
Skill Tree
Section titled “Skill Tree”What You’ll Learn
Section titled “What You’ll Learn”- Custom Data Parts — transport structured data alongside text in the stream (progress bars, status updates, sources)
- Message Metadata — attach additional information to messages that the LLM doesn’t see
- Stream Transforms — smooth out stuttering streams with
smoothStreamand write custom transforms - Error Handling — catch errors in the stream, user-friendly messages, and retry strategies
Why This Matters
Section titled “Why This Matters”In Level 1 you learned about streamText — writing tokens to the terminal one by one. That’s enough for prototypes. In production you need more: structured data alongside the text, clean metadata separation, smooth output, and robust error handling.
The concrete problem: your stream delivers only raw text. But your UI needs progress indicators, source citations, and status updates — and when the provider crashes mid-stream, your user sees a blank page.
Prerequisites
Section titled “Prerequisites”- Level 1: AI SDK Basics — specifically
streamText,textStream, andfullStream(Challenge 1.4) - TypeScript — async/await, AsyncIterable, Generics
- Basic understanding of Web Streams —
TransformStream,ReadableStream(helpful but not required)
Working directory: Create a new folder
level-7-streaming/(or work in your existing project directory). No new packages needed —aiand@ai-sdk/anthropicfrom Level 1 are sufficient.
Skip hint: You’re already using
smoothStream, Custom Data Parts, andonErrorin production? Jump straight to the Boss Fight and test your knowledge.
Challenges
Section titled “Challenges”Boss Fight
Section titled “Boss Fight”Build a Real-Time Dashboard: A streaming system that sends Custom Data Parts for status updates, uses Message Metadata for session tracking, applies smoothStream for smooth output, and catches errors gracefully — all in one project.