dart_openai 1.0.0 copy "dart_openai: ^1.0.0" to clipboard
dart_openai: ^1.0.0 copied to clipboard

Dart SDK for openAI Apis (GPT-3 & DALL-E)

Dart SDK for openAI Apis (GPT-3 & DALL-E) #

An open-source SDK that allows developers to easily integrate the power of OpenAI's state-of-the-art AI models into their Dart applications. This library provides simple and intuitive methods for making requests to OpenAI's various APIs, including the GPT-3 language model, DALL-E image generation, and more.

The package is designed to be lightweight and easy to use, so you can focus on building your application, rather than worrying about the complexities and error caused by dealing with http requests.

Unofficial
OpenAI does not have any official Dart library.

Note:

Please note that this client SDK connects directly to openAI APIs using http requests, all requests fields from direct method are just derivations from the openAI Apis, so if you want to use this SDK, please refer first and have a look over here

Progress #

Testing Progress #

Authentication #

API key #

void main() {
 OpenAI.apiKey = dotenv.env["OPEN_AI_KEY"]!;
 // ..
}

Requesting organization #

 OpenAI.organization = "ORGANIZATION ID";

Models #

List Models #

Lists the currently available models, and provides basic information about each one such as the owner and availability.

 final models = await OpenAI.instance.model.list();
 print(models.first.id);

Retrieve model #

Retrieves a model instance, providing basic information about the model such as the owner and permissioning.

 final model = await OpenAI.instance.model.one("MODEL ID");
 print(model.id)

Completions #

Create completion #

 OpenAICompletionModel completion = await OpenAI.instance.completion.create(
   model: "text-davinci-003",
   prompt: "Dart is a ",
   temperature: 0.8,
 );

Edits #

Create edit #

 OpenAIEditModel a = await OpenAI.instance.edit.create(
   model: "text-davinci-edit-001",
   input: " Hi!, I am a bot!!!!,",
   instruction: "remove all ! the input ",
 );

Images #

Create image #

 OpenAIImageModel image = await OpenAI.instance.image.create(
   prompt: "A dog",
   n: 1,
 );

Create image edit #

 final result = await OpenAI.instance.image.edit(
   image: File(/* image file path*/),
   mask: File(/* mask file path*/),
   prompt: "change color to green",
   n: 1,
 );

Create image variation #

OpenAIImageVariationModel variation = await OpenAI.instance.image.variation(
 image: File(/*YOUR IMAGE FILE PATH*/),
);

Embeddings #

Create embeddings #

OpenAIEmbeddingsModel embeddings = await OpenAI.instance.embedding.create(
  model: "text-embedding-ada-002",
  input: "This is a text input just to test",
);;

Files #

List files #

List<OpenAIFileModel> files = await OpenAI.instance.file.list();

Upload file #

OpenAIFileModel uploadedFile = await OpenAI.instance.file.upload(
 file: File("FILE PATH HERE"),
 purpose: "fine-tuning",
);

Delete file #

bool isFileDeleted = await OpenAI.instance.file.delete("FILE ID");

Retrieve file #

OpenAIFileModel file = await OpenAI.instance.file.retrieve("FILE ID");

Retrieve file content #

dynamic fileContent  = await OpenAI.instance.file.retrieveContent("FILE ID");

Fine Tunes #

Create fine-tune #

OpenAIFineTuneModel fineTune = await OpenAI.instance.fineTune.create(
 trainingFile: "FILE ID",
);

List fine-tunes #

List<OpenAIFineTuneModel> fineTunes = await OpenAI.instance.fineTune.list();

Retrieve fine-tune #

OpenAIFineTuneModel fineTune = await OpenAI.instance.fineTune.retrieve("FINE TUNE ID");

Cancel fine-tune #

OpenAIFineTuneModel fineTune = await OpenAI.instance.fineTune.cancel("FINE TUNE ID");

List fine-tune events #

 List<OpenAIFineTuneEventModel> events = await OpenAI.instance.fineTune.listEvents("FINE TUNE ID");

Delete fine-tune #

 bool deleted = await OpenAI.instance.fineTune.delete("FINE TUNE ID");

Moderations #

Create moderation #

OpenAIModerationModel moderationResult = await OpenAI.instance.moderation.create(
  input: "I want to kill him",
);
407
likes
0
pub points
97%
popularity

Publisher

verified publishergwhyyy.com

Dart SDK for openAI Apis (GPT-3 & DALL-E)

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

collection, http, meta, path

More

Packages that depend on dart_openai