{"id":23222659,"url":"https://github.com/flutter/ai","last_synced_at":"2025-04-05T14:03:20.439Z","repository":{"id":268582444,"uuid":"856586543","full_name":"flutter/ai","owner":"flutter","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-29T00:20:30.000Z","size":2302,"stargazers_count":100,"open_issues_count":8,"forks_count":31,"subscribers_count":44,"default_branch":"main","last_synced_at":"2025-03-29T01:25:11.430Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flutter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-12T20:44:25.000Z","updated_at":"2025-03-29T00:20:34.000Z","dependencies_parsed_at":"2025-03-14T18:13:04.103Z","dependency_job_id":"ec683bd4-5b84-47be-8828-3222609d06bf","html_url":"https://github.com/flutter/ai","commit_stats":null,"previous_names":["flutter/ai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flutter%2Fai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flutter%2Fai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flutter%2Fai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flutter%2Fai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flutter","download_url":"https://codeload.github.com/flutter/ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345850,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-18T23:13:44.912Z","updated_at":"2025-04-05T14:03:20.431Z","avatar_url":"https://github.com/flutter.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![package:flutter_ai_toolkit](https://github.com/flutter/ai/actions/workflows/flutter.yml/badge.svg)](https://github.com/flutter/ai/actions/workflows/flutter.yml)\n[![pub package](https://img.shields.io/pub/v/flutter_ai_toolkit.svg)](https://pub.dev/packages/flutter_ai_toolkit)\n[![package publisher](https://img.shields.io/pub/publisher/flutter_ai_toolkit.svg)](https://pub.dev/packages/flutter_ai_toolkit/publisher)\n\nHello and welcome to the [Flutter AI Toolkit][]!\n\nThe AI Toolkit is a set of AI chat-related widgets to make it easy to\nadd an AI chat window to your Flutter app.\nThe AI Toolkit is organized around an abstract LLM provider API that makes it\neasy to swap out the LLM provider that you'd like your chat provider to use.\nOut of the box, it comes with support for two LLM provider integrations:\n[Google Gemini AI][] and [Firebase Vertex AI][].\n\n[Flutter AI Toolkit]: https://docs.flutter.dev/ai-toolkit\n[Google Gemini AI]: https://ai.google.dev/gemini-api/docs\n[Firebase Vertex AI]: https://firebase.google.com/docs/vertex-ai\n\n## Key features\n\n* **Multi-turn chat:**\n  Maintains context across multiple interactions.\n* **Streaming responses:**\n  Displays AI responses in real-time as they're generated.\n* **Rich text display:**\n  Supports formatted text in chat messages.\n* **Voice input:**\n  Allows users to input prompts using speech.\n* **Multimedia attachments:**\n  Enables sending and receiving various media types.\n* **Custom styling:**\n  Offers extensive customization to match your app's design.\n* **Chat serialization/deserialization:**\n  Store and retrieve conversations between app sessions.\n* **Pluggable LLM support:**\n  Implement a simple interface to plug in your own LLM.\n* **Cross-platform support:**\n  Compatible with the Android, iOS, web, and macOS platforms.\n\n## Online demo\n\nTo see the AI toolkit in action, check out the [online demo][].\n\n\u003ca href=\"https://flutter-ai-toolkit-examp-60bad.web.app/\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/flutter/ai/refs/heads/main/README/screenshot.png\" height=\"800\" alt=\"Screenshot of a halloween-themed web app demo using the Flutter AI toolkit.\" /\u003e\n\u003c/a\u003e\n\nThe [demo's source code][] can be a useful reference as you integrate\nthe AI toolkit in to your own applications.\n\n[online demo]: https://flutter-ai-toolkit-examp-60bad.web.app/\n[demo's source code]: https://github.com/flutter/ai/blob/main/example/lib/demo/demo.dart\n\n## Getting started\n\n\u003ca href=\"https://idx.google.com/new?template=https%3A%2F%2Fgithub.com%2Fflutter%2Fai\"\u003e\n  \u003cpicture\u003e\n    \u003csource\n      media=\"(prefers-color-scheme: dark)\"\n      srcset=\"https://cdn.idx.dev/btn/try_light_32.svg\"\u003e\n    \u003csource\n      media=\"(prefers-color-scheme: light)\"\n      srcset=\"https://cdn.idx.dev/btn/try_dark_32.svg\"\u003e\n    \u003cimg\n      height=\"32\"\n      alt=\"Try in IDX\"\n      src=\"https://cdn.idx.dev/btn/try_purple_32.svg\"\u003e\n  \u003c/picture\u003e\n\u003c/a\u003e\n\n 1. **Installation**\n\n    Add the following dependencies to your `pubspec.yaml` file:\n\n    ```sh\n    $ flutter pub add flutter_ai_toolkit google_generative_ai firebase_core\n    ```\n\n 2. **Vertex AI configuration**\n\n    The AI toolkit supports both Firebase Vertex AI and Google Gemini AI as LLM providers.\n    Firebase Vertex AI is the preferred approach for production use cases.\n\n    To use Vertex AI in your project, follow the steps described in\n    [Get started using the Vertex AI in Firebase SDKs][vertex-ai-get-started].\n\n    Once that's complete, integrate the new Firebase project into\n    your Flutter app using the `flutterfire` CLI tool, as described in\n    [Add Firebase to your Flutter app][] docs.\n\n    After following these instructions, you're ready to\n    use Firebase Vertex AI in your Flutter app.\n    Start by initializing Firebase:\n\n    ```dart\n    import 'package:firebase_core/firebase_core.dart';\n    import 'package:firebase_vertexai/firebase_vertexai.dart';\n    import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';\n\n    // Other app imports...\n\n    import 'firebase_options.dart'; // Generated by `flutterfire config`.\n\n    void main() async {\n      WidgetsFlutterBinding.ensureInitialized();\n      await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);\n      runApp(const App());\n    }\n\n    // Implementation of App and other widgets...\n    ```\n\n    With Firebase properly initialized in your Flutter app,\n    you're now ready to create an instance of the Vertex provider:\n\n    ```dart\n    class ChatPage extends StatelessWidget {\n      const ChatPage({super.key});\n\n      @override\n      Widget build(BuildContext context) =\u003e Scaffold(\n            appBar: AppBar(title: const Text(App.title)),\n            // Create the chat view, passing in the Vertex provider.\n            body: LlmChatView(\n              provider: VertexProvider(\n                chatModel: FirebaseVertexAI.instance.generativeModel(\n                  model: 'gemini-1.5-flash',\n                ),\n              ),\n            ),\n          );\n    }\n    ```\n\n    The `FirebaseVertexAI` class comes from the `firebase_vertexai` package.\n    The AI Toolkit provides the `VertexProvider` class to\n    expose Vertex AI to the `LlmChatView`.\n    Note that you provide a model name that\n    corresponds to one of the [available model names][firebase-models],\n    but you don't provide an API key.\n    All of that is handled as part of the Firebase project.\n\n    For a complete usage example,\n    check out the [`vertex.dart` sample][].\n\n 3. **Gemini AI configuration**\n\n    To use Google Gemini AI, obtain an API key from [Google AI Studio][].\n    Be careful not to check this key into your source code repository to\n    prevent unauthorized access.\n\n    You'll also need to choose a specific Gemini model name to\n    use in creating an instance of the Gemini model.\n    The following example uses `gemini-1.5-flash`, but\n    you can choose from an [ever-expanding set of models][gemini models].\n\n    ```dart\n    import 'package:flutter/material.dart';\n    import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';\n    import 'package:google_generative_ai/google_generative_ai.dart';\n\n    void main() {\n      runApp(const MyApp());\n    }\n\n    class MyApp extends StatelessWidget {\n      const MyApp({super.key});\n\n      @override\n      Widget build(BuildContext context) {\n        return MaterialApp(\n          title: 'Flutter Demo',\n          theme: ThemeData(\n            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),\n            useMaterial3: true,\n          ),\n          home: const ChatPage(title: 'Generative AI Chat'),\n        );\n      }\n    }\n\n    class ChatPage extends StatelessWidget {\n      const ChatPage({super.key, required this.title});\n      final String title;\n\n      @override\n      Widget build(BuildContext context) {\n        return Scaffold(\n          appBar: AppBar(title: Text(title)),\n          body: LlmChatView(\n            provider: GeminiProvider(\n              model: GenerativeModel(\n                model: 'gemini-1.5-flash',\n                apiKey: 'GEMINI-API-KEY',\n              ),\n            ),\n          ),\n        );\n      }\n    }\n    ```\n\n    The `GenerativeModel` class comes from the `google_generative_ai` package.\n    The AI Toolkit builds on top of this package with the `GeminiProvider`,\n    which plugs Gemini AI into the `LlmChatView`, the top-level widget that\n    enables an LLM-based chat conversation with your users.\n\n    For a complete usage example,\n    check out the [`gemini.dart` sample][].\n\n    While Gemini AI is useful for quick prototyping, the recommended solution\n    for production apps is [Vertex AI in Firebase][]. This eliminates the need\n    for an API key in your client app and replaces it with a more secure Firebase\n    project.\n\n 4. **Set up device permissions**\n\nTo enable your users to take advantage of features like voice input and\nmedia attachments, ensure that your app has the necessary permissions:\n\n- **Network access:**\nTo enable network access on macOS, add the following to your `*.entitlements` files:\n\n```xml\n\u003cplist version=\"1.0\"\u003e\n    \u003cdict\u003e\n      ...\n      \u003ckey\u003ecom.apple.security.network.client\u003c/key\u003e\n      \u003ctrue/\u003e\n    \u003c/dict\u003e\n\u003c/plist\u003e\n```\n\nTo enable network access on Android, ensure that your `AndroidManifest.xml` file contains the following:\n\n```xml\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n    ...\n    \u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e\n\u003c/manifest\u003e\n```\n\n- **Microphone access:**\n  To enable voice input for users, update configs according to the\n  [permission and setup instructions][record-setup] for `package:record`.\n\n- **File selection:**\n  To enable users to select and attach files,\n  follow the [usage instructions][file-setup] for `package:file_selector`.\n- **Image selection:**\n\n  To enable users to take or select a picture from their device, refer to\n  the [installation instructions][image-setup] for `package:image_picker`.\n\n[gemini models]: https://ai.google.dev/gemini-api/docs/models/gemini\n[`gemini.dart` sample]: https://github.com/flutter/ai/blob/main/example/lib/gemini/gemini.dart\n\n[Vertex AI in Firebase]: https://firebase.google.com/products/vertex-ai-in-firebase\n[vertex-ai-get-started]: https://firebase.google.com/docs/vertex-ai/get-started?platform=flutter\n[Add Firebase to your Flutter app]: https://firebase.google.com/docs/flutter/setup\n\n[firebase-models]: https://firebase.google.com/docs/vertex-ai/gemini-models#available-model-names\n[`vertex.dart` sample]: https://github.com/flutter/ai/blob/main/example/lib/vertex/vertex.dart\n\n[record-setup]: https://pub.dev/packages/record#setup-permissions-and-others\n[file-setup]: https://pub.dev/packages/file_selector#usage\n[image-setup]: https://pub.dev/packages/image_picker#installation\n\n## Samples\n\nTo run the [example apps][] in the `example/lib` directory, first replace the\n`example/lib/gemini_api_key.dart` and `example/lib/firebase_options.dart` files.\nThey're placeholders for configuration needed by the examples.\n\n[example apps]: https://github.com/flutter/ai/tree/main/example/lib\n\n### `gemini_api_key.dart`\n\nMost of the example apps rely on a Gemini API key, so for those to work,\nyou'll need to add your API key to the `example/lib/gemini_api_key.dart` file.\nYou can get an API key in [Google AI Studio][].\n\n\u003e [!WARNING]\n\u003e Be careful not to check the `gemini_api_key.dart` file into your git repo.\n\n### `firebase_options.dart`\n\nTo use the [Vertex AI example app][], add your\nFirebase configuration details to the `example/lib/firebase_options.dart` file.\nYou can do this running the `flutterfire` CLI tool as described in\n[Add Firebase to your Flutter app][] **from within the `example` directory**.\n\n\u003e [!WARNING]\n\u003e Be careful not to check the `firebase_options.dart` file into your git repo.\n\n[Vertex AI example app]: https://github.com/flutter/ai/blob/main/example/lib/vertex/vertex.dart\n[Add Firebase to your Flutter app]: https://firebase.google.com/docs/flutter/setup\n\n## Feedback\n\nAlong the way, as you use this package, please\n[log issues and feature requests][] as well as\nsubmit any [code you'd like to contribute][].\nWe want your feedback and contributions to ensure that the AI Toolkit is\nas robust and useful as it can be for your real-world apps.\n\n[log issues and feature requests]: https://github.com/flutter/ai/issues\n[code you'd like to contribute]: https://github.com/flutter/ai/pulls\n\n[Google AI Studio]: https://aistudio.google.com/app/apikey\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutter%2Fai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflutter%2Fai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutter%2Fai/lists"}