Chunking the Reply Into Deltas
delta chunking
Part of: Streaming Writing Assistant
Real model APIs don't send you whole words at civilized boundaries. They send deltas : small, arbitrary-sized pieces of text that arrive as the model produces them. Sometimes a delta is a whole word, sometimes half a word, sometimes just punctuation. Your job as the client is to not care, and to concatenate everything in order. What a delta actually is A delta is whatever text arrived in this event. Nothing promises it aligns with words, sentences, or anything meaningful on its own: That might print 'Ra', then 'in', then ' falls', then ' softly', with unpredictable boundaries every run. This is why lesson 2's endpoint re-frames whatever it receives instead of buffering up to word boundaries. The API already decided the chunking; you just relay it. Order is the only thing that matters Deltas are meaningless individually and only make sense concatenated in arrival order . Drop one, skip one, or reorder two, and the final text is corrupted. There's no close enough. The whole contract is: receive in order, join with nothing in between, done. No spaces added, no separators. The deltas already contain any spacing the model produced. Adding your own separator between deltas is one of the
Challenge: Split Into Deltas