The Flutter AI Toolkit (flutter_ai_toolkit) plus Firebase AI Logic gives you a streaming Gemini chat screen with voice input, attachments and function calling, and no API key in the app. Across 4+ years of Flutter work and 20+ shipped apps, most AI features I add start with exactly this screen: a chat window that streams answers, accepts a photo or a voice note, and remembers the conversation. Here is the build, step by step, including the version trap and the November 2, 2026 App Check deadline.
What is the Flutter AI Toolkit?
The Flutter AI Toolkit is the official flutter_ai_toolkit package: a set of chat widgets built around an abstract LLM provider API. flutter_ai_toolkit 1.0.0 (December 15, 2025) supports Android, iOS, web and macOS and requires Flutter 3.27.0 or later. Its main widget, LlmChatView, renders a complete chat UI, and the bundled FirebaseProvider connects it to Gemini through Firebase AI Logic with no API key in your app.
According to the Flutter AI Toolkit docs, the toolkit covers:
- Chat basics: multi-turn chat, streaming responses and rich text.
- Input: voice input and multimedia attachments.
- Logic: function calling (tool calls), chat serialization and deserialization.
- Customization: custom styling, custom response widgets and pluggable LLM providers.
- Platforms: Android, iOS, web and macOS.
Release 1.0.0 comes from the verified publisher labs.flutter.dev, needs Dart ^3.7.0, and is BSD-3-Clause licensed, with source at github.com/flutter/ai.
Which Flutter AI Toolkit package versions work together in October 2026?
Install the three packages with one command and let pub resolve them. The catch: flutter_ai_toolkit 1.0.0 depends on firebase_ai ^3.0.0, so your app ends up on the 3.x line (3.15.0 at most), even though firebase_ai 5.1.0 is the latest release.
flutter pub add flutter_ai_toolkit firebase_ai firebase_core
Versions checked October 24, 2026: flutter_ai_toolkit 1.0.0, firebase_ai 3.15.0 (the newest that resolves; 5.1.0 is the latest overall), firebase_app_check 0.4.9.
Three things to check first:
- Do not pin firebase_ai 5.x next to the toolkit. The toolkit's constraint is
^3.0.0, so pub cannot resolve it.firebase_ai3.15.0 is the newest compatible version and needsfirebase_core ^4.13.0. - Use
agentPlatform(), notvertexAI(). Infirebase_ai3.15.0,FirebaseAI.vertexAI()is deprecated in favor ofFirebaseAI.agentPlatform(), and the 5.x line removes it. Some Flutter doc snippets still showvertexAI(). - Change the model name in old examples. The toolkit README and examples use
gemini-2.0-flash, which shut down on June 1, 2026. Skipgemini-2.5-flashtoo: on the Agent Platform Gemini API it shut down on October 20, 2026, and on the Gemini Developer API it is deprecated with no shutdown date yet, usable only by projects that already used it. Firebase's own Flutter get-started sample now usesgemini-3.8-flash.
Older tutorials with GeminiProvider or VertexProvider are out of date: the toolkit 0.9.0 changelog says it "removes both GeminiProvider and VertexProvider and replaces it with FirebaseProvider." The Flutter AI Toolkit docs add that both Gemini options require a Firebase project and that you do not provide an API key, because the Firebase project handles it.
How do I set up Firebase AI Logic for a Flutter app?
Firebase AI Logic is Firebase's set of client SDKs (firebase_ai in Flutter) for calling Gemini models directly from mobile and web apps through your Firebase project, protected by App Check. It offers two API providers: the Gemini Developer API and the Agent Platform Gemini API (formerly Vertex AI).
Create or open a Firebase project, go to AI Services, then AI Logic, and click Get started. Choose the Gemini Developer API, which Firebase recommends because it starts at no cost. Then generate firebase_options.dart with the FlutterFire CLI and add network permissions on Android and macOS.
- Enable AI Logic in the Firebase console under AI Services. Google Analytics is not required.
- Connect the app by running the FlutterFire CLI in your project root:
flutterfire config - Add network access. Android needs the internet permission in
AndroidManifest.xml, and macOS needs the network client entitlement in its*.entitlementsfiles:<!-- android/app/src/main/AndroidManifest.xml --> <uses-permission android:name="android.permission.INTERNET"/> <!-- macos/Runner/*.entitlements --> <key>com.apple.security.network.client</key> <true/>
The Flutter docs add a warning: if the client calls Gemini directly, keep firebase_options.dart out of public repositories.
How do I build the chat screen with LlmChatView and FirebaseProvider?
Initialize Firebase, create a FirebaseProvider around a Gemini model from FirebaseAI.googleAI() (the entry point used in the Flutter AI Toolkit overview and Firebase's Flutter get-started guide), and pass it to LlmChatView. You supply a model name, never an API key; the Firebase project handles access. Streaming, Markdown rendering, attachments and voice input work immediately.
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';
import 'firebase_options.dart'; // from `flutterfire config`
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
runApp(const MaterialApp(home: ChatPage()));
}
class ChatPage extends StatefulWidget {
const ChatPage({super.key});
@override
State<ChatPage> createState() => _ChatPageState();
}
class _ChatPageState extends State<ChatPage> {
late final _provider = FirebaseProvider(
model: FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.8-flash',
systemInstruction: Content.system(
'You are a helpful assistant for a travel app. Keep answers short.',
),
),
);
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Assistant')),
body: LlmChatView(
provider: _provider,
welcomeMessage: 'Hi! Ask me anything about your trip.',
suggestions: const ['Plan a one-day itinerary', 'What should I pack?'],
),
);
}
Details that matter on real screens:
- Suggestions only show when the chat has no history, and tapping one sends it.
- System instructions go on the model through
systemInstruction: Content.system(...). - Structured output uses
responseBuilderto swap Markdown for your own widgets, paired withGenerationConfig(responseMimeType: 'application/json', responseSchema: ...). If you want the model to compose whole screens from your own widget catalog instead of filling one response widget, that is the next step beyondLlmChatView; see my Flutter GenUI SDK guide.
I keep the provider in State rather than creating it in build, as the official history example does, because the provider owns the conversation. Firebase also strongly recommends Remote Config or server prompt templates in production, so you can change the model name without shipping a new build.
Should I use the Gemini Developer API or the Agent Platform Gemini API?
Start with the Gemini Developer API. Firebase recommends it because it has a free tier that runs on the no-cost Spark plan without a payment method. The Agent Platform Gemini API, formerly Vertex AI, requires billing. You can switch later by changing one constructor.
| Aspect | Gemini Developer API | Agent Platform Gemini API |
|---|---|---|
| Entry point in firebase_ai | FirebaseAI.googleAI() | FirebaseAI.agentPlatform() |
| Billing | Free tier on the Spark plan with no payment method; paid tiers need the Blaze plan and a linked Cloud Billing account, and most projects prepay | Requires billing from the start |
| Google Cloud credit | Cannot be used | Can be used |
| Location | No location parameter | location parameter, default global |
| App Check protection | Yes | Yes |
Switching is one line, as long as the model you pick is listed for that API on Firebase's models page:
FirebaseAI.agentPlatform().generativeModel(model: 'gemini-3.8-flash')
Note the default location changed: the old vertexAI() defaulted to us-central1, while agentPlatform() defaults to global. Firebase AI Logic itself is free; costs come from the Gemini API tier you use (see Firebase AI Logic pricing), and some preview and media-generating models may need billing even on the Developer API.
How do I add function calling to a Flutter Gemini chatbot?
Declare your tools on the model with Tool.functionDeclarations, then pass an onFunctionCall handler to FirebaseProvider. The provider runs the whole loop: it sends the prompt, receives the function call, runs your handler, returns the result to Gemini, and repeats until the model produces a final text answer.
This is adapted from the official function calls example in the flutter/ai repository:
final provider = FirebaseProvider(
model: FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.8-flash',
tools: [
Tool.functionDeclarations([
FunctionDeclaration(
'get_time',
'Get the current local time',
parameters: {},
),
FunctionDeclaration(
'c_to_f',
'Convert a temperature from Celsius to Fahrenheit',
parameters: {
'temperature': Schema.number(description: 'The temperature in Celsius'),
},
),
]),
],
),
onFunctionCall: _onFunctionCall,
);
Future<Map<String, Object?>?> _onFunctionCall(FunctionCall functionCall) async =>
switch (functionCall.name) {
'get_time' => {'time': DateTime.now().toIso8601String()},
'c_to_f' => {
'temperature':
(functionCall.args['temperature'] as num).toDouble() * 1.8 + 32,
},
_ => throw Exception('Unknown function call: ${functionCall.name}'),
};
Since toolkit 0.9.2, the provider handles multiple tool calls in a loop, so one prompt can trigger several tools, and the result of one call can feed the next. In my practice, tool handlers carry the real risk: anything that reads user data or spends money checks permissions inside the handler.
How do I save and restore chat history?
Serialize each ChatMessage with toJson(), store it, then rebuild the list with ChatMessage.fromJson() and assign it to provider.history. Listen to the provider, because it is a ChangeNotifier, and save whenever it changes. Clear the conversation with provider.history = [].
@override
void initState() {
super.initState();
_loadHistory();
}
@override
void dispose() {
_provider.removeListener(_saveHistory);
super.dispose();
}
Future<void> _loadHistory() async {
final history = <ChatMessage>[];
for (final map in await _readSavedMessages()) { // your storage
history.add(ChatMessage.fromJson(map));
}
if (!mounted) return;
_provider.history = history;
// Attach after loading, so restoring history does not write it straight back.
_provider.addListener(_saveHistory);
}
Future<void> _saveHistory() async {
final maps = _provider.history.map((m) => m.toJson()).toList();
await _writeSavedMessages(maps); // your storage
}
Two details from the 1.0.0 source of FirebaseProvider: setting history calls notifyListeners(), which is why the listener is attached after loading; and during a reply it notifies once, when the response is complete, not on every streamed chunk, so this saves once per exchange without a debounce. A custom provider may notify more often, so check yours. The official history example writes one JSON file per message to a chat-history folder under path_provider's temporary directory. For real apps, the Flutter team's AI Chat sample stores many chats per user in an authenticated Cloud Firestore database and asks the LLM to title each chat. If you go that way, sign-in comes first; my Firebase Authentication guide for Flutter covers that part.
If you recreate the provider, for example after a settings change, pass _provider.history.toList() to the new provider's history parameter so the conversation survives.
What permissions do voice input and attachments need?
The toolkit uses the record package for voice and file_selector and image_picker for attachments, and the Flutter docs defer to their setup guides. On iOS you need usage descriptions in Info.plist, on Android the RECORD_AUDIO permission, and on macOS extra sandbox entitlements.
| Platform | Voice input (record) | Images and files |
|---|---|---|
| Android | RECORD_AUDIO permission | No setup for image_picker; Android 13+ uses the system Photo Picker |
| iOS (13.0+) | NSMicrophoneUsageDescription | NSPhotoLibraryUsageDescription and NSCameraUsageDescription |
| macOS (10.15+) | NSMicrophoneUsageDescription plus the com.apple.security.device.audio-input entitlement | com.apple.security.files.user-selected.read-only entitlement |
| Web | Photo capture follows the camera plugin's setup, per the Flutter AI Toolkit docs | |
The minimum OS versions differ by plugin, and the table above uses the highest floor of the three:
| Plugin | iOS | macOS | Android SDK |
|---|---|---|---|
image_picker | 13+ | 10.15+ | 24+ |
file_selector | 12+ | 10.14+ | 21+ |
record | 12.0 | 10.15 | 23 |
If you record video with image_picker, iOS also needs NSMicrophoneUsageDescription.
<!-- android/app/src/main/AndroidManifest.xml -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- macos/Runner/*.entitlements -->
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
The image_picker docs note that NSPhotoLibraryUsageDescription is not requested when requestFullMetadata is false, but App Store policy still requires the plist entry. If a feature does not belong in your app, turn it off instead of requesting permissions you cannot justify:
LlmChatView(
provider: _provider,
enableAttachments: false,
enableVoiceNotes: false,
)
By default the provider also transcribes voice notes. To use your own speech-to-text, pass a function to speechToText. In 1.0.0 it is a typedef, Stream<String> Function(XFile file), not an interface class, whatever older docs say.
How do I secure Firebase AI Logic with App Check?
Add Firebase App Check, use the debug provider while developing, and switch to Play Integrity on Android and App Attest or DeviceCheck on Apple before release. Firebase calls this critical when apps call Gemini directly, and starting November 2, 2026, App Check enforcement is required to use Firebase AI Logic at all.
flutter pub add firebase_app_check
import 'package:firebase_app_check/firebase_app_check.dart';
import 'package:flutter/foundation.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await FirebaseAppCheck.instance.activate(
providerAndroid: kDebugMode
? const AndroidDebugProvider()
: const AndroidPlayIntegrityProvider(),
providerApple: kDebugMode
? const AppleDebugProvider()
: const AppleAppAttestProvider(),
);
runApp(const MaterialApp(home: ChatPage()));
}
This uses the providerAndroid and providerApple parameters from firebase_app_check 0.4.9, the line that works with firebase_ai 3.15. The older androidProvider and appleProvider enums you see in many snippets are deprecated there. The rest of the routine:
- Register the debug token. On iOS, add the
-FIRDebugEnabledlaunch argument and copy the token from the Xcode console; on Android, look for "Enter this debug secret into the allow list" in the log. Add it under Security, App Check, Apps, Manage debug tokens. - Never ship or commit the debug token. Firebase says this explicitly.
- Web: use
ReCaptchaV3ProviderorReCaptchaEnterpriseProviderin release. For local debugging setself.FIREBASE_APPCHECK_DEBUG_TOKEN = trueinweb/index.html, and never add localhost to the reCAPTCHA allowed domains. - Older Apple devices: App Attest needs iOS 14.0 or macOS 14.0. There is also
AppleAppAttestWithDeviceCheckFallbackProvider, which falls back to DeviceCheck.
Since firebase_ai 3.12.0, App Check and Auth are picked up automatically, so you do not pass them to FirebaseAI. For replay protection, create the instance with FirebaseAI.googleAI(useLimitedUseAppCheckTokens: true). Limited-use tokens have a fixed five-minute lifetime and can add latency, and Firebase's App Check page lists minimum SDK versions for them, so check that table first.
When should chat go through your own backend instead?
For production, the Flutter docs recommend routing AI requests through a backend such as Cloud Functions for Firebase, Cloud Run or your own server, so the backend controls access rather than the client. The toolkit supports this: write a custom LlmProvider that calls your server and keep the same LlmChatView.
The decision rule I use:
| Situation | Setup |
|---|---|
| Prototype or MVP on Gemini | Firebase AI Logic + App Check, with FirebaseProvider |
| Paying users, per-user quotas, or a non-Gemini model | Custom LlmProvider + your own backend proxy |
A custom provider extends LlmProvider with ChangeNotifier and implements three things: generateStream (a one-off call that does not interact with chat history or build on it), sendMessageStream (adds the user message and the response to history), and the history getter and setter. The Flutter docs call the toolkit's EchoProvider useful as a minimal provider example. If you only need to log or reroute some prompts, messageSender lets you intercept each message before it reaches the provider.
My practice: in TourVista, Nest AI and Fluently AI, keys stay behind a backend proxy and responses stream to the UI over server-sent events. I use Firebase AI Logic with App Check for prototypes and MVPs, and a custom provider plus proxy once there are paying users, per-user quotas or a non-Gemini model. The server side is in my guide to stopping hardcoded LLM API keys in Flutter, and calling OpenAI, Gemini or Claude directly is covered in integrating LLM models into a Flutter app. If the task is small enough to run on the phone, see on-device AI in Flutter. For where this screen fits in a full AI-assisted build, see how to build a Flutter app with AI in 2026, and if you write the app with a coding agent, my Dart and Flutter MCP server setup guide connects it to your running app.
Frequently Asked Questions
What is the Flutter AI Toolkit?
It is the official flutter_ai_toolkit package from the Flutter team: chat widgets such as LlmChatView built on an abstract LLM provider API. It handles multi-turn chat, streaming, voice input, attachments, function calling and chat serialization, and ships a FirebaseProvider that talks to Gemini through Firebase AI Logic.
Does the Flutter AI Toolkit need an API key?
No. You give FirebaseProvider a model name, and access runs through your Firebase project. Toolkit 0.9.0 replaced GeminiProvider and VertexProvider with FirebaseProvider, and the Flutter docs say both Gemini options require a Firebase project, with no API key provided by you. If you build a custom provider for your own backend, the keys live on that server, not in the app.
Why does flutter_ai_toolkit install firebase_ai 3.x instead of 5.x?
flutter_ai_toolkit 1.0.0 constrains firebase_ai to ^3.0.0, so pub cannot pick the 5.x line. The newest version that resolves is firebase_ai 3.15.0, which needs firebase_core ^4.13.0. In 3.15.0, use FirebaseAI.agentPlatform() for the Agent Platform Gemini API, because vertexAI() is deprecated there.
What replaced GeminiProvider and VertexProvider?
FirebaseProvider. The flutter_ai_toolkit 0.9.0 changelog says it "removes both GeminiProvider and VertexProvider and replaces it with FirebaseProvider." Pass FirebaseProvider a model from FirebaseAI.googleAI() for the Gemini Developer API or FirebaseAI.agentPlatform() for the Agent Platform Gemini API.
Is Firebase AI Logic free? Do I need the Blaze plan?
Firebase AI Logic itself is free. The Gemini Developer API free tier runs on the no-cost Spark plan without a payment method. Paid tiers need the Blaze plan and a linked Cloud Billing account, and most projects must prepay. The Agent Platform Gemini API requires billing.
Can I use the Flutter AI Toolkit without Firebase?
Yes, with a custom provider. Any LLM endpoint that can implement the LlmProvider interface can plug into LlmChatView, including OpenAI, Claude or your own backend. The built-in FirebaseProvider is the only bundled provider for a real model; EchoProvider is a minimal example for testing.
Which platforms does the Flutter AI Toolkit support?
Android, iOS, web and macOS, according to the Flutter docs, and firebase_ai covers the same four. Each needs its own setup, mainly network access on Android and macOS plus microphone and photo permissions if you keep voice input and attachments.
Do I need Firebase App Check for Firebase AI Logic?
Yes. Firebase calls App Check critical for apps that call Gemini directly, guided setup has auto-enforced it since early July 2026, and from November 2, 2026 enforcement is required to use Firebase AI Logic. Use debug providers in development and Play Integrity, App Attest, DeviceCheck or reCAPTCHA in release.
Which Gemini model should I use with Firebase AI Logic in 2026?
Firebase's Flutter get-started sample uses gemini-3.8-flash. The other stable Gemini 3.x Flash and Flash-Lite models on Firebase's models page are gemini-3.7-flash, gemini-3.6-flash, gemini-3.5-flash, gemini-3.5-flash-lite and gemini-3.1-flash-lite; gemini-4-argon is also stable but needs the Blaze plan. Avoid gemini-2.0-flash, which shut down June 1, 2026. gemini-2.5-flash shut down on the Agent Platform Gemini API on October 20, 2026, and on the Gemini Developer API it is deprecated with no shutdown date yet, open only to projects that already used it. Keep the name in Remote Config so you can change it without a release.
If you want an AI chat built into your Flutter app with the right security model from day one, whether that is Firebase AI Logic with App Check or a custom provider behind your own proxy, see my Flutter AI development service or get in touch.