- Option 1 (Restrict existing keys): Go to Google Cloud Credentials, select your key, and under API restrictions, restrict it to Gemini API (generativelanguage.googleapis.com).
- Option 2 (New keys): Generate new restricted keys in Google AI Studio and update your code.
Note: Keys generated directly in AI Studio are restricted to the Gemini API by default.