The AI Feature of my appdoesn't work on deployment

I have confirmed the below things:
Confirmed GEMINI_API_KEY exists and has versions in Secret Manager.

  • Confirmed apphosting.yaml correctly configured (e.g., runConfig: maxInstances: 1, secrets: GEMINI_API_KEY

  • Confirmed 940461553688@cloudbuild.gserviceaccount.com has the Secret Manager Secret Accessor role in IAM (both at project-level and verified at secret-level).

  • Confirmed 940461553688-compute@developer.gserviceaccount.com also has Secret Manager Secret Accessor .

  • Ran firebase apphosting:secrets:grantaccess GEMINI_API_KEY --backend studio --project glyphforge-wg95q .

  • Gemini api is enabled for the project

The server logs shows message: ‘API key not valid. Please pass a valid API key.’ I have checked the secret manager the key is available, there are 2 versions, one created by the firebase itseld and other from the ai studio,
What to do now? Any suggestions.

1 Like