How to Get Your Google Gemini API Key
Walkthrough of Google AI Studio / Vertex AI API key generation.
How to Get Your Google Gemini API Key
Google offers two paths to access Gemini: Google AI Studio (free tier, quick start) and Vertex AI (enterprise, production-grade). Most professional services firms start with AI Studio for testing, then migrate to Vertex AI for client work.
This guide covers both. You'll have a working API
Path 1: Google AI Studio (Fastest Start)
Google AI Studio is the free developer platform for Gemini. No billing required. Perfect for testing prompts, building proof-of-concepts, or running internal automation.
Limitations you need to know:
- 60 requests per minute rate limit
- No SLA guarantees
- Not suitable for client-facing applications
- Data processing happens in Google's multi-tenant environment
Generate Your AI Studio API APIClick to read the full definition in our AI & Automation Glossary. Key
Step 1: Navigate to aistudio.google.com
Step 2: Sign in with any Google account (personal Gmail works fine)
Step 3: Click "Get API
Step 4: Click "Create API
Google creates a default project and generates your key instantly. Copy it immediately. The full key displays only once.
Step 5: Store the key in your password manager or secrets vault
Your key looks like this: AIzaSyB1234567890abcdefghijklmnopqrstuvwx
Test Your AI Studio Key
Open your terminal and run:
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=YOUR_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"contents": [{
"parts": [{
"text": "Explain API authentication in one sentence."
}]
}]
}'
Replace YOUR_API_KEY with your actual key. You should get a JSON response with generated text in under 2 seconds.
If you see "error": { "code": 400 }, check that you copied the full key without extra spaces.
Path 2: Vertex AI (Production-Grade)
Vertex AI is Google's enterprise AI platform. Use this for:
- Client-facing applications
- Processing confidential data
- Applications requiring uptime SLAs
- Teams needing centralized billing and access controls
Vertex AI requires a Google Cloud Platform (GCP) account with billing enabled.
Set Up Your GCP Project
Step 1: Go to console.cloud.google.com
Step 2: Click "Select a project" dropdown at the top, then "New Project"
Step 3: Name your project (example: lawfirm-ai-production)
Step 4: Click "Create"
Step 5: Enable billing
Click the hamburger menu (three lines, top left) > Billing > Link a billing account. Add a credit card. Google provides $300 in free credits for new accounts.
Enable the Vertex AI API APIClick to read the full definition in our AI & Automation Glossary.
Step 1: In the GCP Console, open the navigation menu > APIs
Step 2: Search for "Vertex AI API
Step 3: Click the Vertex AI API
This takes 30-60 seconds. You'll see a green checkmark when complete.
Create a Service Account and Key
Vertex AI uses service accounts instead of simple API
Step 1: Navigate to IAM & Admin > Service Accounts
Step 2: Click "Create Service Account"
Step 3: Fill in the details:
- Service account name:
gemini-api-access - Service account ID: (auto-fills)
- Description:
Service account for Gemini API access in [your application name]
Step 4: Click "Create and Continue"
Step 5: Grant the role "Vertex AI User"
Click "Select a role" > type "Vertex AI User" > select it > click "Continue"
Step 6: Click "Done" (skip the optional user access step)
Step 7: Find your new service account in the list and click the three dots > Manage keys
Step 8: Click "Add Key" > "Create new key" > select "JSON" > click "Create"
A JSON file downloads automatically. This file contains your credentials. Rename it to something memorable like gemini-service-account.json.
Step 9: Move this file to a secure location
Never commit this file to Git. Add *service-account*.json to your .gitignore immediately.
Test Your Vertex AI Access
Install the Google Cloud SDK if you haven't already: cloud.google.com/sdk/docs/install
Set your service account credentials:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/gemini-service-account.json"
Test with Python (install the library first: pip install google-cloud-aiplatform):
from vertexai.preview.generative_models import GenerativeModel
import vertexai
vertexai.init(project="YOUR_PROJECT_ID", location="us-central1")
model = GenerativeModel("gemini-pro")
response = model.generate_content("What is API authentication?")
print(response.text)
Replace YOUR_PROJECT_ID with your actual project ID (find it in the GCP Console dashboard).
If you see generated text, you're connected correctly.
Security Configuration
Restrict API APIClick to read the full definition in our AI & Automation Glossary. Key Scope (AI Studio)
Step 1: In AI Studio, click "Get API
Step 2: Under "API
Step 3: Choose "Generative Language API
This prevents your key from accessing other Google services if compromised.
Set Up Key Rotation (Vertex AI)
Step 1: Create a calendar reminder for 90 days from today
Step 2: When the reminder fires, generate a new service account key following the steps above
Step 3: Update your application to use the new key
Step 4: Wait 7 days, then delete the old key from the service account
This ensures zero downtime during rotation.
Environment Variable Storage
Never hardcode keys in your application. Use environment variables:
# In your .env file (never commit this file)
GEMINI_API_KEY=AIzaSyB1234567890abcdefghijklmnopqrstuvwx
Load it in your code:
import os
api_key = os.getenv('GEMINI_API_KEY')
For production applications, use a secrets manager:
- AWS Secrets Manager
- Azure Key Vault
- Google Secret Manager
- HashiCorp Vault
Cost Management
AI Studio Pricing
Free tier includes:
- 60 requests per minute
- 1,500 requests per day
- No credit card required
Paid tier (if you exceed free limits):
- $0.00025 per 1,000 characters input
- $0.0005 per 1,000 characters output
Vertex AI Pricing
Gemini Pro:
- $0.00025 per 1,000 characters input
- $0.0005 per 1,000 characters output
Gemini Pro Vision (with images):
- $0.0025 per image
- Plus text pricing above
Set up billing alerts:
Step 1: GCP Console > Billing > Budgets & alerts
Step 2: Click "Create Budget"
Step 3: Set a monthly budget (start with $50 for testing)
Step 4: Set alert thresholds at 50%, 75%, and 90%
You'll receive email notifications before costs spiral.
Common Issues
"API
"Quota exceeded" error: You hit the 60 requests/minute limit on AI Studio. Wait 60 seconds or upgrade to Vertex AI.
"Permission denied" error on Vertex AI: Your service account lacks the "Vertex AI User" role. Go to IAM & Admin > IAM, find your service account, click Edit, add the role.
Billing not enabled: Vertex AI requires active billing. Go to Billing > Link a billing account.
Next Steps
You now have a working Gemini API
Document analysis: Extract key terms from contracts, engagement letters, or financial statements.
Email drafting: Generate client communication templates based on matter details.
Research summarization: Condense case law, regulations, or industry reports into executive summaries.
Refer to the Gemini API

Reviewed by Revenue Institute
This guide is actively maintained and reviewed by the implementation experts at Revenue Institute. As the creators of The AI Workforce Playbook, we test and deploy these exact frameworks for professional services firms scaling without new headcount.
Revenue Institute
Need help turning this guide into reality? Revenue Institute builds and implements the AI workforce for professional services firms.