FAQ and troubleshooting

This page provides answers to frequently asked questions (FAQs) andtroubleshooting information about theGemini API and theFirebase AI Logic SDKs.

Firebase AI Logic and its client SDKs were formerly called "Vertex AI in Firebase". In May 2025, werenamed and repackaged our services intoFirebase AI Logic to better reflect our expanded services and features — for example, we now support theGemini Developer API!

Status dashboards

General FAQ

Why did the name change from "Vertex AI in Firebase" to "Firebase AI Logic"?

Back in 2024, we launched a set of Firebase client SDKs that could use theVertex AI Gemini API as well as a Firebase proxy gateway to protect thatAPI from abuse and to enable integrations with other Firebase products. Wecalled our product "Vertex AI in Firebase", and this product name accuratelydescribed our product's available use cases at that time.

Since then, though, we've expanded the capabilities of our product. For example,as of May 2025, we now offer support for theGemini Developer API,including the ability to protect theGemini Developer API from abuseusing our integration withFirebase App Check.

As a result, the name "Vertex AI in Firebase" no longer accurately representsthe expanded scope of our product. Thus,a new name —Firebase AI Logic —better reflects our evolving feature set and allows us to continue to expand ourofferings in the future!

Check out themigration guideto make sure you get all the latest features fromFirebase AI Logic (andoptionally start using theGemini Developer API).

What are the differences between using theGemini Developer API and theVertex AI Gemini API?

The following table lists important differences between the two"Gemini API" providersin general regardless of how you access them:

Gemini Developer APIVertex AI Gemini API
Pricing Available on both the no-cost Spark pricing plan and the pay-as-you-go Blaze pricing plan1 Always requires the pay-as-you-go Blaze pricing plan1 (when used withFirebase AI Logic)
Rate limits (quota) Explicit rate limits Uses dynamic shared quota (DSQ) that everyone using that model in that region shares. Provisioned throughput (PT) is available.
Specifying the location for accessing the model not supported by the API supported by the API
Support forCloud Storage URLs not supported by the API2 Public files and
files protected byFirebase Security Rules
Support for YouTube URLs and Browser URLs YouTube URLs only YouTube URLs and Browser URLs

1The two API providers have different pay-as-you-go pricing(learn more in their respective documentation).

2TheFiles API for theGemini Developer API is not supported through theFirebase AI Logic SDKs.


The following table lists the availability of commonly asked about features forthe two "Gemini API" providers. This table appliesspecifically whenusing theFirebase AI Logic client SDKs.

FeatureGemini Developer APIVertex AI Gemini API
Support forGemini models supported supported
Support forImagen models supported supported
Support for Veo models not supported yet not supported yet
Support for theGemini Live API supported
(Android, Flutter, Web, and Unity only)
supported
(Android, Flutter, Web, and Unity only)
Integration withFirebase App Check supported supported
Compatible withFirebase Remote Config supported supported
Support forAI monitoring inFirebase console supported supported
Note:When usingFirebase AI Logic, the following capabilities arenot yet supported:context caching,fine tuning a model,embeddings generation,semantic retrieval,native audio for theLive API, and someadvanced features ofImagen models.

Can I use both theGemini Developer API and theVertex AI Gemini API?

Yes, you can have both "Gemini API" providers enabled in your Firebaseproject, and you can use both APIs in your app itself.

To switch between API providers in your code, just make sure that you'veset the backend service appropriately in your code.

Important: If your project is on the pay-as-you-go Blaze pricing plan (which is requiredto use theVertex AI Gemini API and several other products in theFirebase andGoogle Cloud ecosystem), be aware thatall calls to theGemini Developer API are pay-as-you-go.

What are the required APIs? And how do I enable them?

Select your Gemini API provider to view provider-specific content

To use theFirebase AI Logic SDKs with theGemini Developer API, your project must have the following two APIsenabled:

You should enable these two APIs using theFirebase console:

  1. In theFirebase console, go to theFirebase AI Logic page.

  2. ClickGet started.

  3. Select to get started with theGemini Developer API.

    This launches a guided workflow that enables the two APIs for you. Theconsole will also generate aGemini API key, as well as add theFirebase AI Logic API to the allowlist for yourFirebase API key.

Which models can be used with theFirebase AI Logic SDKs?

Seelists of supported models.We frequently add new capabilities to the SDKs, so check back on this FAQ forupdates (as well as in release notes, blogs, and social posts).

  • Gemini Developer API

    • BothGemini andImagen foundation models.

      Note that theGemini Developer API (regardless of how it'saccessed) only supportsspecific stableImagen models.

  • Vertex AI Gemini API

    • BothGemini andImagen foundation models.
  • Regardless of your chosenGemini API provider

    • Firebase AI Logic doesnot support the following:

      • Non-foundationGemini models(like PaLM models, tuned models, or Gemma-based models).

      • OlderImagen models orimagen-3.0-capability-001.

What to do when models are retired?

When we release a stable model version, we strive to ensure that it's availableforat minimum one year before retiring the model.

Note: When a stable version is released for a given model, all experimental andpreview versions of that model will usually be retired within a few days orweeks. Also, model versions that have been announced for retirement will oftenbe restricted to existing projects or to projects that have previously used thatmodel.

Where to find the retirement date of a model?

Here are some ways you can find the retirement date of a model:

What to do if the model you're using is about to retire?

  1. Find a suitablecurrently supported model and itsmodel name.

  2. Update the model name used by your appbefore the retirement date;otherwise, any requests to that model will fail with a 404 error.

    • You set the model name during initialization when youcreate aGenerativeModel,LiveModel, orImagenModel instance.Make sure to review the critical recommendation below aboutusingFirebase Remote Config.

    • When usingFirebase AI Logic, youusually don't need to modify anyof the code which actually calls the model.

  3. Test your app to ensure that responses are still as expected.

Because requests to retired models fail,we strongly recommend that you donot hard-code the model and model version into your app's codebase. Instead,set up and useFirebase Remote Config to control the model and model version used in your app.

WithRemote Config, you can dynamically andremotely change the model and model version used by your app without releasing a new version of your app. Any already released versions of your app (that are configured to useRemote Config) will immediately start using the new model and model name.

Retirement dates for the Gemini 1.5 and 1.0 stable models

  • Gemini 1.5 Pro models:

    • gemini-1.5-pro-002 (andgemini-1.5-pro): September 24, 2025
    • gemini-1.5-pro-001: May 24, 2025
  • Gemini 1.5 Flash models:

    • gemini-1.5-flash-002 (andgemini-1.5-flash): September 24, 2025
    • gemini-1.5-flash-001: May 24, 2025
  • Gemini 1.0 Pro Vision models: April 21, 2025(previously scheduled for April 09, 2025)

  • Gemini 1.0 Pro models: April 21, 2025(previously scheduled for April 09, 2025)

How do I set a per-user rate limit?

By default,Firebase AI Logic sets the request limit per user at100 requests per minute (RPM).

If you want to adjust your per-user rate limit, you need to adjust the quotasettings for theFirebase AI Logic API.

Learn more about theFirebase AI Logic API quota.On that page, you can also learn how to view and edit your quota.

Which permissions may be needed to use theFirebase AI Logic SDKs?

ActionRequired IAM permissionsIAM role(s) that include required permissions by default
Upgrade billing to pay-as-you-go (Blaze) pricing planfirebase.billingPlans.update
resourcemanager.projects.createBillingAssignment
resourcemanager.projects.deleteBillingAssignment
Owner
Enable APIs in projectserviceusage.services.enableEditor
Owner
Create Firebase appfirebase.clients.createFirebase Admin
Editor
Owner

DoesFirebase AI Logic use my data to train models?

SeeData governance & Responsible AI.

Is MIME type required in my multimodal requests? (like for images, PDFs, video, and audio input)

Yes, in each multimodal request, you must always provide the following:

  • The file'smimeType.See an exception below.

  • The file. You can either provide the file as inline data or provide the fileusing its URL.

Learn about supported input file types, how to specify MIME type, and the twooptions for providing the file inSupported input files and requirements.

Exception to including MIME type in your request

An exception to providing the MIME type is inline image inputs forrequests from native Android and Apple platform apps.

TheFirebase AI Logic SDKs for Android and Apple platforms provide asimplified and platform-friendly way to handle images in requests — all images(no matter their format) are converted client-side to JPEG at 80% quality beforebeing sent to the server. This means thatwhen you provideimages as inline data using the Android and Apple platforms SDKs, you don'tneed to specify the MIME type in the request.

This simplified handling is shown in theFirebase AI Logic documentation inthe examples for sending base64-encoded images in requests.

Here's some additional platform-specific information about this feature:

  • For Android:

    • You can take advantage of the simplified way to handle platform-native imagetypes (Bitmap) in multimodal prompts that contain images as inline data(seeexample).

    • For more control over image formats and conversions, you may provide theimages as anInlineDataPart and supply the specific MIME type.For example:

      content { inlineData(/* PNG as byte array */, "image/png") }

  • For Apple platforms:

    • You can take advantage of the simplified way to handle platform-native imagetypes (UIImage,NSImage,CIImage, andCGImage) in multimodal promptsthat contain images as inline data(seeexample).

    • For more control over image formats and conversions, you may provide theimages as anInlineDataPart and supply the specific MIME type.For example:

      InlineDataPart(data: Data(/* PNG Data */), mimeType: "image/png")

Are these features available when usingFirebase AI Logic? Context caching, fine tuning a model, embeddings generation, semantic retrieval, and native audio?

The following features are supported by various models and the API providers,butthey are not available when usingFirebase AI Logic:

  • Context caching
  • Fine tuning a model
  • Embeddings generation
  • Semantic retrieval
  • Native audio for theLive API

If you would like to add these as feature requests or vote on an existingfeature request, visitFirebase UserVoice.

Gemini API key FAQ

These FAQ are only applicable if you're using theGemini Developer API.

What's aGemini API key?

TheGemini Developer API uses a "Gemini API key" to authorizethe caller. So, if you're using theGemini Developer API through theFirebase AI Logic SDKs, then you need a validGemini API keyin your Firebase project to make calls to that API.

A "Gemini API key" just means an API key that has theGemini Developer API in its API allowlist.

Note: TheGemini Developer API is sometimes called the"Generative Language API" in theGoogle Cloud console.

When you go through theFirebase AI Logic setup workflow in theFirebase console, we create aGemini API key that'srestricted to only theGemini Developer API, and we set up theFirebase AI Logic proxy service to use this API key. This Firebase-generatedGemini API key is namedGemini Developer API key (auto created by Firebase) in the credentials page oftheGoogle Cloud console.

Learn more aboutAPI restrictions for API keys.

You donot add yourGemini API key to your app's codebase whenusing theFirebase AI Logic SDKs. Learn more about how tokeep yourGemini API key secure.

Should I add myGemini API key into my mobile or web app's codebase?

When using theFirebase AI Logic SDKs, donot add yourGemini API key into your app's codebase.

In fact, while developing with theFirebase AI Logic SDKs, you don'tdirectly interact with yourGemini API key. Instead, ourFirebase AI Logic proxy service will internally include theGemini API key in each request to theGemini Developer API —completely in the backend.

As soon as you start seriously developing your app,it's critical that youintegrate withFirebase App Check so that only requests from your actual app and verified devices are passed through to the backend.

How can I change theGemini API key used to call theGemini Developer API?

When using theFirebase AI Logic SDKs, it's unlikely that you'll needto change yourGemini API key. However, here are two cases where youmight need to:

  • If you accidentally leaked the key and want to replace it with a new securekey.

  • If you accidentally deleted the key. Note that you canundelete the key within 30 days of deletion.

Here's how you change theGemini API key that's used by theFirebase AI Logic SDKs:

  1. If your Firebase-generatedGemini API key still exists, delete it.

    You can delete this API key in theAPIs & Services >Credentials panel of theGoogle Cloud console. It's named:
    Gemini Developer API key (auto created by Firebase).

  2. In that same page of theGoogle Cloud console,create a new API key. We suggest naming it something like:
    Gemini Developer API key for Firebase.

  3. To this new API key,add API restrictions and only selectGenerative Language API.
    "Generative Language API" is what theGemini Developer API issometimes called in theGoogle Cloud console.

    Donot add anyapp restrictions;otherwise theFirebase AI Logic proxy service won't work as expected.

  4. Run the following command to set this new key as theGemini API keythat theFirebase AI Logic proxy service should use.

    PROJECT_ID="PROJECT_ID"GENERATIVE_LANGUAGE_API_KEY="DEVELOPER_CREATED_GEMINI_API_KEY"curl \  -X PATCH \  -H "x-goog-user-project: ${PROJECT_ID}" \  -H "Authorization: Bearer $(gcloud auth print-access-token)" \  -H "Content-Type: application/json" \  "https://firebasevertexai.googleapis.com/v1beta/projects/${PROJECT_ID}/locations/global/config" \  -d "{\"generativeLanguageConfig\": {\"apiKey\": \"${GENERATIVE_LANGUAGE_API_KEY}\"}}"

    Learn about thegcloud CLI.

Make sure tonot add this newGemini API key to your app'scodebase. Learn more about how tokeep yourGemini API key secure.

Note: You can alwaysreach out to Firebase Support for questionsand guidance when working with API keys.

Can I use my "Firebase API key" as myGemini API key?

No — you shouldnot use your "Firebase API key" as yourGemini API key. We strongly recommend that you donot add theGemini Developer API to the allowlist for your Firebase API key.

Your Firebase API key is the API key that's listed in yourFirebase configuration file or object that you add into your app's codebase toconnect your app to Firebase.It's OK to include your Firebase API key in yourcodewhen you use the key only with Firebase-related APIs(likeFirebase AI Logic).Learn important information about Firebase API keys.

In theAPIs & Services >Credentials panel of theGoogle Cloud console, this is what Firebase API keys look like:

API keys automatically created by Firebase for your Firebase Apps

Because you need to add your Firebase API key into your app's codebase forFirebase-related APIs to work, and because theGemini Developer API isauthorized via API key,we strongly recommend that you do NOT add theGemini Developer API (called the "Generative Language API" in theGoogle Cloud console) to the API allowlist for your Firebase API key. If youdo, then you're exposing theGemini Developer API to potential abuse.

How do I keep myGemini API key secure?

This FAQ describes some recommended best practices to keep yourGemini API key secure.

If you're calling theGemini Developer API directly from yourmobile or web app:

  • Use theFirebase AI Logic client SDKs.
  • Donot add yourGemini API key into your app's codebase.

Firebase AI Logic provides a proxy service that internally includes yourGemini API key in each request to theGemini Developer API —completely in the backend.

Additionally, we strongly recommend the following:

  • As soon as you start seriously developing your app,integrate withFirebase App Check to helpprotect your backend resources as well as the APIs used to access generativemodels.

  • Donot reuse the Firebase-generatedGemini API key outside ofFirebase AI Logic. If you need aGemini API key for another usecase, create a separate key.

  • In general, you should NOT modify the Firebase-generatedGemini API key. This key is namedGemini Developer API key (auto created by Firebase) in theGoogle Cloud console.

    • Donot add any additional APIs to the API allowlist for yourFirebase-generatedGemini API key. In its API allowlist, yourGemini API key shouldonly have theGemini Developer API (called the "Generative Language API" in theGoogle Cloud console).

    • Donot add anyapp restrictions;otherwise theFirebase AI Logic proxy service won't work as expected.

MyGemini API key was compromised. What do I need to do?

If yourGemini API key has been compromised, follow the instructions tochange theGemini API keythat's used to call theGemini Developer API.

Also, review the recommended best practices tokeep yourGemini API key secure.

Troubleshoot errors

How do I fix this 404 error?Firebase AI Logic genai config not found

If you're attempting to use theGemini Developer API and you receive a404 error that saysFirebase AI Logic genai config not found, it usually meansthat your Firebase project doesn't have a validGemini API key for usewith theFirebase AI Logic client SDKs.

Here are the most likely causes of this error:

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

    What to do:
    In theFirebase console, go to theFirebase AI Logic page. ClickGet started, and then select theGemini Developer API. Enablethe API, and the console will set up your project for theGemini Developer API. After completing the workflow, try your requestagain.

  • If you very recently went through theFirebase AI Logic setup workflowin theFirebase console, then yourGemini API key might not yet beavailable to all required backend services in all regions.

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

  • YourGemini API key might have been deleted from yourFirebase project.

    What to do:
    Learn how tochange theGemini API key used byFirebase AI Logic.

How do I fix this 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 aCloud Storage for FirebaseURL, 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 agentscorrectly auto-provisioned when theVertex AI API was enabled inthe project. This is a known issue with some projects, and we're working on aglobal fix.

Here's the workaround to fix your project and correctly provision these serviceagents so that you can start includingCloud Storage for Firebase URLs in yourmultimodal requests. You must be anOwner on the project, and you only need tocomplete this set of tasks once for your project.

  1. Access and authenticate with thegcloud CLI.
    The easiest way to do this is fromCloud Shell. Learn more in theGoogle Cloud documentation.

  2. If prompted, follow the instructions displayed in the terminal to make thegcloud CLI run against your Firebase project.

    You'll need your Firebase project ID, which you can find at the top of theProject settings in theFirebase console.

  3. Provision the required service agents in your project by running thefollowing 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, andthen retry sending your multimodal request that includes theCloud Storage for Firebase URL.

If you're still getting this error after waiting several minutes, reach out toFirebase Support.

How do I fix this 400 error?API key not valid. Please pass a valid API key.

If you receive a 400 error that saysAPI key not valid. Please pass a valid API key., it usually means that theAPI key in your Firebase configuration file/object doesn't exist or isn't setupto be used with your app and/or Firebase project.

Check that the API key listed in your Firebase configuration file/object matchesthe API key for your app. You can view all your API keys in theAPIs & Services >Credentials panel in theGoogle Cloud console.

If you discover that they don't match, thenobtain a fresh Firebase configuration file/object,and thenreplace the one that's in your app. The fresh config file/objectshould contain a valid API key for your app and Firebase project.

How do I fix this 403 error?Requests to this API firebasevertexai.googleapis.com ... are blocked.

If you receive a 403 error that saysRequests to this API firebasevertexai.googleapis.com ... are blocked., itusually means that the API key in your Firebase configuration in your app hasrestrictions that prevent it from calling the required API.

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

Follow these steps:

  1. In theGoogle Cloud console, open theAPIs & 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 theEdit API key page, find theAPI restrictions section.

  4. Ensure theRestrict key option is selected. If it isn't, your key isunrestricted, and this is likely not the source of the error.

    Note: If you have an unrestricted API key, we strongly recommend that youapply"API restrictions"to your Firebase API key.
  5. In theSelected APIs drop-down menu, search for and select theFirebase AI Logic API to add it to the list of selectedAPIs that can be called using the API key.

  6. ClickSave.

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

Note: Firebase-related APIs use API keys only toidentify the Firebase projector app,not for authorization to call the API (like some other APIs allow).Authorization for Firebase-related APIs is handled separately from the API key,either throughGoogle Cloud IAM permissions,Firebase Security Rules, orFirebase App Check. Learn more aboutFirebase API keys.

How do I fix this 403 error?PERMISSION_DENIED: The caller does not have permission.

If you receive a 403 error that saysPERMISSION_DENIED: The caller does not have permission., it usually means thatthe API key in your Firebase configuration file/object belongs to a differentFirebase project.

Check that the API key listed in your Firebase configuration file/object matchesthe API key for your app. You can view all your API keys in theAPIs & Services >Credentials panel in theGoogle Cloud console.

If you discover that they don't match, thenobtain a fresh Firebase configuration file/object,and thenreplace the one that's in your app. The fresh config file/objectshould contain a valid API key for your app and Firebase project.

How do I fix the 404 error that says a 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-2.5-flash-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 allsupported and available models.Be sure to check the segments and their order in the model name.For example, the "nano banana" model name isgemini-2.5-flash-image-previewnotgemini-2.5-flash-preview-image-generation.

  • Invalid location(only applicable if using theVertex AI Gemini API provider and apreview model)

    • Cause: You're using apreview version of a model(for example,gemini-2.5-flash-image-preview), and you didn't specify theglobal location.

      If you use theVertex AI Gemini API, all Gemini 2.5 and laterpreview models released after June 2025 are only available in thegloballocation (including the preview version of "nano banana"). However, sinceFirebase AI Logic defaults to theus-central1 location, you need to explicitlyspecify theglobal location when initializing theVertex AI Gemini API backend service in your code when using thesepreview models.

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

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

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

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

      • Imagen models arenot supported in thegloballocation.
      • Gemini Live API models (likegemini-2.0-flash-live-preview-04-09) areonly supported in theus-central1location.
      • Gemini 2.5 models (likegemini-2.5-pro) areonly available in theglobal location, the US locations, and some European locations(and sometimes in other locations if your project has specialoptions).
    • Fix: When you initialize theVertex AI Gemini API service,make sure that you specify a supported location for the model that you'reusing. Learn more about how tospecify the location for accessing the model(including code snippets) and thesupported locations for models.

      Note thatFirebase AI Logic defaults to theus-central1 location.


Give feedback about your experience withFirebase AI Logic


Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-03 UTC.