{"error":{"code":402,"message":"Your prepayment credits are depleted.}}

Everything in my project works fine, but when I call the Gemini API, I get this error:

{ “code”: 402,
“message”: "Your prepayment credits are depleted. Please go to AI Studio at https://ai.studio/projects to manage your project and billing. Learn more at https://ai.google.dev/gemini-api/docs/billing#prepay. ",
“status”:“RESOURCE_EXHAUSTED”}

Note: I already have billing enabled for this project, and I also have an AI Pro active subscription and enough GCP monthly credits (Google Developer Program premium benefit - CREDIT_TYPE_MONTHLY) in my billing account.

According to the Billing doc link in the error, it says this:

  • “No credits” if the billing account is required to purchase credits but the Prepay payments account isn’t set up, or the available credit balance is depleted.

Does anyone know how to fix this error in the Gemini API?

Hello @harsh.trivedi,

On the Prepay billing plan, eligible Google Cloud credits (including monthly Google Developer Program credits from a Google AI Pro subscription) cannot be applied to Gemini API usage until you establish an active, positive balance in your AIS prepaid wallet (Gemini API Billing).

Per the Gemini API Billing documentation:

Prepay users must first purchase Prepaid credits before any eligible Google Cloud credits can be applied to Gemini API usage. Once you have an active Prepay credit balance, Google Cloud credits that are eligible for the Gemini API are consumed before your Prepay credit balance. When your Prepay credit balance on the billing account hits $0, Google Cloud credits will no longer be consumed.

To resolve this error, go to AI Studio Billing and purchase the minimum required prepayment (the minimum amount is shown in the AI Studio billing interface and varies by market) to activate your AIS prepaid wallet, after which your eligible Google Cloud credits will be consumed first (Purchase Prepay credits).