function toHttpStream(stream, abortController?): ReadableStream<Uint8Array<ArrayBufferLike>>;function toHttpStream(stream, abortController?): ReadableStream<Uint8Array<ArrayBufferLike>>;Defined in: packages/typescript/ai/src/stream-to-response.ts:171
Convert a StreamChunk async iterable to a ReadableStream in HTTP stream format (newline-delimited JSON)
This creates a ReadableStream that emits chunks as newline-delimited JSON:
This format is compatible with fetchHttpStream connection adapter.
AsyncIterable<AGUIEvent>
AsyncIterable of StreamChunks from chat()
AbortController
Optional AbortController to abort when stream is cancelled
ReadableStream<Uint8Array<ArrayBufferLike>>
ReadableStream in HTTP stream format (newline-delimited JSON)
const stream = chat({ adapter: openaiText(), model: "gpt-4o", messages: [...] });
const readableStream = toHttpStream(stream);
// Use with Response for HTTP streaming (not SSE)
return new Response(readableStream, {
headers: { 'Content-Type': 'application/x-ndjson' }
});const stream = chat({ adapter: openaiText(), model: "gpt-4o", messages: [...] });
const readableStream = toHttpStream(stream);
// Use with Response for HTTP streaming (not SSE)
return new Response(readableStream, {
headers: { 'Content-Type': 'application/x-ndjson' }
});