AsyncIterable<StreamEvent>. You consume them with for await, cancel them with an AbortSignal, and read event names, IDs, and parsed data straight off each event.
Streams
Both take an optional
RequestOptions argument (signal, timeoutMs, headers).
StreamEvent shape
JSON.parse on the data lines. If parsing fails, data is the raw string and raw still contains the original payload.
Consume execution events
1
Create a client
Initialize the SDK with your API key.
2
Iterate the stream
Use Iteration ends when the server closes the connection or when your loop breaks. Breaking out of the loop cancels the underlying reader.
for await to consume events as they arrive.Cancel a stream
Streams honorAbortSignal. Aborting cancels the reader and terminates iteration.
Terminal timeouts
Streams have no default timeout. SettimeoutMs only when you want a hard deadline; the stream aborts as soon as the timer fires:
Typed payloads
stream() accepts a generic type parameter that types the parsed data:
status values as forward-compatible additions.
Selector stream from a headful browser
The selector stream reports element highlights from a headful browser session. Use it to power visual inspectors:Errors
Streams throwFigraniumError in the same conditions as regular requests, plus:
EMPTY_STREAM: the response arrived with no body.REQUEST_ABORTED: the caller aborted, or the terminaltimeoutMsfired.