API_KEY_INVALID / 404 error even with active billing (Project ID: gen-lang-client-0030150852)

Hi, I am facing a critical issue where my Gemini API keys return “API_KEY_INVALID” (HTTP 400) or “404 Not Found” despite having an active billing account with usage history.

Environment:

  • Billing Status: Active (Pay-as-you-go)
  • Usage: Already charged ~100 JPY (confirmed in billing reports)
  • API: Generative Language API is enabled

Problem:

When calling the API (Gemini 1.5 Flash) via Python, it returns:
“API key not valid. Please pass a valid API key.”

I have already contacted Billing Support (Case 70187434), and they confirmed that my billing account is active and healthy. However, they could not solve the technical synchronization issue between the billing status and the API gateway.

I’ve tried:

  1. Creating new API keys.
  2. Re-importing the project to Google AI Studio.
  3. Testing with different Google accounts.
    But the result is always 404/400.

Could someone from the Google team check if there is a backend synchronization delay or a project-specific restriction?

CRITICAL UPDATE: I received a system email titled “[Action needed] Complete your billing setup for the Gemini API” even though my billing account is already active and being charged (currently 119 JPY).

Evidence of use (provided by Cloud Billing Support Case 70187434): Usage is recorded under these SKUs:

  • Generate_content text output token count for gemini 1.5 flash | ACA6-865B-F153

  • Generate_content text input token count for gemini 1.5 flash | F2C1-F842-5D84

This proves the billing backend is working, but the account is stuck in a “pending setup” state in the API gateway. Please manually refresh the entitlement for Project: gen-lang-client-0030150852.

Hey, got the same problem, have you managed to fix this?

Hi @akaneko @youssof

I have DM’ed you for more details

Hi youssof,

I managed to fix the issue! In my case, I didn’t use the automatically generated key. Instead, I went to the Google Cloud Console, navigated to “APIs & Services” > “Credentials”, and clicked “Create Credentials” at the top to manually create a new “API key”.

Using this manually created key resolved the 404 / API_KEY_INVALID error immediately. It seems like manually associating the key with the project in the Cloud Console makes a difference. Hope this works for you too!

2026年4月22日(水) 9:07 Mustansir Lokhandwala <notifications@discuss.ai.google.dev>: