dart_openai 1.0.8 copy "dart_openai: ^1.0.8" to clipboard
dart_openai: ^1.0.8 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/openai.dart';
import 'package:dotenv/dotenv.dart';

Future<void> main() async {
  // Load the .env file
  DotEnv env = DotEnv()..load([".env"]);

  // Set the OpenAI API key from the .env file.
  OpenAI.apiKey = env['OPEN_AI_API_KEY']!;

  // 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: "Dart is",
    n: 4,
  );

  // Printing the output to the console.
  print(image.data.first.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);
}
485
likes
0
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

License

unknown (license)

Dependencies

collection, http, meta, path

More

Packages that depend on dart_openai