Error codes

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

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

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

  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 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 : 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.

To fix this, you need to update your API key's restrictions in the Google Cloud console to include the required API. For Firebase AI Logic , you must ensure the Firebase AI Logic  API ( firebasevertexai.googleapis.com ) is included in the list of selected APIs that can be called using the API key.

Follow these steps:

  1. In the Google Cloud console, open the APIs & Services > Credentials panel.

  2. Select the API key that your application is configured to use (for example, the "iOS key" for an iOS app).

  3. On the Edit API key page, find the API restrictions section.

  4. Ensure the Restrict keyoption is selected. If it isn't, your key is unrestricted, and this is likely not the source of the error.

  5. In the Selected APIs drop-down menu, search for and select the Firebase AI Logic  API to add it to the list of selected APIs that can be called using the API key.

  6. Click Save.

    It may take up to five minutes for the changes to take effect.

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.

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.

404 error : Firebase AI Logic genai config not found

If you're attempting to use the Gemini Developer API and you receive a 404 error that says Firebase AI Logic genai config not found , it usually means that your Firebase project doesn't have a valid Gemini API key for use with the Firebase AI Logic client SDKs.

Here are the most likely causes of this error:

  • You haven't yet set up your Firebase project for the Gemini Developer API .

    What to do:
    In the Firebase console, go to AI Services> AI Logic . Click Get started, and then select the Gemini Developer API . Enable the API, and the console will set up your project for the Gemini Developer API . After completing the workflow, try your request again.

  • If you very recently went through the Firebase AI Logic setup workflow in the Firebase console, then your Gemini API key might not yet be available to all required backend services in all regions.

    What to do:Wait a few minutes, and then try your request again.

  • Your Gemini API key might have been deleted from your Firebase project.

    What to do:
    Learn how to change the Gemini API key used by Firebase AI Logic .

404 error : the model " was not found or your project does not have access to it "?

For example: " Publisher Model projects/PROJECT-ID/locations/us-central1/publishers/google/models/gemini-3-pro-image-preview was not found or your project does not have access to it. Please ensure you are using a valid model version. "

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

  • Invalid model name

    • Cause: The model name you've provided isn't a valid model name.

    • Fix: Check your model name and model version against the list of all supported and available models . Be sure to check the segments and their order in the model name. For example:

      • The Gemini 3.1 Pro preview model name is gemini-3.1-pro-preview .
      • The Gemini 3 Flash preview model name is gemini-3-flash-preview .
      • The "Nano Banana Pro" preview model name is gemini-3-pro-image-preview .
      • The "Nano Banana 2" preview model name is gemini-3.1-flash-image-preview .
      • The "Nano Banana" model name is gemini-2.5-flash-image .
  • Invalid location (only applicable if using the Vertex AI Gemini API provider and a previewor experimentalmodel)

    • Cause: You're using a preview or experimental version of a model (for example, gemini-3.1-pro-preview and gemini-3.1-flash-image-preview ), and you didn't specify the global location.

      If you use the Vertex AI Gemini API , all preview and experimental Gemini models (except Gemini Live models) are only available in the global location. However, since Firebase AI Logic defaults to the us-central1 location, you need to explicitly specify the global location when initializing the Vertex AI Gemini API backend service in your code when using these preview and experimental Gemini models.

    • Fix: When you initialize the Vertex AI Gemini API service, specify the location global . Learn more about how to specify the location for accessing the model (including code snippets).

  • Invalid location (only applicable if using the Vertex AI Gemini API provider)

    • Cause: You're using a model that's not supported in the location where you're trying to access it.

      If you use the Vertex AI Gemini API , some models are only available in specific locations . For example (but not exhaustive):

      • Imagen models are not supported in the global location.
      • Gemini Live API models (like gemini-2.0-flash-live-preview-04-09 ) are only supported in the us-central1 location.
      • Gemini 2.5 models (like gemini-2.5-pro ) are only available in the global location, the US locations, and some European locations (and sometimes in other locations if your project has special options).
    • Fix: When you initialize the Vertex AI Gemini API service, make sure that you specify a supported location for the model that you're using. Learn more about how to specify the location for accessing the model (including code snippets) and the supported locations for models .

      Note that Firebase AI Logic defaults to the us-central1 location.

429 errors : "You exceeded your current quota, please check your plan and billing details" or "Resource exhausted, please try again later."

429 errors indicate that you're either going over your quota or the model you're accessing is overloaded by requests from other people.

The action to take depends on whether you're using the Gemini Developer API or Vertex AI Gemini API . For more information about quotas and how to request additional quota, see Rate limits and quotas .

If you're using the Vertex AI Gemini API , the Google Cloud documentation provides some additional context and guidance for Error code 429 .

Create a Mobile Website
View Site in Mobile | Classic
Share by: