ai.stream.Stream
The typed partial-value stream returned by an LLM function's `@stream` projection. This is the one canonical host-stream class; tagged handles carry its FQN across FFI so host bridges do not need to hardcode a namespace.
Reference version
Signature
class ai.stream.Stream<T>The typed partial-value stream returned by an LLM function's @stream
projection. This is the one canonical host-stream class; tagged handles carry
its FQN across FFI so host bridges do not need to hardcode a namespace.
Partial and final values share one type: a partial is the declared type parsed from the text received so far.
Source:<builtin>/ai/ns_stream/stream.bamlbytes 21386–22844
Fields
_next_text
() -> string | null throws ai.errors.InvokeError_cache
baml.sap._ParseCache<T>_text
string_finished
boolInstance methods
function
final
(self
) -> T throws baml.errors.LlmClient | baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure
Drain the stream and parse the accumulated text as the final value.
function
next
(self
) -> T | ai.stream.Done throws baml.errors.LlmClient | baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure
Return the next parsed partial value, or Done after EOF.