Skip to main content
Streaming chat session. Iterate ChatStream.textStream or ChatStream.eventStream, then call ChatStream.getFinalResult.

Constructor

Parameters

HttpClient
required
string
required
required
string

Returns

ChatStream

Methods

eventStream()

Async iterable of structured run events (tokens, tool calls, done, and so on).

Returns

AsyncGenerator<RunEvent> An async generator yielding RunEvent objects.

getFinalResult()

Final chat result after the stream completes. Call only after fully consuming ChatStream.textStream or ChatStream.eventStream.

Returns

ChatResult The assembled assistant reply, thread id, and run id.

textStream()

Async iterable of assistant text token chunks as they arrive.

Returns

AsyncGenerator<string> An async generator yielding partial text strings.