Skip to main content

genkit_firebase_ai 1.0.0 copy "genkit_firebase_ai: ^1.0.0" to clipboard
genkit_firebase_ai: ^1.0.0 copied to clipboard

Genkit plugin for Firebase AI Logic. Call Gemini from Flutter apps with tools, structured output, grounding and Live sessions.

example/example.dart

// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// Calls Gemini from a Flutter app through Firebase AI Logic.
///
/// Firebase must be initialized first (normally with the `firebase_options.dart`
/// generated by `flutterfire configure`); see the package README and
/// `testapps/firebase_ai` for a complete app.
library;

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/widgets.dart';
import 'package:genkit/genkit.dart';
import 'package:genkit_firebase_ai/genkit_firebase_ai.dart';

Future<void> main() async {
  // Firebase talks to the platform through the Flutter binding.
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();

  final ai = Genkit(plugins: [firebaseAI()]);

  final response = await ai.generate(
    model: firebaseAI.gemini('gemini-flash-latest'),
    prompt: 'Tell me a joke about a developer.',
  );
  print(response.text);

  // Structured output: the response is parsed into the schema's type.
  final structured = await ai.generate(
    model: firebaseAI.gemini('gemini-flash-latest'),
    prompt: 'List three primary colors.',
    outputSchema: .list(.string()),
  );
  print(structured.output);
}
2
likes
160
points
669
downloads

Documentation

API reference

Publisher

verified publishergenkit.dev

Weekly Downloads

Genkit plugin for Firebase AI Logic. Call Gemini from Flutter apps with tools, structured output, grounding and Live sessions.

Repository (GitHub)
View/report issues
Contributing

License

Apache-2.0 (license)

Dependencies

firebase_ai, firebase_core, flutter, genkit, http, json_annotation, logging, schemantic, web_socket_channel

More

Packages that depend on genkit_firebase_ai