The latest Gemini models, likeGemini 3.1 Flash Image(Nano Banana 2), are available to use with Firebase AI Logic!Learn more.
Gemini 2.0 Flash and Flash-Lite models will shut down onJune 1, 2026. To avoid service disruption, update to a newer model likegemini-2.5-flash-lite.Learn more.
Error codesStay organized with collectionsSave and categorize content based on your preferences.
This page provides troubleshooting of common error codes for theGemini APIand theFirebase AI Logic SDKs.
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 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 theAPIs & Services>Credentialspanel in theGoogle Cloudconsole.
If you discover that they don't match, thenobtain a fresh Firebase configuration file/object,
and thenreplacethe 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 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 agents
correctly auto-provisioned when theVertex 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 includingCloud Storage for FirebaseURLs in your
multimodal requests. You must be anOwneron the project, and you only need to
complete this set of tasks once for your project.
Access and authenticate with thegcloud CLI. The easiest way to do this is fromCloud Shell. Learn more in theGoogle Clouddocumentation.
If prompted, follow the instructions displayed in the terminal to make thegcloud CLIrun against your Firebase project.
You'll need your Firebase project ID, which you can find at the top of thesettingsProject settingsin theFirebaseconsole.
Provision the required service agents in your project by running the
following command:
Wait a few minutes to ensure that the service agents are provisioned, and
then retry sending your multimodal request that includes theCloud Storage for FirebaseURL.
If you're still getting this error after waiting several minutes, reach out toFirebase Support.
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., 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 theGoogle Cloudconsole to include the required API. ForFirebase AI Logic,
you must ensure theFirebase AI Logic API(firebasevertexai.googleapis.com) is included in the list of selected
APIs that can be called using the API key.
Select the API key that your application is configured to use (for example,
the "iOS key" for an iOS app).
On theEdit API keypage, find theAPI restrictionssection.
Ensure theRestrict keyoption is selected. If it isn't, your key is
unrestricted, and this is likely not the source of the error.
In theSelected APIsdrop-down menu, search for and select theFirebase AI Logic APIto add it to the list of selected
APIs that can be called using the API key.
ClickSave.
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 saysPERMISSION_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 theAPIs & Services>Credentialspanel in theGoogle Cloudconsole.
If you discover that they don't match, thenobtain a fresh Firebase configuration file/object,
and thenreplacethe 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 theGemini Developer APIand you receive a
404 error that saysFirebase AI Logic genai config not found, it usually means
that your Firebase project doesn't have a validGeminiAPI key for use
with theFirebase AI Logicclient 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 theFirebaseconsole, go toAI Services>AI Logic. ClickGet started, and then select theGemini Developer API. Enable the API, and the console will set up
your project for theGemini Developer API. After completing the
workflow, try your request again.
If you very recently went through theFirebase AI Logicsetup workflow
in theFirebaseconsole, then yourGeminiAPI 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.
YourGeminiAPI key might have been deleted from your
Firebase project.
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 allsupported and available models.
Be sure to check the segments and their order in the model name.
For example:
TheGemini 3.1 Propreview model name isgemini-3.1-pro-preview.
TheGemini 3 Flashpreview model name isgemini-3-flash-preview.
The "Nano Banana Pro" preview model name isgemini-3-pro-image-preview.
The "Nano Banana 2" preview model name isgemini-3.1-flash-image-preview.
The "Nano Banana" model name isgemini-2.5-flash-image.
Invalid location(only applicable if using theVertex AIGemini APIprovider and aprevieworexperimentalmodel)
Cause: You're using aprevieworexperimentalversion of a model
(for example,gemini-3.1-pro-previewandgemini-3.1-flash-image-preview), and you didn't specify thegloballocation.
If you use theVertex AIGemini API, allpreviewandexperimentalGeminimodels (except Gemini Live models) are only
available in thegloballocation. However, sinceFirebase AI Logicdefaults to theus-central1location, you need
to explicitly specify thegloballocation when initializing theVertex AIGemini APIbackend service in your code when using thesepreviewandexperimentalGeminimodels.
Fix: When you initialize theVertex AIGemini APIservice,
specify the locationglobal. Learn more about how tospecify the location for accessing the model(including code snippets).
Invalid location(only applicable if using theVertex AIGemini APIprovider)
Cause: You're using a model that's not supported in the location where
you're trying to access it.
Imagenmodels arenotsupported in thegloballocation.
Gemini Live APImodels (likegemini-2.0-flash-live-preview-04-09)
areonlysupported in theus-central1location.
Gemini 2.5 models (likegemini-2.5-pro) areonlyavailable in thegloballocation, the US locations, and some European locations
(and sometimes in other locations if your project has special
options).
Note thatFirebase AI Logicdefaults to theus-central1location.
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 theGemini Developer APIorVertex AIGemini API. For more
information about quotas and how to request additional quota, seeRate limits and quotas.
If you're using theVertex AIGemini API, theGoogle Clouddocumentation
provides some additional context and guidance forError code 429.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-04-17 UTC."],[],[]]