"Migrate google_generative_ai to firebase_ai in Flutter"
"google_generative_ai is discontinued. This guide shows how to migrate google_generative_ai to firebase_ai in Flutter: the package swap, the backend decision, the code changes, and the two errors almost everyone hits."
Your Gemini-powered Flutter app worked fine last month. Then Google archived google_generative_ai , discontinued firebase_vertexai , and shut down the legacy Google AI client SDKs — and suddenly your code is running on borrowed time. If you searched "migrate google_generative_ai to firebase_ai flutter" and landed on tutorials still showing the old GenerativeModel(apiKey:) pattern, beware: copy them and you'll inherit retired models, hardcoded API keys, and an auth model that no longer exists. This guide does the migration right — current versions, the backend choice nobody explains, App Check lockdown, and the two errors that will ambush you if you rush it. What you'll build and learn A full migration of a working text-generation screen from google_generative_ai to firebase_ai How to set up a Firebase project with AI Logic enabled (the part that replaces your API key) The Gemini Developer API vs Agent Platform backend decision — and which one you want The migration path for bare-SDK apps *and* for flutter_ai_toolkit apps How to lock the app down with App Check so your AI endpoint can't be abused Fixes for the 400 API_KEY_INVALID leftovers, retired-model 404s, and App Check 403s What actually died, and what replaces it Google consolidated everything. The legacy google_generative_ai client SDK family was shut down at the end of November 2025, and the firebase_vertexai package was discontinued too. The single replacement for both is firebase_ai — the Firebase AI Logic plugin for Flutter, currently at 4.0.0 (verified on pub.dev today). The bigger shift isn't the package name, it's the auth model. The old SDK talked to the Gemini Developer API with a raw API key embedded in your app — a key anyone could extract from your APK or IPA. The new SDK…