---
title: "Streaming chat"
slug: plugins/unity/Samples~/StreamingChat
---

<a id="streaming-chat"></a>

Attach `StreamingChatExample` and `AstralRuntimeInitializer` to a GameObject.
Set `modelPath` to a GGUF file visible to the player and set `backendName` to
`cpu` or another packaged provider.

`Run` creates one session and polls its UTF-8 stream once per frame. `Cancel`
uses the generic request reference, and a second run disposes the previous
session and caller-owned `NativeArray` before starting again.

The example converts bytes to a managed string only at the `Debug.Log` boundary.
Replace that call with your UI or gameplay text sink.

Source: [View the pinned source](https://github.com/Cosmin-B/astral-runtime/blob/f2d13b77c70624ede5bc06823d4a794a4b955e10/plugins/unity/Samples~/StreamingChat/README.md) · [Edit this source](https://github.com/Cosmin-B/astral-runtime/edit/main/plugins/unity/Samples~/StreamingChat/README.md)
