google_generative_ai 0.1.0 copy "google_generative_ai: ^0.1.0" to clipboard
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.

package:google_generative_ai

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.

639
likes
0
pub points
98%
popularity

Publisher

verified publishergoogle.dev

Google generative AI SDK API bindings for Dart - allows access to state-of-the-art LLMs.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

http

More

Packages that depend on google_generative_ai