This page describes how to migrate from the Google AI client SDKs to the Vertex AI in Firebase client SDKs in your mobile or web apps. The Vertex AI in Firebase SDKs are available for Apple platforms (Swift), Android (Kotlin and Java), Web (JavaScript), and Flutter (Dart).
Go directly to migration instructions
Why migrate to use Vertex AI?
You might have tried out an alternative version of a Gemini API using Google AI Studio or the Google AI client SDKs. These SDKs are useful for getting started with the Gemini API and prototyping. However, for production or enterprise-scale mobile and web apps that directly call a Gemini API client-side, Firebase strongly recommends calling the Vertex AI Gemini API using our Firebase SDKs.
Security features for mobile and web apps
For mobile and web apps, security is critical and requires special considerations because your code (including calls to the Gemini API) is running in an unprotected environment.
By default, the Vertex AI Gemini API is authorized by Google Cloud IAM (rather than by an API key like the Google AI Gemini API). The Vertex AI in Firebase SDKs are built to call the more secure Vertex AI Gemini API.
For mobile and web apps, you need to protect the Gemini API and your project resources (like tuned models) from abuse by unauthorized clients. You can use Firebase App Check to verify that all API calls are from your actual app, and this feature is only available if you use the Vertex AI in Firebase SDKs.
Ecosystem built for mobile and web apps
Firebase is Google's platform for developing mobile and web apps. Using the Vertex AI in Firebase SDKs means that your apps are in an ecosystem that's focused on the needs of full-stack apps and developers. For example, you're set up to do any of the following and much more:
Use Cloud Storage for Firebase to include large files in your multimodal requests. Also, take advantage of client SDKs that handle file uploads and downloads (even in poor network conditions) and offer more security for your end-users' data. Learn more in our solution guide about using Cloud Storage for Firebase.
Manage structured data using database SDKs built for mobile and web apps (like Cloud Firestore).
Dynamically set run-time configurations (like location) or swap out values in your app (like a model name) without releasing a new app version using Firebase Remote Config.
Additional benefits of using Vertex AI from Google Cloud
As your use of generative AI in your app and workflows mature, you might need a platform that offers end-to-end solutions for building and deploying generative AI applications. Google Cloud provides a comprehensive ecosystem of tools to enable you to harness the power of generative AI, from the initial stages of app development to app deployment, app hosting, and managing complex data at scale.
The Vertex AI platform from Google Cloud offers a suite of MLOps tools that streamline usage, deployment, and monitoring of AI models for efficiency and reliability. Additionally, integrations with databases, DevOps tools, logging, monitoring, and IAM provide a holistic approach to managing the entire generative AI lifecycle.
Learn more about the use cases of Vertex AI in the Google Cloud documentation.
Migrate to the Vertex AI in Firebase SDKs
Migrating to the Vertex AI in Firebase SDKs requires three main steps:
Set up a new or existing Firebase project and connect your app to Firebase.
Migrate your codebase, which only requires changing the SDK and initialization code (including the model name). There's no modification needed for any of the code which actually calls the Gemini API.
Delete any unused API keys and disable unused APIs.
Step 1: Set up a Firebase project and connect your app to Firebase
Even if you're already familiar with Firebase, review this section to make sure that your Firebase project and app are set up to use the Vertex AI in Firebase SDKs.
In the Firebase console, go to the Build with Gemini page.
Click the Vertex AI in Firebase card to launch a workflow that helps you complete the following tasks:
Upgrade your project to use the pay-as-you-go Blaze pricing plan.
Enable the required APIs in your project (Vertex AI API and Vertex AI in Firebase API).
Continue to the next step in this guide to migrate your codebase to use the Vertex AI in Firebase SDKs.
Sign into the Firebase console.
Click Create project, and then use any of the following options:
Option 1: Create a wholly new Firebase project (and its underlying Google Cloud project automatically) by entering a new project name in the first step of the "Create project" workflow.
Option 2: "Add Firebase" to an existing Google Cloud project by selecting your Google Cloud project name from the drop-down menu in the first step of the "Create project" workflow.
You can use the Google Cloud project that was created for you by Google AI Studio when you created your Google AI API key. You can find the name of that project in the API key section of Google AI Studio.
You can use any other existing Google Cloud project.
Note that when prompted, you do not need to set up Google Analytics to use the Vertex AI in Firebase SDKs.
In the Firebase console, go to the Build with Gemini page.
Click the Vertex AI in Firebase card to launch a workflow that helps you complete the following tasks:
Upgrade your project to use the pay-as-you-go Blaze pricing plan.
Enable the required APIs in your project (Vertex AI API and Vertex AI in Firebase API).
Continue in the console's workflow to connect your app to Firebase, which includes these tasks:
Registering your app with your Firebase project.
Adding your Firebase config to your app's codebase.
Step 2: Migrate your codebase
Select the platform of your app to view platform-specific instructions.
The Google AI SDKs and the Vertex AI in Firebase SDKs were built so that migrating between the two platforms is as straightforward as possible.
To migrate, you only need to change which SDK you integrate into your app's codebase and the initialization of the service and the generative model. You don't need to modify any of the code which actually calls the Gemini API!
Change the SDK
Google AI
Vertex AI in Firebase
Change the initialization
Google AI
Vertex AI in Firebase
Step 3: Delete any unused API keys and disable unused APIs
If you no longer need to use your Google AI API key, follow security best practices and delete it. You can view and delete your Google AI API keys in the API keys section of Google AI Studio.
Also, if you're no longer using the Google AI Gemini API, disable it in
your project. You can do this in the Google Cloud console from the
Generative Language API (generativelanguage.googleapis.com
) page. ("Generative Language API" is the official name of the
Google AI Gemini API.)
What else can you do?
- Both Google AI and Vertex AI offer a web UI "playground" experience called "AI Studio" for experimenting with prompts and model parameters. Learn how to migrate your Google AI Studio prompts to Vertex AI Studio in the Google Cloud documentation.