AI Cloud Architect

Securing Your Gemini and Google API Keys

GoogleHow-to by Leonid YankulinGoogle Cloud Blog (developers and practitioners)

Protect your Gemini API keys with this guide on API restrictions, secure storage in Secret Manager, and key hygiene to prevent hijacking and unauthorized use.

Read the original (opens the source's page in a new tab)

AI: Summary

What it is

Step-by-step guidance on restricting, storing and monitoring Google API keys used for Gemini, including deleting and auditing keys that may be compromised.

Who it is for

Developers and cloud teams who hold Gemini API keys for AI Studio or agents and need to limit misuse of those keys.

Key points

  • Create keys in a standalone project and restrict them to the minimum APIs, for example only Gemini API for AI Studio.
  • Store keys in Secret Manager rather than in code or visible places; a Gemini key is a standard Google API key.
  • Deleted keys can be undeleted within 30 days; track usage with the serviceruntime api request_count metric.