Gemini API returning 400 API_KEY_INVALID error despite correct setup

Hello, I am trying to use the Gemini API (generativelanguage.googleapis.com) from a Python script. My Google Cloud project is “Gemini API”. I have already performed extensive troubleshooting and have confirmed the following: 1. I have generated a new, valid API key. 2. The “Generative Language API” is ENABLED in my Google Cloud Console. 3. A billing account is active and correctly linked to my project. 4. My local computer and code are correctly configured to send the API key with the request. Despite all of this being correct, Google’s servers are still rejecting my valid key with a `400 API_KEY_INVALID` error. This seems to be a backend provisioning issue with my account or project. Could a Googler or community expert please advise on why my valid key might be rejected? Thank you.

@Raj one typical cause of the api key error is the Google Cloud Project not being linked to a valid billing account. Understand that you said that it’s been set already but can you please double check? You can open an issue for assistance here Public Issue Tracker if the problem persists.