Migrate to use Vertex AI SDKs instead of Google AI SDKs


This page describes how to migrate from the Google AI client SDKs to the Vertex AI for Firebase client SDKs in your mobile or web apps. The Vertex AI for 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 SDKs. However, for production or enterprise-scale mobile and web apps that directly call a Gemini API, 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, your code (including calls to the Gemini API) is running in an unprotected environment, so security is critical.

  • 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). You can call the Vertex AI Gemini API if you use the Vertex AI for Firebase SDKs.

  • For mobile and web apps, you also 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 for Firebase SDKs.

Ecosystem built for mobile and web apps

Firebase is Google's platform for developing mobile and web apps. Using the Vertex AI for 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.

Features from the Vertex AI Gemini API

The Vertex AI Gemini API also offers different features from than the Google AI Gemini API, like more options for multimodal prompts (specifically, text-and-video and text-and-audio input).

You can learn more about the differences between the two Gemini API offerings in the Google Cloud documentation.

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 for Firebase SDKs

Migrating to the Vertex AI for Firebase SDKs requires three main steps:

  1. Set up a new or existing Firebase project and connect your app to Firebase.

  2. 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.

  3. 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 for Firebase SDKs.

Step 2: Migrate your codebase

Select the platform of your app to view platform-specific instructions.

The Google AI SDKs and the Vertex AI for 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 for Firebase

Change the initialization

Google AI

Vertex AI for 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: generativelanguage.googleapis.com.

What else can you do?