Error codes  |  Firebase AI Logic

Error codes

This page provides troubleshooting of common error codes for the Gemini API and the Firebase AI Logic SDKs.

Error Codes

400 error: API key not valid. Please pass a valid API key.

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 set up 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.

400 error: Service agents are being provisioned ... Service agents are needed to read the Cloud Storage file provided.

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 Agent Platform API was enabled in the project. This is a known issue with some projects, and we're working on a global fix.

Workaround

  1. Access and authenticate with the gcloud CLI.
    The easiest way to do this is from Cloud Shell. Learn more in the Google Cloud documentation.
  2. 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 settings Project settings in the Firebase console.
  3. 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 ''
    
  4. 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.

403 error: PERMISSION_DENIED: To access this model, you must enforce Firebase App Check.

If you receive a 403 - PERMISSION_DENIED error that says To access this model, you must enforce Firebase App Check., it means that your request doesn't have a valid App Check token and you're attempting to access a model that's commonly abused.

Some generative models have been identified as common for malicious actors to abuse.

To help protect our developers, Firebase blocks access to these models unless the request includes a valid App Check token (meaning App Check is enforced for Firebase AI Logic).

To Access the Model

  1. Set up App Check for Firebase AI Logic. For local development, make sure that you set up the App Check debug provider.
  2. Resend the request from your app to Firebase AI Logic. This request will send along a valid App Check token, and you'll no longer get this 403 - PERMISSION_DENIED error.
  3. Before you release your app to end-users, you need to set up a production attestation provider (like App Attest, Play Integrity, or reCAPTCHA Enterprise) so that your end-users can access your AI feature when App Check is enforced.

403 error: PERMISSION_DENIED: Firebase AI Logic has been deactivated in this project.

If you receive a 403 - PERMISSION_DENIED error that says Firebase AI Logic has been deactivated in this project., it means that your Firebase project has been identified as inactive and you don't have App Check enforced for Firebase AI Logic.

To Resume Using Firebase AI Logic

  1. Set up App Check for Firebase AI Logic. For local development, make sure that you set up the App Check debug provider.
  2. Resend the request from your app to Firebase AI Logic. This request will send along a valid App Check token, and you'll no longer get this 403 - PERMISSION_DENIED error.
  3. Before you release your app to end-users, you need to set up a production attestation provider (like App Attest, Play Integrity, or reCAPTCHA Enterprise).

403 error: PERMISSION_DENIED: The caller does not have permission.

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.

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 in your app has restrictions that prevent it from calling the required API.

404 error: Firebase AI Logic genai config not found

If you receive a 404 error that says Firebase AI Logic genai config not found, it usually means that a setting for Firebase AI Logic is misconfigured or missing.

429 errors: You exceeded your current quota, please check your plan and billing details.

There are a couple different reasons why you could get an error like this:

For more details, see the Firebase pricing documentation and the Gemini Developer API pricing documentation and billing FAQ.