How to Get a Google AI API Key
To use Gemini CLI, you need a Google AI API key. This guide will walk you through the process of obtaining one for free.
Prerequisites
- ✓A Google Account (Gmail, Google Workspace, etc.)
- ✓Access to Google AI Studio (available in supported regions)
Step-by-Step Guide
Visit Google AI Studio
Go to Google AI Studio (makersuite.google.com)
Note: Google AI Studio is currently available in specific regions. If you can't access it, you may need to use a VPN or wait for availability in your region.
Sign in with Google
Click "Sign in" and authenticate with your Google account. Accept the terms of service if prompted.
Navigate to API Keys
Once signed in, look for the "Get API key" button or navigate to the API keys section:
- Click on your profile icon in the top right
- Select "API keys" from the dropdown menu
- Or look for a "Get API key" button on the main page
Create a New API Key
Click "Create API key" and choose your preferences:
- Select "Create API key in new project" for a fresh start
- Or choose an existing project if you have one
- Give your API key a descriptive name (e.g., "Gemini CLI Key")
Copy and Save Your API Key
Your API key will be displayed. Make sure to:
- Copy the entire API key string
- Save it in a secure location (password manager recommended)
- Never share your API key publicly or commit it to version control
Important: This may be the only time you can view the full API key. If you lose it, you'll need to create a new one.
API Key Limits and Quotas
Free tier includes:
- ✓60 requests per minute rate limit
- ✓1,000 requests per day quota
- ✓1 million tokens context window
- ✓Free to use for personal and commercial projects
Security Best Practices
DO ✓
- • Store API keys in environment variables
- • Use a password manager
- • Rotate keys regularly
- • Use different keys for different projects
- • Set up API key restrictions
DON'T ✗
- • Commit keys to Git repositories
- • Share keys in public forums
- • Hardcode keys in your applications
- • Use the same key everywhere
- • Ignore suspicious activity
Common Issues
Google AI Studio not available in my region
Currently, Google AI Studio has limited availability. You can check theavailable regions listor use a VPN to access from a supported region.
API key not working
Ensure you've copied the entire key, including any special characters. Check that the key hasn't expired and that you haven't exceeded rate limits.