For AI agents: the documentation index is at llms.txt. Guide pages have a markdown version at the same path with .md appended, before any query string or fragment.
Invoke a Supabase Edge Function and read the response body as it arrives. Use it for text/event-stream responses and large downloads.
stream returns a FunctionStreamResponse as soon as the response head arrives. Its body is an HTTPBody, an AsyncSequence of ArraySlice<UInt8> chunks. Iterate it once.FunctionsError from stream itself, before you read the body.CancellationError from the loop.stream takes the same body and options as invoke.let response = try await supabase.functions.stream(
"hello",
body: .json(["foo": "bar"])
)
// Write each chunk to a file, so memory use stays small.
let fileURL = FileManager.default.temporaryDirectory
.appendingPathComponent("hello-response")
FileManager.default.createFile(atPath: fileURL.path, contents: nil)
let file = try FileHandle(forWritingTo: fileURL)
defer { try? file.close() }
for try await chunk in response.body {
try file.write(contentsOf: chunk)
}