Interface OpenAIOptions

Hierarchy

Properties

apiBase?: string

By default, the API base is https://api.openai.com/v1, corresponding to OpenAIs API. You can override this to use a different provider or proxy.

apiHeaders?: Record<string, string>

Additional headers to pass to the API. This is useful is you want to pass additional parameters to a proxy service, for instance.

apiKey?: string

By default, the API key is read from the OPENAI_API_KEY environment variable. You can override this by passing a different key here.

controller?: AbortController

An optional AbortController, which can be used to abort the request mid-flight.

fetch?: ((input, init?) => Promise<Response>) | ((url, init?) => Promise<Response>)

An optional custom fetch implementation, which will be used to replace the default fetch/node-fetch call used for making API requests in edge/dom and node environments respectively.

mode?: StreamMode

Whether to return tokens or raw events.

onDone?: (() => void | Promise<void>)

Type declaration

    • (): void | Promise<void>
    • A function to run at the end of a stream. This is useful if you want to do something with the stream after it's done, like log token usage.

      Returns void | Promise<void>

onParse?: ((token) => void | Promise<void>)

Type declaration

    • (token): void | Promise<void>
    • A function that runs for each token. This is useful if you want to sum tokens used as they're returned.

      Parameters

      • token: string

      Returns void | Promise<void>

Generated using TypeDoc