The key is recognized, but Gemini says I do not have the required permission.
Why this happens
Authentication verifies identity, whereas authorization grants access. A valid key might lack target model access, be restricted to specific IPs/referrers, or belong to an unauthorized project.
Answer 1: Check the key’s API and application restrictions
In Google Cloud or AI Studio settings, verify that the Generative Language API is enabled and that IP, HTTP referrer, or API restrictions match your execution environment.
