How to Get a Gemini API Key (2026 Step-by-Step Guide)
Get your Google Gemini API key through Google AI Studio or Google Cloud. This guide covers both methods, free tier limits, and how to make your first request.
Two Ways to Get a Gemini API Key
There are two main ways to get a Gemini API key: through Google AI Studio (simpler, recommended for most developers) or through Google Cloud Vertex AI (better for enterprise workloads with existing GCP infrastructure).
Google AI Studio is the fastest path. It provides a free tier and is ideal for prototyping and small projects. Google Cloud Vertex AI is better for production workloads that need IAM, billing controls, and enterprise support.
Method 1: Google AI Studio (Recommended)
Google AI Studio is the quickest way to get a Gemini API key. Search interest for 'Google AI Studio' grew 50% in 2026, reflecting its growing popularity among developers.
Go to aistudio.google.com, sign in with your Google account, and click 'Get API key' in the left sidebar. If you don't have a project yet, Google AI Studio will create one for you automatically. Accept the terms of service, and your API key will be generated.
- Step 1: Go to aistudio.google.com
- Step 2: Sign in with your Google account
- Step 3: Click 'Get API key' in the left sidebar
- Step 4: Click 'Create API key' (a new Google Cloud project is created if needed)
- Step 5: Copy and store your API key securely
Method 2: Google Cloud Vertex AI
If you already use Google Cloud Platform, you can enable the Vertex AI API and generate credentials from the GCP Console. This method provides more control over IAM permissions, billing, and quotas.
Navigate to the Google Cloud Console, enable the 'Vertex AI API', then go to 'Credentials' and create an API key or service account key. This approach is recommended for enterprise setups.
Gemini API Free Tier
Google AI Studio offers a generous free tier for the Gemini API. The free tier has per-minute rate limits but no daily cap, making it suitable for development and testing.
When you're ready for production, you can enable billing in Google Cloud to access higher rate limits and additional features. The paid tier bills per million tokens, with separate rates for input and output.
Make Your First Request
The Gemini API has its own SDK, but you can also use the OpenAI-compatible endpoint. Here's a simple example using the Google Gen AI Python SDK:
from google import genai
client = genai.Client(api_key="YOUR_GEMINI_API_KEY")
response = client.models.generate_content(
model="gemini-2.0-flash",
contents="Hello, what can you do?"
)
print(response.text)Minimal Gemini API call using the Google Gen AI SDK
FAQ
Is the Gemini API key free?
Google AI Studio offers a free tier with generous rate limits. You can create and use an API key for free during development. For production with higher limits, paid billing is required.
What's the difference between Google AI Studio and Google Cloud Vertex AI?
Google AI Studio is simpler and faster, ideal for prototyping and small projects. Vertex AI provides enterprise features like IAM, billing controls, and higher quotas, suited for production workloads.
Can I use the Gemini API key with OpenAI SDK?
Yes. Google provides an OpenAI-compatible endpoint for the Gemini API. You can use the OpenAI SDK by setting the base URL to the Gemini OpenAI-compatible endpoint.
Related in This Series
Related Providers
Sources
- Google AI StudioGoogle · Checked 2026-07-29
- Gemini API DocumentationGoogle AI for Developers · Checked 2026-07-29
- Gemini API PricingGoogle AI for Developers · Checked 2026-07-29