You canoptionally try an alternative "Google AI" version of the
Gemini APIthat provides free-of-charge access
(within limits and where available) usingGoogle AI StudioandGoogle AI SDKs.
If you choose to use Google AI tools and services as well as Firebase,
we recommend the following:
Donotuse Google AI Studio and Google AI SDKs with aFirebase projectthat's used by yourproduction app.
Step 1: Set up a Firebase project and connect your app to Firebase
If youalreadyhave a Firebase project and an app connected to Firebase
In the Firebase console, go to theBuild with Geminipage,
and then click the second card to launch a workflow that helps you do the
following tasks. If you see a tab in the console for Vertex AI, then
these tasks are complete.
ClickCreate project, and then use either 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.
Note that when prompted, you donotneed to set up
Google Analytics to use the Vertex AI for Firebase SDKs.
In the Firebase console, go to theBuild with Geminipage,
and then click the second card to launch a workflow that helps you do the
following tasks. If you see a tab in the console for Vertex AI, then
these tasks are complete.
With your Firebase project set up and your app connected to Firebase
(see previous step), you can now add the Vertex AI for Firebase SDK to your app.
Step 3: Initialize the Vertex AI service and the generative model
Before you can make any API calls, you need to initialize the Vertex AI
service and the generative model.
When you've finished the getting started guide, learn how to choose aGemini modeland (optionally) alocationappropriate for your use case and app.
Step 4: Call the Vertex AI Gemini API
Now that you've connected your app to Firebase, added the SDK, and initialized
the Vertex AI service and the generative model,
you're ready to call the Vertex AI Gemini API.
You can usegenerateContent()to generate text from a text-only prompt
request: