|---|
| *Click your Gemini API provider to view provider-specific content and code on this page.* <button value="dev" default="">Gemini Developer API</button> <button value="vertex">Agent Platform Gemini API</button> |

<br />

<br />

**Using Firebase AI Logic is free-of-charge.**
However, the costs for your Gemini API usage and whether your Firebase
project needs to be on the [pay-as-you-go Blaze pricing plan](https://firebase.google.com/pricing.md.txt) depends on your chosen
Gemini API provider and the features of Firebase AI Logic that you use.

For the Gemini Developer API:

- Pricing is largely based on the model and features that you use.

- Using some models (especially preview models and media-generating models)
  might require billing.

This page provides a *high-level overview* of pricing and billing account
requirements. For more details, see the
[Gemini Developer API pricing documentation](https://ai.google.dev/gemini-api/docs/pricing)
and
[billing FAQ](https://ai.google.dev/gemini-api/docs/billing).

> [!TIP]
> **Tip:** If you're new to Firebase and Google Cloud, check if you're eligible for [$300 of credit](https://firebase.google.com/support/faq.md.txt#pricing-free-trial) and a Free Trial Cloud Billing account.  
> Note that this credit *cannot* be used towards Gemini Developer API costs, but the credit can be used for the Agent Platform Gemini API (formerly Vertex AI) and most other paid Firebase and Google Cloud services that you'd use for your app.

## Billing account requirements

The Gemini Developer API offers different tiers for its pricing. The
following sections provide a *high-level overview* of these tiers, but review
their details in the
[Gemini Developer API pricing documentation](https://ai.google.dev/gemini-api/docs/pricing).

### Gemini Developer API "free tier"

The Gemini Developer API "free tier" lets you get started without having
to provide a payment method. It gives you limited access to certain models and
access to many basic features.

To use this "free tier", you do ***not*** link your project to a
Cloud Billing account. This means your Firebase project is on the
[no-cost Spark pricing plan](https://firebase.google.com/pricing.md.txt).

### Gemini Developer API "paid tiers"

The Gemini Developer API "paid tiers" are available when you require
higher volumes or want access to more models or advanced features.

To use these "paid tiers", you must link your project to a
Cloud Billing account. This means your Firebase project is upgraded to the
[pay-as-you-go Blaze pricing plan](https://firebase.google.com/pricing.md.txt).

Here are some important key points about the Gemini Developer API and
linking a Cloud Billing account:

- **Prepayment usually required**   

  After linking a Cloud Billing account, the Gemini Developer API
  requires most projects to *provide a prepayment* to access the API
  (especially for projects with a new Cloud Billing account). To learn if
  your project has additional billing setup requirements, "import" your
  Firebase project into Google AI Studio (find the button in the
  top-right of the [**Projects** page](https://aistudio.google.com/projects)).

- **All usage of the Gemini Developer API is pay-as-you-go**   

  After linking a Cloud Billing account, *all usage* of the
  Gemini Developer API is *pay-as-you-go pricing* (including any usage
  through the Firebase AI Logic SDKs). Note that all Firebase and
  Google Cloud services (like Cloud Firestore) continue to offer their own
  specific [no-cost usage levels](https://firebase.google.com/pricing.md.txt).

- **Set up budget alerts and spend caps**   

  As part of linking a Cloud Billing account, we strongly recommend that you
  set up [**budget alerts**](https://firebase.google.com/docs/projects/billing/budget-alerts.md.txt) and
  [**spend caps**](https://firebase.google.com/docs/projects/billing/spend-caps.md.txt) for the
  Gemini Developer API.

  Note that the budgets you set for an API are not specific to usage of the API
  via Firebase AI Logic (for example, the budget applies if you use the API
  via a GenAI server SDK or Genkit in the same Google Cloud project).

Learn more about billing setup and payments in the
[Gemini Developer API billing documentation](https://ai.google.dev/gemini-api/docs/billing#setup-billing).

## Other considerations for costs

If you're on the Blaze pricing plan, you might incur costs
when you use other products in conjunction with Firebase AI Logic:

- **Other Firebase products may incur costs.**
  For details, see the [Firebase pricing page](https://firebase.google.com/pricing.md.txt).

  - Using some of the attestation providers supported by Firebase App Check.

  <!-- -->

  - Using Firebase Authentication beyond the no-cost usage levels.

  - Using any of Firebase's database products beyond their no-cost usage levels.

- **AI monitoring in the Firebase console may incur costs.**   

  While AI monitoring in the Firebase console is free-of-charge itself, you
  may incur costs if you go beyond the no-cost usage levels of the underlying
  Google Cloud Observability Suite products. Learn more in the
  [Google Cloud Observability Suite pricing documentation](https://cloud.google.com/products/observability#pricing).

## Recommendations to manage costs

We recommend doing the following to help manage your costs:

- Avoid surprise bills:
  [monitor your costs and usage](https://firebase.google.com/docs/ai-logic/monitoring.md.txt),
  [set up budget alerts](https://firebase.google.com/docs/projects/billing/budget-alerts.md.txt),
  and
  [set up spend caps](https://firebase.google.com/docs/projects/billing/spend-caps.md.txt).

- When using Gemini models (except Live API models), get an
  estimate of the [token size](https://firebase.google.com/docs/ai-logic/count-tokens.md.txt)
  of your requests using the `countTokens` API before sending your requests and
  accessing the `usageMetadata` attribute in your responses.

- Set an appropriate
  [thinking level](https://firebase.google.com/docs/ai-logic/thinking.md.txt) (except Live API models)
  and `maxOutputTokens` (all models) in the
  [model's configuration](https://firebase.google.com/docs/ai-logic/model-parameters.md.txt).

- [Enable AI monitoring](https://firebase.google.com/docs/ai-logic/monitoring.md.txt#ai-monitoring-in-console)
  to view dashboards in the Firebase console with
  information about your requests, including token counts.