Skip to content
English

Switch theme

// Models · API key guide

Gemini API keys: generate one in Google AI Studio

Keys are created in Google AI Studio and belong to a Google Cloud project. New accounts start on the Free Tier – no billing account needed.

4 stepsofficial docs onlychecked 2026-10-26

01How to get a Google Gemini API key

  1. Sign in to Google AI Studio with a Google account and accept the terms – new users get a default Google Cloud project and API key automatically.
  2. Existing Google Cloud users: Dashboard → Projects → “Import projects”, then create a key in that project.
  3. Open the API keys page (aistudio.google.com/apikey) → “Create API key”. Since 2026-05-28 new keys are authorization keys bound to a service account.
  4. Save it as GEMINI_API_KEY and send it in the x-goog-api-key header.

Official key page: https://aistudio.google.com/apikey – console labels may change; follow what the official page shows.

02Real-name, phone and credit card requirements

Real-name / ID verificationNo ID verification for the Free Tier – a Google account is enough.
Phone numberOnly whatever your Google account requires.
Credit card / paymentFree Tier: no. Paid Tier: link a billing account and prepay at least $5 (or equivalent).

03Base URL and a minimal call

Base URL:https://generativelanguage.googleapis.com/v1beta
OpenAI-compatible endpoint: https://generativelanguage.googleapis.com/v1beta/openai/ (use with the OpenAI SDK).
OpenAI-compatible:https://generativelanguage.googleapis.com/v1beta/openai/
Environment variable:GEMINI_API_KEY · Example model:gemini-3.8-flash
gemini-3.8-flash is the model in the official quickstart.

curl

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3.8-flash",
    "input": "Explain how AI works in a few words"
  }'

Python

# pip install openai
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["GEMINI_API_KEY"], base_url="https://generativelanguage.googleapis.com/v1beta/openai/")
resp = client.chat.completions.create(
    model="gemini-3.8-flash",
    messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)

New accounts begin on the Free Tier, with access to certain models up to their free-tier rate limits; exact limits are shown per project in AI Studio. Availability depends on your region.

Our free-API tracker:Free tier: input and output tokens are free of charge. Gemini 4 Argon, Gemini 4 Carbon, Gemini 4 Neon, 3.1 Pro Preview, Nano Banana image generation, Veo etc. are not on the free tier.
checked 2026-11-23 · details →

05Google Gemini API prices

All model prices →
ModelInput / 1M tokensOutput / 1M tokensSource
Gemini 2.5 Flash-Litegemini-2.5-flash-lite $0.1$0.4 official · 2026-10-10
Gemini 3.1 Flash-Litegemini-3.1-flash-lite $0.25$1.5 official · 2026-10-10
Gemini 3.5 Flash-Litegemini-3.5-flash-lite $0.3$2.5 official · 2026-10-10
Gemini 2.5 Flashgemini-2.5-flash $0.3$2.5 official · 2026-11-21
Gemini 3 Flash Previewgemini-3-flash-preview $0.5$3 official · 2026-10-10
Gemini 3.8 Flashgemini-3.8-flash $0.75$3.75 official · 2026-10-10
Gemini 3.6 Flashgemini-3.6-flash $0.75$3.75 official · 2026-10-10
Gemini Robotics-ER 2gemini-robotics-er-2 $1$5 official · 2026-11-21

Standard (non-batch) list prices from our price database; cheapest first, max 8 rows. Prices change – the official page wins.

06Keep your API key safe

07FAQ

FAQ

How do I generate a Gemini API key?

Google AI Studio → API keys (aistudio.google.com/apikey) → Create API key. New users already get one in a default project.

Are Gemini API keys free?

Creating keys is free and new accounts are on the Free Tier for certain models with rate limits. Higher limits need the Paid Tier (billing account + $5 prepay).

Can I have multiple Gemini API keys?

Yes – keys live in Google Cloud projects; create separate keys or projects per app so you can revoke one without affecting others.

08Official sources

All facts checked against these pages on 2026-10-26. If anything differs, the official page wins.

09Related

Other API key guides

Data updated: Model API prices · HF model metadata(UTC+8)