Skip to content

anderdobo/generative-ai-dart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Generative AI SDK for Dart

The Google Generative AI SDK for Dart allows developers to use state-of-the-art Large Language Models (LLMs) to build language applications.

Getting Started

API keys

To use the Gemini API, you'll need an API key. If you don't already have one, create a key in Google AI Studio: https://makersuite.google.com/app/apikey.

Dart samples

See the Dart sample apps at samples/dart, including some getting started instructions.

Flutter sample

See a Flutter sample app at samples/flutter_app, including some getting started instructions.

Using the SDK in your own app

Add a dependency on the package:google_generative_ai package via:

dart pub add google_generative_ai

or:

flutter pub add google_generative_ai

Initializing the API client

final model = GenerativeModel(model: 'gemini-pro', apiKey: apiKey);

Calling the API

final prompt = 'Do these look store-bought or homemade?';
final imageBytes = await File('cookie.png').readAsBytes();
final content = [
  Content.multi([
    TextPart(prompt),
    DataPart('image/png', imageBytes),
  ])
];

final response = await model.generateContent(content);
print(response.text);

Documentation

Find complete documentation for the Google AI SDKs and the Gemini model in the Google documentation: https://ai.google.dev/docs.

Packages

Package Description Version
google_generative_ai The Google Generative AI SDK for Dart - allows access to state-of-the-art LLMs. pub package
samples/dart Dart samples for package:google_generative_ai.
samples/flutter_app A Flutter sample for package:google_generative_ai.

Contributing

See Contributing for more information on contributing to the Generative AI SDK for Dart.

License

The contents of this repository are licensed under the Apache License, version 2.0.

About

Google AI SDK for Dart

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 100.0%