Vertex AI in Firebase launched to General Availability (GA) on October 21, 2024.
If you used the preview version of the Vertex AI in Firebase library
(firebase/vertexai-preview
), then you need to make the following
changes to upgrade to use the GA version of the library
(firebase/vertexai
).
Here's a high-level list of the changes required to migrate:
- Enable the new required API in your Firebase project (required for everyone)
- Update to the GA version of the library (required for everyone)
- Additional changes (required depending on features you use)
Enable the new required API in your Firebase project (required for everyone)
You need to enable the Vertex AI in Firebase API in your Firebase project and add it to the allowlist of your Firebase API key. This is a new API that's required to use the GA version of Vertex AI in Firebase.
In the Firebase console, go to the Build with Gemini page.
In the Vertex AI in Firebase card, click Get started to launch a workflow that helps you to enable this API and add it to the allowlist of your Firebase API key.
You can skip the rest of the workflow in the console.
Update to the GA version of the library (required for everyone)
Follow these instructions to update your app's codebase to use the GA version of the library:
Get the latest version of the Firebase JS SDK for Web using npm:
npm i firebase@latest
OR
yarn add firebase@latest
Wherever you've imported the library, update your import statements to use
firebase/vertexai
:// BEFORE import { initializeApp } from "firebase/app";
import { getVertexAI, getGenerativeModel } from "firebase/vertexai-preview";// AFTER import { initializeApp } from "firebase/app"; import { getVertexAI, getGenerativeModel } from "firebase/vertexai";
Additional changes (required depending on features you use)
Several changes were implemented for the GA versions of the SDKs. Review the following lists for any changes that you might need to make in your code to accommodate taking up the GA-version of the SDK in your app.
Function calling
If you implemented this feature before GA, then you'll need to make updates to how you define your schema. We recommend reviewing the updated function calling guide to learn how to write your function declarations.Generating structured output (like JSON) using
responseSchema
If you implemented this feature before GA, then you'll need to make updates to how you define your schema. We recommend reviewing the new structured output guide to learn how to write JSON schemas.Timeout
- Changed the default timeout for requests to be 180 seconds.
Enumerations
- Removed values from the following enumerations:
HarmCategory
,BlockThreshold
,HarmProbability
,HarmSeverity
,BlockReason
, andFinishReason
.
- Removed values from the following enumerations:
Block reason
- Changed
blockReason
inPromptFeedback
to be optional.
- Changed
Possible errors related to migrating
As you're migrating to use the GA version of Vertex AI in Firebase, you might encounter errors if you haven't completed all of the required changes as described in this migration guide.
403 Error: Requests to this API firebasevertexai.googleapis.com ... are blocked.
If you receive a 403 error that says
Requests to this API firebasevertexai.googleapis.com ... are blocked.
,
it usually means that the API key in your Firebase configuration file/object
doesn't have a required API in its allowlist for the product that you're trying
to use.
Make sure that the API key used by your app has all the required APIs included in the key's "API restrictions" allowlist. For Vertex AI in Firebase, your API key needs to have at minimum the Vertex AI in Firebase API in its allowlist. This API should have been automatically added to your API key's allowlist when you enabled the new API via the Firebase console.
You can view all your API keys in the APIs & Services > Credentials panel in the Google Cloud console.