invokeSSE

fun invokeSSE(function: String, region: FunctionRegion = config.defaultRegion, builder: HttpRequestBuilder.() -> Unit = {}): Flow<FunctionServerSentEvent>(source)

Invokes a remote edge function that returns Server-Sent Events (SSE) and returns a Flow of FunctionServerSentEvent. Each event provides access to data, event, and id fields, as well as a decodeAs method for deserializing the data payload.

The authorization token is automatically added to the request. Ktor's SSE plugin requires direct io.ktor.client.HttpClient access, so this method uses the raw client with api.getDefaultHeaders to include the authentication token (base headers like apikey are already applied by Ktor's DefaultRequest plugin).

Return

A Flow of FunctionServerSentEvent representing the SSE stream

Parameters

function

The function to invoke. If name of the function is renamed, use the slug after URL

region

The region where the function is invoked

builder

The request builder to configure the request

Throws

HttpRequestTimeoutException

if the request timed out

HttpRequestException

on network related issues