Hello,
Newly created Gemini API keys are returning API_KEY_INVALID for me across multiple Google Cloud projects.
What I have verified:
- Google AI Studio itself works successfully with Gemini.
- Billing is active and identity verification has been completed.
- Gemini API (generativelanguage.googleapis.com) is enabled.
- A newly created Gemini API key is bound to an enabled service account.
- The key is restricted to the Gemini API.
- I tested freshly copied keys from two different projects.
- I verified that the copied key strings contained no control characters.
- I tested directly against the REST endpoint, without using any SDK:
GET https://generativelanguage.googleapis.com/v1beta/models
Header: x-goog-api-key: [REDACTED]
Both newly created keys return:
400 INVALID_ARGUMENT
reason: API_KEY_INVALID
service: generativelanguage.googleapis.com
message: “API key not valid. Please pass a valid API key.”
The same account can successfully run Gemini inside Google AI Studio, so Gemini access itself appears to be working.
Could someone please check whether there is an issue with Gemini API key issuance/authentication for my account or projects, or advise what additional configuration is required for these newly created keys?
I have intentionally not included any API key values for security reasons.
Thank you.