Keys / Google
GOOGLE_API_KEY
A Google Cloud API key. The Gemini API client libraries read it to call Gemini models.
- Expires
- the docs don't say
- API
- create, list and delete, with the Google Cloud API Keys API
Get it
Create one on aistudio.google.com/apikey. The steps aren't recorded yet.
Set it
GOOGLE_API_KEY=...
The Google Gen AI SDKs for Python, JavaScript, Go and Java read it from this variable when you don't pass a key. If GEMINI_API_KEY is also set, they use this one. Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- Open the key on the Cloud console's Credentials page and click Rotate key. The new key keeps the old key's restrictions. A key made in AI Studio doesn't, so add them yourself.
keypin rotatecopies the restrictions itself, using a service account with API Keys Admin; it refuses a key bound to a service account. - Deploy it everywhere that uses the old key. Keep the old key until the new one works.
- Delete the old key. You can restore a deleted key within 30 days.