Skip to main content
Sync context manager for SSE chat streams. Async clients use AsyncChatStream (same methods with async).

ChatStream

Bases: object Sync context manager for SSE chat streams. Returned by client.modus.stream(...) / client.scopes.stream(...). Iterate text_stream for tokens, or event_stream for typed events, then call get_final_result() for the assembled ChatResult. For async clients, see AsyncChatStream.

text_stream

Yield assistant reply text as it arrives, one token at a time.

event_stream

Yield typed stream events (tokens, tool calls, done, errors).

get_final_result()

Return the assembled reply after the stream finishes.
  • Raises: ModusError – if called before the stream emits a done event.

AsyncChatStream

Bases: object Async context manager for SSE chat streams. Same shape as ChatStream for AsyncModus / async resource methods.

text_stream

Yield assistant reply text as it arrives. See sync text_stream for details.

event_stream

Yield typed stream events as they arrive. See sync event_stream for details.

get_final_result()

Return the assembled reply after the stream finishes. See sync get_final_result.