OpenAI class final

The main class of the package. It is a singleton class, so you can only have one instance of it. You can also access the instance by calling the OpenAI.instance getter.

final openai = OpenAI.instance;
Annotations
  • @immutable

Properties

audio → OpenAIAudio
The OpenAIAudio instance, used to access the audio endpoints.
no setter
chat → OpenAIChat
The OpenAIChat instance, used to access the chat endpoints.
no setter
completion → OpenAICompletion
The OpenAICompletion instance, used to access the completion endpoints.
no setter
edit → OpenAIEdits
The OpenAIEdits instance, used to access the edits endpoints.
no setter
embedding → OpenAIEmbedding
The OpenAIEmbedding instance, used to access the embeddings endpoints.
no setter
file → OpenAIFiles
The OpenAIFiles instance, used to access the files endpoints.
no setter
fineTune → OpenAIFineTunes
The OpenAIFineTunes instance, used to access the fine-tunes endpoints.
no setter
hashCode int
The hash code for this object.
no setterinherited
image → OpenAIImages
The OpenAIImages instance, used to access the images endpoints.
no setter
model → OpenAIModel
The OpenAIModel instance, used to access the model endpoints. Please, refer to the Models page from the official OpenAI documentation website in order to know what models are available and what's the use case of every model.
no setter
moderation → OpenAIModeration
The OpenAIModeration instance, used to access the moderation endpoints.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

apiKey String
This is used to initialize the OpenAI instance, by providing the API key. All the requests will be authenticated using this API key.
no getter
baseUrl String
This is used to set the base url of the OpenAI API, by default it is set to OpenAIConfig.baseUrl.
no getter
instance OpenAI
The singleton instance of OpenAI, make sure to call the OpenAI.initialize method before accessing instance, otherwise it will throw an Exception. A MissingApiKeyException will be thrown, if the API key is not set.
no setter
organization String?
The organization id, if set, it will be used in all the requests to the OpenAI API.
getter/setter pair
showLogs bool
This controls whether to log steps inside the process of making a request, this helps debugging and pointing where something went wrong. This uses dart:developer internally, so it will show anyway only while debugging code.
no getter

Static Methods

includeHeaders(Map<String, dynamic> headers) → void
Adds the given headers to all future requests made using the package.