Skip to main content
Stream tokens in real-time for a responsive user experience. Ideal for chat interfaces where users expect to see text appear progressively.

LLMStreamingResult

Flutter Widget Example

Cancellation

Cancel ongoing generation at any time:

Best Practices

Use streaming for chat interfaces — Users perceive the app as more responsive when they see tokens appear progressively, even if total generation time is the same.
  1. Update UI incrementally — Append tokens to your state as they arrive
  2. Show a cancel button — Let users stop long generations
  3. Handle cancellation gracefully — The stream will complete when cancelled
  4. Get final metrics — Always await result for accurate performance data

See Also

chat()

Simple one-liner

generate()

Non-streaming with metrics