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
(FirebaseVertexAI-Preview
), then you need to make the following
changes to upgrade to use the GA version of the library
(FirebaseVertexAI
).
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:
In Xcode, with your app project open, update your Firebase Package to version 11.4.0 or later using one of the following options:
Option 1: Update all packages: Navigate to File > Packages > Update to Latest Package Versions.
Option 2: Update Firebase individually: Navigate to the Firebase package in the section called Package Dependencies. Right-click on the Firebase package, and then select Update Package.
Make sure that the Firebase package now shows version 11.4.0 or later. If it does not, verify that your specified Package Requirements allow updating to version 11.5.0 or later.
Select your app's target in the Project Editor, and then navigate to the Frameworks, Libraries, and Embedded Content section.
Select the
+
button, and then add FirebaseVertexAI from the Firebase package.Select FirebaseVertexAI-Preview, and then press the
—
button.
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
Replaced most
enum
types withstruct
s with static variables. This change allows more flexibility for evolving the API in a backward-compatible way. When usingswitch
statements, you must now include adefault:
case to cover unknown or unhandled values, including new values that are added to the SDK in the future.Renamed the
BlockThreshold
enumeration toHarmBlockThreshold
; this type is now astruct
.Removed
unknown
andunspecified
cases from the following enumerations (nowstruct
s):HarmCategory
,HarmBlockThreshold
,HarmProbability
,BlockReason
, andFinishReason
.Replaced the enumeration
ModelContent.Part
with a protocol namedPart
to allow new types to be added in a backward-compatible way. This change is described in greater detail in the Content parts section.
Content parts
Removed the
ThrowingPartsRepresentable
protocol, and simplified the initializers forModelContent
to avoid occasional compiler errors. Images that don't encode properly will still throw errors when being used ingenerateContent
.Replaced the
ModelContent.Part
cases with the followingstruct
types conforming to thePart
protocol:.text
toTextPart
.data
toInlineDataPart
.fileData
toFileDataPart
.functionCall
toFunctionCallPart
.functionResponse
toFunctionResponsePart
Harm category
- Changed the
HarmCategory
to no longer be nested in theSafetySetting
type. If you're referring to it asSafetySetting.HarmCategory
, that can be replaced withHarmCategory
.
- Changed the
Safety feedback
- Removed the
SafetyFeedback
type, since it wasn't used in any of the responses.
- Removed the
Citation metadata
- Renamed the
citationSources
property tocitations
inCitationMetadata
.
- Renamed the
Total billable characters
- Changed the
totalBillableCharacters
property inCountTokensResponse
to be optional to reflect situations where no characters are sent.
- Changed the
Candidate response
- Renamed
CandidateResponse
toCandidate
to match other platforms.
- Renamed
Generation configuration
- Changed the public properties of
GenerationConfig
tointernal
. They all remain configurable in the initializer.
- Changed the public properties of