Skip to content
Optimal Lab

AI Native · interactive

Streaming UI and partial results

The model writes a JSON answer a few characters at a time. Wait for it all, show the raw text, or parse each partial chunk and render what you can. Press play.

0/24 chunks0 ms

Waiting for the first token…

Received so far

—

At 0 ms: parsed what's arrived so far and closed the open brackets.

Rendering

0 ms

Step 3 of 4

  1. 1

    Time to first token matters most

    Generation takes seconds. Streaming shows progress after a few hundred milliseconds instead.

    Perceived speed beats raw speed.

  2. 2

    Partial output is broken output

    Mid-stream JSON doesn't parse, markdown has unclosed bold and code fences, and a word can be cut in half.

    {"title":"Reset your rou

  3. 3

    Parse leniently

    Close open strings and brackets, parse, and render the fields you have. Libraries do this for JSON and for markdown.

    Keep the layout stable so it doesn't jump.

  4. 4

    Handle stop, errors and the final check

    Let users cancel, show when the stream died, and validate the complete result once it's done.

    Partial is for display; validate the final.

In production

Tools and technologies

AI SDKs ship partial-object streaming helpers.

Not tied to one language — use these names when you search docs or design a system.