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

Dart SDK for openAI Apis (GPT-3 & DALL-E), integrate easily the power of OpenAI's state-of-the-art AI models into their Dart applications.

example/lib/main.dart

import 'package:dart_openai/dart_openai.dart';

import 'env/env.dart';

Future<void> main() async {
  // Set the OpenAI API key from the .env file.
  OpenAI.apiKey = Env.apiKey;

  // Start using!
  final completion = await OpenAI.instance.completion.create(
    model: "text-davinci-003",
    prompt: "Dart is",
  );

  // Printing the output to the console
  print(completion.choices[0].text);

  // Generate an image from a prompt.
  final image = await OpenAI.instance.image.create(
    prompt: "dog",
    n: 1,
  );

  // Printing the output to the console.
  for (int index = 0; index < image.data.length; index++) {
    final currentItem = image.data[index];
    print(currentItem.url);
  }

  // create a moderation
  final moderation = await OpenAI.instance.moderation.create(
    input: "I will cut your head off",
  );

  // Printing moderation
  print(moderation.results.first.categories.violence);
}
408
likes
130
pub points
97%
popularity

Publisher

verified publishergwhyyy.com

Dart SDK for openAI Apis (GPT-3 & DALL-E), integrate easily the power of OpenAI's state-of-the-art AI models into their Dart applications.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (LICENSE)

Dependencies

collection, fetch_client, http, meta

More

Packages that depend on dart_openai