Google Cloud Guide: Replacing Raw API Keys with ADC and Service Accounts
·2026.11.21 02:03
Key point
The guide outlines a five-step process to migrate from raw API keys to Application Default Credentials and Service Accounts, including spend caps and Model Armor guardrails.
Details
- Google Cloud recommends removing raw API keys from AI Studio to prevent unauthorized usage and financial exposure, replacing them with Application Default Credentials (ADC) and Service Accounts.
- The migration involves five steps: setting up individual logins via
gcloud auth application-default login, calling models (Gemini, Claude, OpenAI) through a single credential, assigning Service Accounts to applications, applying least privilege withroles/aiplatform.user, and managing residual keys in Secret Manager. - Additional protections include spend caps (currently in Preview) that pause services when limits are exceeded, Model Armor for screening prompt injections and jailbreaks, and sandboxed code execution for model-generated Python.
- A 20-minute checklist is provided for teams to implement these changes, including running a key scanner and deleting all AI Studio keys after migration.
Implementation Details
- Model calls use specific SDKs:
google-genaifor Gemini (e.g.,gemini-4-hydrogen),AnthropicVertexfor Claude (e.g.,claude-sonnet-5-5), and OpenAI SDK pointed to Google Cloud endpoints for models likeopenai/gpt-oss-120b-maas. - Spend caps operate on estimated costs and are not immediate; overages are still billed, and service recovery after a cap trigger can take up to one hour.
- Companion code and samples are available in the repository
github.com/sergiov8/secure-your-keys-demo.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.