Generative UIs and Structured Streaming
We'll explore hard problems in building rich UIs that rely on streaming data from LLMs. ​Specifically, we'll talk through techniques for rendering **STRUCTURED** outputs from LLMs, with real-world examples of how to handle partially-streamed outputs over incomplete JSON data. We'll explore advanced needs like * Fields that should be required for stream to start * ​Rendering React Components with partial data ​* Handling nullable fields vs. yet-to-be-streamed fields * ​Building high-quality User feedback * ​Handling errors mid-stream
Project details
Open in GitHubMoving beyond basic token-by-token streaming to create fluid, interactive, and truly modern AI user experiences with semantic streaming of structured objects.
Episode Summary
This week's 🦄 ai that works session dove into one of the most underrated aspects of building great AI apps: Streaming.
We explored how to go beyond basic token-by-token streaming to create fluid, interactive, and truly modern user experiences. The session covered practical implementations using NextJS, FastAPI, and more, demonstrating how semantic streaming can transform your AI applications.
The key insight: streaming isn't just about showing text faster—it's about building better apps. By streaming semantically valid, partial objects instead of broken JSON chunks, you can create interactive UIs that respond in real-time and give users control.
The One Thing to Remember
The difference between a good and a great AI app is often the user experience. Move beyond streaming raw tokens and start streaming structured, semantically valid objects. It simplifies your frontend code and unlocks a new level of interactivity for your users.
Key Takeaways
- Stop Streaming Broken JSON: The BAML approach provides a stream of semantically valid, partial objects, so at every step, your application has a real, usable data structure to work with
- Control Your Stream Declaratively: Control streaming behavior directly in your BAML schema with simple attributes like
@@stream.doneto ensure objects only appear once they're fully formed - Streaming is a UX Superpower: Create interactive UIs that respond in real-time and give users control, not just show text faster
- Enable Parallel Workflows: Get complete, validated objects as they're generated, allowing downstream tasks to start immediately while generation continues
Live Demos
- Recipe Generator Demo - See semantic streaming in action
- Interactive Todo List - Experience real-time structured updates
Resources
- Session Recording
- Code Examples on GitHub
- Blog Post: Semantic Streaming
- Discord Community
- Sign up for the next session on Luma
Next Session
AI That Works: Bash vs. MCP - Token Efficient Coding Agent Tooling - September 16, 2025
We'll explore what's better for helping coding agents do more with fewer tokens:
- The token efficiency and downsides of JSON for agent tooling
- Writing your own drop-ins for MCP tools
- Advanced tricks like using
.shimsto forceuvinstead ofpiporbuninstead ofnpm
Whiteboards
Token based streaming (note each digit comes out in sequence - 1, 10, 100, etc)
Semantic streaming (note each digit only comes out when it's complete)
See if you spot the difference here between token streaming vs semantic streaming
https://github.com/user-attachments/assets/78c83f23-130b-4a41-89ff-7a24aee4e596













































































