google_generative_ai 0.1.0
google_generative_ai: ^0.1.0 copied to clipboard
Google generative AI SDK API bindings for Dart - allows access to state-of-the-art LLMs.
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 #
Get an API key #
Using the Gemini SDK requires an API key; see https://ai.google.dev/tutorials/setup for how to create one.
Add the package to your project #
Add a dependency on the package via:
dependencies:
google_generative_ai:
git:
url: git@github.com:google/generative-ai-dart.git
path: pkgs/google_generative_ai
ref: main
And import:
import 'package:google_generative_ai/google_generative_ai.dart';
Using the API #
import 'package:google_generative_ai/google_generative_ai.dart';
const apiKey = ...;
void main() async {
final model = GenerativeModel(model: 'gemini-pro', apiKey: apiKey);
final prompt = 'Write a story about a magic backpack.';
final content = [Content.text(prompt)];
final response = await model.generateContent(content);
print(response.text);
};
See additional examples at samples/.
Additional documentation #
You can find additional documentation for the Google AI SDKs and the Gemini at ai.google.dev/docs.