There are 2 separate issues (API key auth and Gemini model expiration) that may impact each other. I would focus on fixing the model expiration issue first.
As of 9/24/2025, Gemini 1.5 (pro and flash) were retired (see the retired models). Continue using Gemini 1.5 will cause 404 NOT FOUND error (in either Vertex AI or AI Studio). You should migrate to Gemini 2.0/2.5 Flash and later instead. Please follow the latest Gemini migration guide.
Fixing the Model expiration issue should give you a clearer picture of whether the API key still causing problem.