Click your Gemini API provider to view provider-specific content and code on this page. |
Rate limits (commonly called quotas) regulate the number of requests you can make to the Gemini API within a given timeframe. These limits help ensure fair usage, protect against abuse, and help maintain system performance for all users.
When using Firebase AI Logic to send requests to Gemini and Imagen models, your project's rate limits depend on your chosen "Gemini API" provider. Firebase AI Logic also provides a way to set "per user" rate limits.
View rate limits for the Gemini Developer API
How rate limits (quotas) work
Rate limits (quotas) are measured across four dimensions:
- Requests per minute (RPM)
- Requests per day (RPD)
- Tokens per minute (TPM)
- Tokens per day (TPD)
Your usage is evaluated against each limit, and exceeding any of them will trigger a 429 quota-exceeded error. For example, if your RPM limit is 20, then making 21 requests within a minute will result in an error, even if you haven't exceeded your TPM or other limits.
Rate limits are applied at the project-level and apply to all applications and IP addresses that use that Firebase project.
Limits vary depending on the specific model being used, and some limits only apply to specific models. For example, images per minute (IPM) is only calculated for models capable of generating images (Imagen 3), but is conceptually similar to TPM.
Rate limits are more restricted for experimental and preview models.
Request a rate limit increase
If you're on a "paid tier" for the Gemini Developer API, then you can request a rate limit increase.
Set "per user" rate limits
To use Firebase AI Logic, your project needs your chosen Gemini API provider enabled, but you also need the Firebase AI Logic API enabled, which acts as a gateway between our client SDKs and your Gemini API provider. This API is enabled for you when you initially set up Firebase AI Logic in your Firebase project.
You can use the Firebase AI Logic API rate limit (quota) as a "per user" rate limit for your app, specifically for the AI features that rely on Firebase AI Logic. You should set this limit to reasonably accommodate a single user accessing your AI features, while also ensuring that no single user overwhelms the limits of your Gemini API provider (which is meant to be shared by all your users).
Details about the "per user" rate limit
Here are some important details about the Firebase AI Logic API rate limits (quotas) -- specifically, requests per minute (RPM):
It's based on "Generate content requests" on a per-user per-region per-minute basis, and it's not based on model.
It applies at the project-level and applies to all applications and IP addresses that use that Firebase project.
It applies to any call that specifically comes from any Firebase AI Logic SDK.
The default rate limit is 100 RPM per user.
Note that you still need to consider the limits for your Gemini API provider (see above), which take precedence over the Firebase AI Logic API.
Adjust the "per user" rate limit
To adjust a rate limit (quota), you must have the serviceusage.quotas.update
permission, which is included by default in the Owner and Editor role.
Here's how to edit your rate limit (quota) or request an increase:
In the Google Cloud console, go to the page for the Firebase AI Logic API.
Click Manage.
Lower on the page, click the Quotas & System Limits tab.
Filter the table to show the quotas of interest, like the capability (requests for generating content) and region.
For example, to view the per-user quotas for generating content requests in any of the supported Asian regions, your filter would look similar to this:
Generate content requests
+Dimension:region:asia
Select the checkbox to the left of each quota of interest.
At the end of the quota's row, click
, and then select Edit quota.In the Quota changes form, do the following:
Enter the increased quota in the New value field.
This quota applies at the project-level and is shared across all applications and IP addresses that use that Firebase project.
Complete any additional fields in the form, and then click Done.
Click Submit request.