← Blog

How to Create a Google AI Studio API Key

2026-09-06 · 5 min read · SubToAPI Team

Creating a Google AI Studio API key takes about two minutes: sign in to aistudio.google.com with a Google account, click "Get API key" in the left sidebar, create a new key in a Google Cloud project, and copy the string that starts with AIza.... That key is what you'll pass in the x-goog-api-key header (or as a query parameter) when calling the Gemini API from your own code.

The rest of this guide walks through the actual creation flow in detail, covers the project and billing setup that trips people up, and shows how to make your first test request so you know the key actually works before you build anything on top of it.

Step 1: Sign in and open AI Studio

Go to aistudio.google.com and sign in with a personal Google account. AI Studio doesn't require a separate signup — if you have Gmail, you already have access. Workspace accounts sometimes have API access restricted by an admin, so if you hit a permissions wall, that's usually why.

Step 2: Create or select a Google Cloud project

Every API key in AI Studio is tied to a Google Cloud project, even if you never open the Cloud Console yourself. When you click Get API key for the first time, AI Studio will offer to create a new project automatically. For personal experiments, letting it auto-create a project is fine. For anything you plan to put in production, create a dedicated project first:

  1. Click the project dropdown at the top of the API key screen.
  2. Select Create new project.
  3. Give it a name that reflects what you're building (not "test" or "untitled") — you'll thank yourself later when you have five projects and need to tell them apart.

Keeping production and experimental keys in separate projects makes it much easier to track usage and revoke access without breaking something else.

Step 3: Generate the API key

Once you're in the project you want, click Create API key. AI Studio generates a key immediately — no waiting period, no manual approval. The key looks like this:

AIzaSyD-EXAMPLE1234567890abcdefgh

Copy it right away and store it somewhere safe. AI Studio will show it to you again if you navigate back to the key list, but treating it as a one-time reveal is good practice.

Step 4: Restrict the key (recommended)

By default, a freshly created key can call any Generative Language API endpoint from anywhere. If this key is going into client-side code, a mobile app, or anywhere it could leak, restrict it:

This doesn't stop someone from abusing the key if they extract it from client-side JavaScript, but it does limit the blast radius.

Step 5: Test the key with a real request

Before wiring the key into an application, confirm it works with a plain curl call:

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GOOGLE_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{
      "parts": [{"text": "Say hello in one sentence."}]
    }]
  }'

A successful response returns a JSON object with a candidates array containing the generated text. If you get a 400 or 403 error, the two most common causes are an unrestricted key that was later locked down incorrectly, or a project where the Generative Language API isn't enabled yet — check APIs & Services > Enabled APIs in the Cloud Console.

Billing and rate limits

AI Studio gives every project a free tier with rate limits per model (requests per minute and tokens per minute, varying by model). You don't need to attach a billing account to get started. If you exceed free-tier limits or want higher throughput, you'll need to link the project to a Cloud Billing account, which switches you to pay-as-you-go pricing for Gemini API usage.

Watch for two things once billing is attached: usage caps you set yourself (Cloud Console lets you cap spend per project), and quota increases, which are separate from billing and sometimes require a request through the console if you're scaling past the default limits.

Managing keys as your project grows

A single API key is fine for a solo prototype. Once you have a team, multiple environments, or an app you're shipping to users, a few practices help:

If you need this behind a stable API for a team

A raw AI Studio key works well for personal projects, but it doesn't give you per-application keys, usage breakdowns by user, or seat-based access — you're managing one key per project by hand. If you're building on Claude specifically and want that structure without building it yourself, SubToAPI turns an existing Claude subscription into an HTTPS API with its own sub_live_... keys, streaming, tool use, and usage metadata, plus team seats so multiple developers can work under one plan. It's a different model provider than AI Studio, but the same problem — going from "I have access to a model" to "I have a manageable API for my team" — applies either way. You can see how it's structured in the quickstart and pricing pages, or start a trial at signup.

Questions

Do I need a credit card to create a Google AI Studio API key? No. You can generate a key and use the free tier without adding billing information. A billing account is only required if you exceed free-tier rate limits or need higher usage.

Can I have more than one API key in AI Studio? Yes. You can create multiple keys, including across different Google Cloud projects, which is useful for separating development, staging, and production environments.

What's the difference between an AI Studio key and a Vertex AI key? AI Studio keys are simpler and meant for quick development against the Gemini API. Vertex AI uses Google Cloud's IAM-based authentication instead of a single API key, and is aimed at production workloads with more granular access control and enterprise features.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →