Ultimate guide for fixing your team’s API keys
Google advises teams to replace scattered API keys with centralized credentials to prevent costly leaks and simplify access management during AI prototype scaling.
API keys embedded in prototypes often remain unchanged as projects grow, creating security and cost risks when exposed. Developers typically store multiple keys across files and platforms, increasing the chance of accidental leaks that automated scrapers can exploit within minutes.
Google recommends replacing raw API keys with Application Default Credentials, allowing teams to use a single login for accessing models like Gemini and Claude. This approach reduces credential sprawl and streamlines access management without requiring new accounts or keys.
The process involves authorizing applications with service accounts that have only necessary permissions, then migrating remaining keys to Secret Manager. Additional safeguards like spend caps and monitoring can be added to prevent unexpected billing surges.
A companion repository provides executable samples and tools, including a scanner to locate exposed keys in codebases. The scanner flags potential leaks in CI pipelines without exposing sensitive values, enabling teams to transition credentials efficiently.