NewIncredible offer for our exclusive subscribers!Read More
November 13, 2024
Technology

Gemini AI Integration in Flutter

  • August 23, 2024
  • 1 min read
  • 215 Views
Gemini AI Integration in Flutter

Gemini Google AI Dart SDK beta release

The Google AI Dart SDK has been released to beta. This enables you to build generative AI features into your Dart or Flutter app, powered by Gemini, Google’s latest family of AI models to build AI-powered features and applications. There is now a google_generative_ai package on pub.dev.

This SDK supports use cases like:

  • Generate text from text-only input
  • Generate text from text-and-images input (multimodal)
  • Build multi-turn conversations (chat)
  • Embedding

Code:

import 'package:google_generative_ai/google_generative_ai.dart';

const apiKey = ...;

void main() async {

  final model = GenerativeModel(

      model: 'gemini-1.5-flash-latest',

      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);

};

How to get the Api key?

You have to generate Api key to use this AI tool in your project. You can get this api key from the google AI Studio or https://aistudio.google.com/app/apikey

Output:

Gemini AI Integration in Flutter

About Author

Anuj Kumar Parashar

Leave a Reply

Your email address will not be published. Required fields are marked *