Flow<StreamEvent<JsonElement>> backed by OkHttp. You consume them with collect, and cancellation stops the underlying call immediately.
Streams
Both take an optional
options argument (headers, timeoutMillis).
StreamEvent shape
Models.kt
data: lines as JSON into JsonElement. If parsing fails, data falls back to a JsonPrimitive containing the raw payload, and raw still contains the original text.
Consume execution events
1
Create a client
Initialize the SDK with your API key.
Client.kt
2
Collect the stream
Use Collection ends when the server closes the connection or when the coroutine is cancelled. The Flow is cold, so collection starts the underlying request.
collect to consume events as they arrive inside a coroutine.Client.kt
No read timeout
Streams set OkHttpreadTimeout to 0 so they can run indefinitely. You do not need to pass a special timeoutMillis in RequestOptions for long-lived streams. Normal request timeouts apply only to API calls that are not streaming.
Client.kt
Cancel a stream
Cancel the coroutine that collects the Flow. The SDK usescallbackFlow with awaitClose { call.cancel() }, so the underlying OkHttp call is aborted as soon as collection stops.
Client.kt
Watch an execution with polling
executions.watch polls get at a configurable interval and yields Execution only when the status changes. It finishes automatically when the outcome or status reaches a terminal state (success, error, stopped, crashed, or anti_bot).
Client.kt
Selector stream from a headful browser
The selector stream reports element highlights from a headful browser session. Use it to power visual inspectors:Client.kt
Errors
Streams raiseFigraniumException in the same conditions as regular requests:
NETWORK_ERROR: the stream could not reach the server.- Any non-2xx HTTP response from the server.
Related
Errors
FigraniumException fields, codes, and retry guidance.Browser resource
Open, inspect, and stream headful browser sessions.
Executions resource
List, stop, delete, and watch executions.