Failed to generate API key: permission denied. Please try again

When trying to create an API key through AI studio, the following error shows:

Failed to generate API key: permission denied. Please try again.

The console shows a 403 (Forbidden)

I’m trying to create the API key for a project of which I’m the owner. I’m also managing the connected billing account. The following APIs are enabled:

  • Gemini for Google Cloud API
  • Vertex AI API
  • Generative Language API

I even added keys manually via credentials in APIs & Services but can’t see those in AI Studio either

I tried to create a key via another account on another project and it worked fine. Both appear to be set-up similar but there is no clue on whats going wrong and how to fix it.

Hi @Jasper_ENABL,

Welcome to the Forum,

Could you please check if you have allowed certain permissions in your GCP account?

  • Permissions required on GCP project:
    • apikeys.keys.create
    • resourcemanager.projects.update
    • serviceusage.services.enable

They essentially mean: can create api key in project, can update project, can enable services in project

Thank you!

Thanks for your suggestion chunduriv, as a quick check I added the following roles to my account:

  • Owner
  • API Keys Admin (new)
  • Project IAM Admin (new)
  • Service Usage Admin (new)

After waiting a couple of minutes for the changes to be fully processed, I am still unable to create API keys in AI Studio

I am also having the exact same issue – I am an Owner on my project, so should have all the necessary permissions, yet am being denied the API key

Quick update:

I have not changed a thing to my account or project. I tried again just now in the exact same way (25 days later) and it worked as expected. I now can create API keys through AI studio.

My best guess is that the roles suggestion worked, but it took more than 10 minutes for the changes to be visible to AI studio?