Skip to main content
API Key Setup7 min readPublished: 2026-07-29Updated: 2026-07-29

Google AI Studio API Key: Complete Setup Guide (2026)

Learn how to get and use a Google AI Studio API key to access Gemini models. Covers the free tier, differences from Vertex AI, and code examples in Python and Node.js.

What Is Google AI Studio?

Google AI Studio is a browser-based IDE for building generative AI applications with Google's Gemini models. It provides a fast, zero-setup way to prototype prompts, test model behavior, and generate an API key for programmatic access.

Unlike a full cloud platform, Google AI Studio is designed to get developers from idea to first API call in minutes. You can experiment with different Gemini models, adjust parameters like temperature and token limits, and export working code directly from the UI.

Google AI Studio is the recommended starting point for most developers who want to use the Gemini API, especially those who do not already have a Google Cloud project or need enterprise-grade infrastructure.

Google AI Studio vs. Google Cloud Vertex AI

Google AI Studio and Google Cloud Vertex AI both provide access to Gemini models, but they target different use cases. Google AI Studio is designed for prototyping and development, with a simple key-based authentication and a generous free tier. Vertex AI is an enterprise platform with IAM-based access control, VPC integration, and advanced billing management.

If you are an individual developer or a small team building prototypes, Google AI Studio is the right choice. If you are deploying to production with strict security requirements, existing GCP infrastructure, or need higher rate limits, Vertex AI is more appropriate.

Both platforms access the same underlying Gemini models — the difference is in the access method, billing, and management layer.

Accessing aistudio.google.com

To access Google AI Studio, go to aistudio.google.com in your browser. You need a Google account to sign in — the same account you use for Gmail, Google Drive, or YouTube will work.

Google AI Studio is available in most regions. If you are in a region where it is not directly accessible, you may need to use a VPN. Once signed in, you will see the dashboard with options to create prompts, chat with models, and manage API keys.

The interface is available in English. The platform is free to use for development within the free tier rate limits.

How to Get a Google AI Studio API Key

Getting an API key from Google AI Studio takes less than a minute. Once you are signed in, the process is entirely browser-based — no CLI or cloud project setup required.

  • Step 1: Go to aistudio.google.com and sign in with your Google account
  • Step 2: Click 'Get API key' in the left sidebar menu
  • Step 3: Click 'Create API key' button
  • Step 4: A new Google Cloud project is automatically created if you don't have one
  • Step 5: Copy the generated API key and store it securely (e.g., in an environment variable)

Gemini API Free Tier (Google AI Studio)

Google AI Studio provides a free tier for the Gemini API that is generous enough for development, testing, and small projects. The free tier includes access to all available Gemini models, including Gemini 2.5 Pro and Gemini 2.5 Flash.

The free tier has per-minute rate limits (typically 15 requests per minute for most models) but does not impose a daily cap. This makes it well-suited for iterative development where you need to test prompts and adjust parameters repeatedly.

When you need higher rate limits or are ready for production, you can upgrade to the paid tier by enabling billing in Google Cloud. Paid pricing is per million tokens, with separate rates for input and output tokens. Prompt caching is also available at a discount on supported models.

Using Your API Key in Code

Once you have your API key, you can start making requests to the Gemini API. Google provides official SDKs for Python and JavaScript/TypeScript. You can also use the REST API directly or the OpenAI-compatible endpoint.

Here is a minimal example using the official Google Gen AI Python SDK:

python
from google import genai

client = genai.Client(api_key="YOUR_GOOGLE_AI_STUDIO_API_KEY")

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Explain what an API key is in one sentence."
)

print(response.text)

Calling the Gemini API with the Google Gen AI Python SDK

javascript
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

const response = await ai.models.generateContent({
  model: "gemini-2.5-flash",
  contents: "Explain what an API key is in one sentence.",
});

console.log(response.text);

Calling the Gemini API with the Google Gen AI JavaScript SDK

API Key Security Best Practices

Treat your Google AI Studio API key like a password. Never commit it to version control or hardcode it in client-side code. Store it in environment variables or a secrets manager, and use different keys for development and production.

If a key is compromised, you can delete or regenerate it from the Google AI Studio dashboard. Monitor your API usage regularly to detect unexpected spikes that might indicate key leakage.

FAQ

Is Google AI Studio free to use?

Yes, Google AI Studio offers a free tier with per-minute rate limits but no daily cap. The free tier is sufficient for development, testing, and small projects. For production with higher limits, paid billing is required.

Do I need a Google Cloud account to use Google AI Studio?

No. You only need a regular Google account. Google AI Studio automatically creates a Google Cloud project for you when you generate an API key, but you do not need to set up or manage a GCP project manually.

Can I use a Google AI Studio API key with the OpenAI SDK?

Yes. Google provides an OpenAI-compatible endpoint for the Gemini API. Set the base URL to the Gemini OpenAI-compatible endpoint and use your Google AI Studio API key as the API key in the OpenAI SDK.

What models can I access with a Google AI Studio API key?

A Google AI Studio API key gives you access to all available Gemini models, including Gemini 2.5 Pro, Gemini 2.5 Flash, and Gemini 2.5 Flash-Lite. The same key works across all models, and you specify the model name in your API request.

What is the rate limit for the free tier?

The free tier typically allows 15 requests per minute for most models, with no daily cap. Rate limits may vary by model. Check the official documentation for the most current limits.

Related Providers

Sources