This page provides answers to frequently asked questions (FAQs) about the Gemini API and the Vertex AI in Firebase SDKs. For additional questions, check out the Gemini API FAQ in the Google Cloud documentation.
To use the Vertex AI in Firebase SDKs, your project must have the following two APIs enabled:
- Vertex AI API (
aiplatform.googleapis.com
) - Vertex AI in Firebase API (
firebasevertexai.googleapis.com
)
You can enable these APIs with a few clicks in the Firebase console:
Go to the Build with Gemini page.
Click the Vertex AI in Firebase card to launch a workflow that enables the two APIs. This workflow will also add the Vertex AI in Firebase API to your Firebase API key's allowlist.
Alternatively, you can use the Google Cloud console (more manual option):
Click each API link at the top of this FAQ entry, and then click Enable in each API's page.
Add the Vertex AI in Firebase API to your Firebase API key's allowlist by following the instructions in Add API restrictions in the Google Cloud documentation.
Action | Required IAM permissions | IAM role(s) that include required permissions by default |
---|---|---|
Upgrade billing to pay-as-you-go (Blaze) pricing plan | firebase.billingPlans.update resourcemanager.projects.createBillingAssignment resourcemanager.projects.deleteBillingAssignment
|
Owner |
Enable APIs in project | serviceusage.services.enable |
Editor Owner |
Create Firebase app | firebase.clients.create |
Firebase Admin Editor Owner |
You can use the Vertex AI in Firebase SDKs with any of the Gemini foundation models listed in Learn about the Gemini models.
You cannot use non-foundation Gemini models like PaLM models, tuned models, or Gemma-based models with the Vertex AI in Firebase SDKs.
We frequently add new capabilities to the SDKs, so check back on this FAQ for updates (as well as in release notes, blogs, and social posts).
If you're trying to send a multimodal request with a Cloud Storage for Firebase
URL, you might encounter the following 400 error:
Service agents are being provisioned ... Service agents are needed to read the Cloud Storage file provided.
This error is caused by a project that didn't have the required service agents correctly auto-provisioned when the Vertex AI API was enabled in the project. This is a known issue with some projects, and we're working on a global fix.
Here's the workaround to fix your project and correctly provision these service agents so that you can start including Cloud Storage for Firebase URLs in your multimodal requests. You must be an Owner on the project, and you only need to complete this set of tasks once for your project.
Access and authenticate with the gcloud CLI.
The easiest way to do this is from Cloud Shell. Learn more in the Google Cloud documentation.If prompted, follow the instructions displayed in the terminal to make the gcloud CLI run against your Firebase project.
You'll need your Firebase project ID, which you can find at the top of the Project settings in the Firebase console.
Provision the required service agents in your project by running the following command:
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/endpoints -d ''
Wait a few minutes to ensure that the service agents are provisioned, and then retry sending your multimodal request that includes the Cloud Storage for Firebase URL.
If you're still getting this error after waiting several minutes, reach out to Firebase Support.
If you receive a 400 error that says
API key not valid. Please pass a valid API key.
, it usually means that the
API key in your Firebase configuration file/object doesn't exist or isn't setup
to be used with your app and/or Firebase project.
Check that the API key listed in your Firebase configuration file/object matches the API key for your app. You can view all your API keys in the APIs & Services > Credentials panel in the Google Cloud console.
If you discover that they don't match, then obtain a fresh Firebase configuration file/object, and then replace the one that's in your app. The fresh config file/object should contain a valid API key for your app and Firebase project.
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.
You can view all your API keys in the APIs & Services > Credentials panel in the Google Cloud console.
If you receive a 403 error that says
PERMISSION_DENIED: The caller does not have permission.
, it usually means that
the API key in your Firebase configuration file/object belongs to a different
Firebase project.
Check that the API key listed in your Firebase configuration file/object matches the API key for your app. You can view all your API keys in the APIs & Services > Credentials panel in the Google Cloud console.
If you discover that they don't match, then obtain a fresh Firebase configuration file/object, and then replace the one that's in your app. The fresh config file/object should contain a valid API key for your app and Firebase project.
Give feedback about your experience with Vertex AI in Firebase