Getting 400 Error - API Key not found

I created a paid API key on AI Studio by linking it to my Google Cloud project.

After running my Python Project (having the api key correctly set) it tells me:

Invalid argument provided to Gemini: 400 API Key not found. Please pass a valid API key. [reason: "API_KEY_INVALID"
domain: "googleapis.com"
metadata {
  key: "service"
  value: "generativelanguage.googleapis.com"
}
, locale: "en-US"
message: "API Key not found. Please pass a valid API key."
]

I don’t know what to do to be honest, because I created a new api key in a new account, I created a new api key and I didn’t use it in some hours just in case…, but the error is showing again and again right after running the code. The thing is that it was working some days ago with a free API key.

Hope someone can help me with this.

Hi @viacoo,

Welcome to the forum! To best assist you, could you please share a small code snippet showing how you’re passing the API key? This will help me understand the situation and provide more specific guidance. Thanks!

Cheers!