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

x/openai/core.ts>PagePromise

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

This subclass of Promise will resolve to an instantiated Page once the request completes.

It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:

for await (const item of client.items.list()) { console.log(item) }

Constructors

new
PagePromise(
client: APIClient,
request: Promise<APIResponseProps>,
Page: new (...args: ConstructorParameters<AbstractPage>) => PageClass,
)

Type Parameters

PageClass extends AbstractPage<Item>
optional
Item = ReturnType<PageClass["getPaginatedItems"]>[number]

Methods

Allow auto-paginating iteration on an unawaited list call, eg:

for await (const item of client.items.list()) { console.log(item) }