Optional apiOptional apiAdditional headers to pass to the API. This is useful is you want to pass additional parameters to a proxy service, for instance.
Optional apiBy default, the API key is read from the OPENAI_API_KEY environment variable. You can override this by passing a different key here.
Optional controllerAn optional AbortController, which can be used to abort the request mid-flight.
Optional fetchAn 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.
Optional modeWhether to return tokens or raw events.
Optional onA 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.
Optional onA function that runs for each token. This is useful if you want to sum tokens used as they're returned.
Generated using TypeDoc
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.