stream<>(credentials: Credentials,options: Options<I>,): Promise<ReadableStream<T>>
Send a HTTP request and, if 2xx, begin streaming the chunks of T object type.
The request body (options.body) is required if I is defined, otherwise I is inferred.
NOTE: The Response is thrown if not 2xx status!
Usage
Usage
import * as OpenAI from '@agent/openai'; let ctx = OpenAI.credentials({ apikey: '...', }); // NOTE: may throw let events = await OpenAI.stream< OpenAI.Chat.Stream.Chunk, OpenAI.Chat.Stream.Request, >(ctx, { method: 'POST', path: '/chat/completions', body: { stream: true, model: '...', messages: [...] }, }); for await (let msg of events) { console.log(msg.choices); }
credentials: Credentials