Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/openai/streaming.ts>Stream

Deno build of the official Typescript library for the OpenAI API.
Extremely Popular
Go to Latest
class Stream
implements AsyncIterable<Item>
import { Stream } from "https://deno.land/x/openai@v4.38.3/streaming.ts";

Constructors

new
Stream(iterator: () => AsyncIterator<Item>, controller: AbortController)

Methods

tee(): [Stream<Item>, Stream<Item>]

Splits the stream into two streams which can be independently read from at different speeds.

Converts this stream to a newline-separated ReadableStream of JSON stringified values in the stream which can be turned back into a Stream with Stream.fromReadableStream().

[Symbol.asyncIterator](): AsyncIterator<Item>

Static Methods

fromReadableStream<Item>(readableStream: ReadableStream, controller: AbortController)

Generates a Stream from a newline-separated ReadableStream where each item is a JSON value.

fromSSEResponse<Item>(response: Response, controller: AbortController)