---
title: "Gemini API Key: How to Get One, Free Tier & Cost | Straitly"
description: "Get a Gemini API key in Google AI Studio: the steps, auth keys, where GEMINI_API_KEY goes, free tier vs paid, the $5 prepay and what each model costs next."
url: https://straitly.ai/gemini-api-key
updated: 2026-12-05
publisher: Straitly (https://straitly.ai)
---

# Gemini API key

Get a Gemini API key in Google AI Studio. A new user gets a default Google Cloud project and key after accepting the Terms of Service, and the API keys page at [aistudio.google.com/api-keys](https://aistudio.google.com/api-keys) makes more [\[1\]](#src-1). Since 28 May 2026, every new key is an authorization key, tied to a service account and limited to the Gemini API; put it in GEMINI\_API\_KEY [\[1\]](#src-1). 7 of the 10 Gemini models in the table have a free tier; the rest need a billing account and a $5 prepay [\[2\]](#src-2) [\[3\]](#src-3). Straitly wrote this page and sells these models: one Straitly key calls the 10 Gemini models in the table, each at the Straitly price in its row [\[10\]](#src-10) [\[11\]](#src-11).

Updated 5 December 2026

[See the steps](#steps) [Free tier vs paid ](#free-tier)

40%

or more below Google's list price, input and output, on 9 of the 10 Gemini models on this page [\[3\]](#src-3) [\[10\]](#src-10).

## How do I get a Gemini API key in Google AI Studio?

Every Gemini API key belongs to a Google Cloud project, which holds billing, people and permissions; AI Studio is a light way into those projects. Five steps take a new account from sign-in to a stored key [\[1\]](#src-1) [\[5\]](#src-5).

1. ### Sign in to Google AI Studio
Use your Google account and accept the Terms of Service. A new user gets a default project and an API key right away [\[1\]](#src-1).
2. ### Import a project if you already use Google Cloud
AI Studio makes no default project for an existing Cloud account. Open Dashboard, then Projects, click Import projects and pick yours [\[1\]](#src-1).
3. ### Create the key
On the API keys page at [aistudio.google.com/api-keys](https://aistudio.google.com/api-keys), create a key in that project. If the button is greyed out, your role cannot make keys [\[1\]](#src-1).
4. ### Verify, or set up billing
Some free tier projects must be verified by scanning a QR code with your phone. Paid tier projects skip this [\[5\]](#src-5).
5. ### Store it as a secret
Keep it in GEMINI\_API\_KEY or a secrets manager, never in browser code or a public repository [\[1\]](#src-1).

## What is the difference between a standard key and an authorization key?

Google is moving the Gemini API from standard keys to authorization keys for security. A standard key that has explicit restrictions still works [\[1\]](#src-1).

| Detail            | Standard key                                                                             | Authorization key                                                                       |
| ----------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| Tied to           | A Google Cloud project, for billing and quota                                            | A Google Cloud service account; requests run as that account [\[1\]](#src-1)            |
| Access control    | Does not identify a caller, so permissions stay coarse                                   | Granular, through the bound service account [\[1\]](#src-1)                             |
| Scope             | Works only with explicit restrictions: the Gemini API rejects unrestricted standard keys | Restricted to the Gemini API by default [\[1\]](#src-1)                                 |
| If it leaks       | Google blocks keys reported as leaked; make a new one                                    | Fast leaked key enforcement stops a detected leaked key [\[1\]](#src-1) [\[6\]](#src-6) |
| Made in AI Studio | Before 28 May 2026                                                                       | Every new key since 28 May 2026 [\[1\]](#src-1)                                         |

## How do I use the Gemini API key in code?

Set GEMINI\_API\_KEY or GOOGLE\_API\_KEY and Google's SDKs find it; if both are set, GOOGLE\_API\_KEY wins. The Gemini API CLI reads only GEMINI\_API\_KEY [\[1\]](#src-1). A REST call sends it in the x-goog-api-key header [\[8\]](#src-8). The OpenAI SDK works too, with base URL https://generativelanguage.googleapis.com/v1beta/openai/ and the key as its API key [\[7\]](#src-7). To count a prompt's tokens first, use the [token counter](https://straitly.ai/token-counter).

Copy

```
# pip install -U google-genai
from google import genai

client = genai.Client()  # reads GEMINI_API_KEY
interaction = client.interactions.create(
    model="gemini-4-hydrogen",
    input="Hello",
)
print(interaction.output_text)
```

Copy

```
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Api-Revision: 2026-05-20" \
  -d '{"model": "gemini-4-hydrogen", "input": "Hello"}'
```

## Which Gemini models are free, and what do they cost on the paid tier?

USD per 1M tokens, input / output

| Model                                                                                              | Google free tier | Google paid price                                                               | Below list | Straitly price   |
| -------------------------------------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------- | ---------- | ---------------- |
| Gemini 4 Hydrogen gemini-4-hydrogen                                                                | Yes              | $1.50 / $7.50                                                                   | 45%        | $0.825 / $4.125  |
| Gemini 4 Carbon gemini-4-carbon                                                                    | No, paid only    | $4.00 / $20.00                                                                  | 60%        | $1.60 / $8.00    |
| Gemini 4 Argon gemini-4-argon                                                                      | No, paid only    | $4.00 / $20.00                                                                  | 70%        | $1.20 / $6.00    |
| [Gemini 3.8 Flash](https://straitly.ai/models/gemini-3.8-flash) gemini-3.8-flash                   | Yes              | $0.75 / $3.75 through December 31, 2026; $1.50 / $7.50 starting January 1, 2027 | 58%        | $0.315 / $1.575  |
| [Gemini 3.5 Flash Lite](https://straitly.ai/models/gemini-3.5-flash-lite) gemini-3.5-flash-lite    | Yes              | $0.30 / $2.50                                                                   | 40%        | $0.18 / $1.50    |
| [Gemini 3.6 Flash](https://straitly.ai/models/gemini-3.6-flash) gemini-3.6-flash                   | Yes              | $0.75 / $3.75 through December 31, 2026; $1.50 / $7.50 starting January 1, 2027 | 40%        | $0.45 / $2.25    |
| [Gemini 3.1 Flash Lite](https://straitly.ai/models/gemini-3.1-flash-lite) gemini-3.1-flash-lite    | Yes              | $0.25 / $1.50                                                                   | 40%        | $0.15 / $0.90    |
| [Gemini 3.1 Pro Preview](https://straitly.ai/models/gemini-3.1-pro-preview) gemini-3.1-pro-preview | No, paid only    | $2.00 / $12.00                                                                  | 40%        | $1.20 / $7.20    |
| [Gemini 3 Flash Preview](https://straitly.ai/models/gemini-3-flash-preview) gemini-3-flash-preview | Yes              | $0.50 / $3.00                                                                   | 40%        | $0.30 / $1.80    |
| [Gemini 2.5 Flash Lite](https://straitly.ai/models/gemini-2.5-flash-lite) gemini-2.5-flash-lite    | Yes              | $0.10 / $0.40                                                                   | 31%        | $0.0685 / $0.274 |

Newest first. Rows are the Gemini models in Straitly's catalog on 6 December 2026, with Straitly's price read there that day [\[10\]](#src-10). The free tier column and Google's paid prices are its Standard rates for prompts in the first price tier, checked on its pricing page on 5 December 2026 [\[3\]](#src-3). Free tier use has lower rate limits, and Google uses that content to improve its products [\[2\]](#src-2) [\[3\]](#src-3). Below list is the smaller of the input and output gaps, rounded down. Google has deprecated Gemini 4 Argon; calls route to Gemini 4 Carbon from 15 December 2026 [\[9\]](#src-9). Gemini 4 Carbon has no Straitly model page yet. Cached input, Batch and Priority rates are on [Gemini API pricing](https://straitly.ai/gemini-api-pricing). Google's pricing page also lists models outside this table, such as its Live, image, speech and embedding models, with their own prices [\[3\]](#src-3).

[See all models ](https://straitly.ai/models)

## What does a Gemini API key cost after the free tier?

To get higher limits and the paid only models, link a billing account and prepay at least $5; one purchase can be up to $5,000\. Prepay credits expire after 12 months and are non-refundable. When the balance hits $0, every API key on that billing account stops, with HTTP 402 [\[2\]](#src-2). Then each tier sets a monthly cap and a spend limit per 10 minutes. Limits apply per project, not per key, and daily request limits reset at midnight Pacific. Your project's own RPM, TPM and RPD limits per model are at [aistudio.google.com/rate-limit](https://aistudio.google.com/rate-limit) [\[2\]](#src-2) [\[4\]](#src-4).

| Tier   | How you qualify                                                  | Monthly cap          | Spend per 10 min |
| ------ | ---------------------------------------------------------------- | -------------------- | ---------------- |
| Free   | An active project or free trial; some projects need verification | None                 | None             |
| Tier 1 | Link an active billing account                                   | $250                 | $10              |
| Tier 2 | $100 paid, and 3 days since the first payment                    | $2,000               | $200             |
| Tier 3 | $1,000 paid, and 30 days since the first payment                 | $20,000 to $100,000+ | $200             |

## What does a month of Gemini cost on a paid key?

A worked bill: 10M input and 2M output tokens a month on Gemini 4 Hydrogen, prompts under 200K tokens, no cache, before tax, above the free tier. Each cell is tokens in millions times the price per 1M tokens [\[3\]](#src-3) [\[10\]](#src-10).

| Price                            | Input, 10M tokens   | Output, 2M tokens  | A month |
| -------------------------------- | ------------------- | ------------------ | ------- |
| Google paid price Prepay credits | 10 x $1.50 = $15.00 | 2 x $7.50 = $15.00 | $30.00  |
| Straitly price Prepaid credits   | 10 x $0.825 = $8.25 | 2 x $4.125 = $8.25 | $16.50  |

## What do Gemini API key errors mean?

Most key problems come back as one of these. Do not retry a 400, 402 or 403; retry a 429 with exponential backoff [\[6\]](#src-6). Creating a new key in the same unverified project does not skip verification [\[5\]](#src-5).

| Error                                  | What it means                                           | What to do                                                                                                    |
| -------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| 403 FREE\_TIER\_VERIFICATION\_REQUIRED | A free tier project that has not been verified          | Verify the project by scanning a QR code with your phone, or set up billing for the paid tier [\[5\]](#src-5) |
| 403 PERMISSION\_DENIED                 | The key was reported as leaked or is blocked            | Create a new key, update your app, then disable the old key [\[1\]](#src-1) [\[6\]](#src-6)                   |
| 402 Payment Required                   | The Prepay credit balance on the billing account hit $0 | Add credits; do not retry the same request [\[2\]](#src-2) [\[6\]](#src-6)                                    |
| 429 RESOURCE\_EXHAUSTED                | The project passed a rate limit or its spend limit      | Retry with exponential backoff, or move up a usage tier [\[4\]](#src-4) [\[6\]](#src-6)                       |

Straitly keys return their own codes, listed on [errors and limits](https://straitly.ai/docs/errors).

## How does a Google Gemini key compare with a Straitly key?

Both call Gemini, and both work with the OpenAI SDK after a base URL and key change [\[7\]](#src-7) [\[14\]](#src-14). The Straitly key also calls other labs. Setup is on the [quickstart](https://straitly.ai/docs/quickstart).

| Detail              | Google Gemini key                                                                                                     | Straitly key                                                                                                                           |
| ------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| Where you make it   | The API keys page in Google AI Studio [\[1\]](#src-1)                                                                 | The API keys page after you [sign up](https://straitly.ai/signup) [\[12\]](#src-12)                                                    |
| How it is sent      | The x-goog-api-key header, or Authorization: Bearer on the OpenAI-compatible endpoint [\[7\]](#src-7) [\[8\]](#src-8) | Authorization: Bearer [\[12\]](#src-12)                                                                                                |
| OpenAI SDK base URL | https://generativelanguage.googleapis.com/v1beta/openai/ [\[7\]](#src-7)                                              | https://api.straitly.ai/v1 [\[14\]](#src-14)                                                                                           |
| Models it calls     | Google's own models                                                                                                   | Gemini and other labs, all 118 on [/models](https://straitly.ai/models) [\[11\]](#src-11)                                              |
| How you pay         | Free tier on some models, then Prepay credits from $5 [\[2\]](#src-2)                                                 | Prepaid credits per token, no subscription and no minimum commitment [\[13\]](#src-13)                                                 |
| When credits expire | After 12 months [\[2\]](#src-2)                                                                                       | Not while your account is open [\[13\]](#src-13)                                                                                       |
| Spend control       | A monthly cap and a 10-minute spend limit per usage tier, per project [\[2\]](#src-2) [\[4\]](#src-4)                 | An optional daily spend cap on each key, and [child keys](https://straitly.ai/docs/child-keys) with their own budget [\[12\]](#src-12) |
| Your prompts        | Free tier content is used to improve Google products; paid tier content is not [\[2\]](#src-2) [\[3\]](#src-3)        | Zero data retention by default on every key [\[15\]](#src-15)                                                                          |

Copy

```
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.straitly.ai/v1",
    api_key=os.environ["STRAITLY_API_KEY"],
)
reply = client.chat.completions.create(
    model="gemini-4-hydrogen",
    messages=[{"role": "user", "content": "Hello"}],
)
print(reply.choices[0].message.content)
```

## Questions people ask about Gemini API keys

[Ask a question](https://straitly.ai/contact)

- ### Are Gemini API rate limits per key or per project?
Per project. Google applies rate limits to the project, not the key, so a second key in the same project adds no capacity. Your project's live RPM, TPM and RPD limits per model are at aistudio.google.com/rate-limit. [\[4\]](#src-4)
- ### Can I put a Gemini API key in browser or mobile code?
No. Google says never to hardcode a key in web or mobile apps, since users can pull it out of the app; run a backend proxy server that makes the calls, and keep keys out of source control. [\[1\]](#src-1)
- ### What should I do if my Gemini API key leaks?
Make a new key in AI Studio or the Cloud console, deploy your app with it, then disable the old key once the new one works; deleting it first can take your app down. Then check billing and usage for calls you did not make. [\[1\]](#src-1)
- ### Why can't I create a project or key in Google AI Studio?
Your Google account may lack permission, or your organization blocks Google Cloud project creation; AI Studio also stops at 10 created or 50 imported projects. Ask an admin for a role such as Project Editor, or create the project in the Google Cloud console and import it. [\[1\]](#src-1)
- ### Does Straitly keep my Gemini prompts?
No. Zero data retention (ZDR) is the default on every Straitly account, on every key. Prompts and completions are never written to disk or logs, and never used to train models. Straitly keeps only the metadata needed for billing and the Activity page: timestamp, model, provider, and the key that made the request; token counts per bucket; latency, status code, and the amount charged. None of these fields contain prompt or completion text. [\[15\]](#src-15) See [data retention](https://straitly.ai/docs/data-retention).

## Sources

How this page is checked: Straitly, which sells API access to these Gemini models, wrote it. Straitly prices are from its own catalog on 6 December 2026; Google steps, terms and prices are from Google's AI Studio docs, read on 5 December 2026\. Last updated 5 December 2026\. If something here is out of date, tell us at [straitly.ai/contact](https://straitly.ai/contact).

1. \[1\] [Using Gemini API keys](https://aistudio.google.com/docs/api-key) Google AI Studio docs, checked 5 December 2026
2. \[2\] [Billing](https://aistudio.google.com/docs/billing) Google AI Studio docs, checked 5 December 2026
3. \[3\] [Gemini Developer API pricing](https://aistudio.google.com/docs/pricing) Google AI Studio docs, checked 5 December 2026
4. \[4\] [Rate limits](https://aistudio.google.com/docs/rate-limits) Google AI Studio docs, checked 5 December 2026
5. \[5\] [Project and account verification](https://aistudio.google.com/docs/verification) Google AI Studio docs, checked 5 December 2026
6. \[6\] [Troubleshooting guide](https://aistudio.google.com/docs/troubleshooting) Google AI Studio docs, checked 5 December 2026
7. \[7\] [OpenAI compatibility](https://aistudio.google.com/docs/openai) Google AI Studio docs, checked 5 December 2026
8. \[8\] [Gemini API quickstart](https://aistudio.google.com/docs/quickstart) Google AI Studio docs, checked 5 December 2026
9. \[9\] [Gemini deprecations](https://aistudio.google.com/docs/deprecations) Google AI Studio docs, checked 5 December 2026
10. \[10\] [Straitly model catalog](https://straitly.ai/api/catalog) Straitly, read 6 December 2026
11. \[11\] [Straitly models](https://straitly.ai/models) Straitly, read 6 December 2026
12. \[12\] [Authentication](https://straitly.ai/docs/authentication) Straitly docs, checked 5 December 2026
13. \[13\] [Billing](https://straitly.ai/docs/billing) Straitly docs, checked 5 December 2026
14. \[14\] [Endpoints](https://straitly.ai/docs/endpoints) Straitly docs, checked 5 December 2026
15. \[15\] [Data retention](https://straitly.ai/docs/data-retention) Straitly docs, checked 5 December 2026

**Method details**

Each step, key type, tier, cap and error on this page was checked against Google's AI Studio docs on 5 December 2026, and each Google paid price and free tier entry for the 10 models against its pricing page. The table holds the Gemini text models Straitly sells; models Google has retired are left off. The worked month leaves out cache and the free tier.

Read next: [Gemini API pricing](https://straitly.ai/gemini-api-pricing) , [Claude API key](https://straitly.ai/claude-api-key) , [Token counter](https://straitly.ai/token-counter) , [API keys & auth docs](https://straitly.ai/docs/authentication) , [Child keys & budgets docs](https://straitly.ai/docs/child-keys) , [Errors & limits docs](https://straitly.ai/docs/errors).

## Call Gemini 4 Hydrogen on Straitly.

One OpenAI-compatible key for the Gemini models above and the rest of the 118.

[Console](https://straitly.ai/app) [Talk to sales ](https://straitly.ai/contact)

---
Markdown version of https://straitly.ai/gemini-api-key.

Ask a question about this page: https://straitly.ai/ask?q=your+question
