# Gemini how to get API key: steps in Google AI Studio

> Create a key on the API Keys page, store it in GEMINI_API_KEY and lock it to the Gemini API. Google's own steps, with the 2026 key changes.

URL: https://claudegpt.si/news/gemini-how-to-get-api-key  
Published: 2026-10-28T02:52:57.667Z  
Author: ClaudeGPT Si Newsroom  
Section: Guides  
Topics: Gemini, Google, How to, API keys, Developer tools  
Publisher: ClaudeGPT Si

## Key takeaways

- Open the API Keys page in Google AI Studio, accept the terms and create a key; new users get a default project and key automatically.
- Google says new AI Studio keys created from May 28, 2026 are auth keys bound to a service account and restricted to the Gemini API.
- Store the key in the GEMINI_API_KEY environment variable and never commit it or hardcode it in a web or mobile app.

To get a Gemini API key, open the API Keys page in Google AI Studio, accept the Terms of Service and create a key. New users get a default project and key automatically. This is how to get a Gemini API key, according to [Google's API key documentation](https://ai.google.dev/gemini-api/docs/api-key), as read on October 28, 2026.

The key is free to create. What you can send with it depends on the plan and quota of the Google Cloud project it belongs to.

## What you need first

A Google account and access to [Google AI Studio](https://aistudio.google.com). If you already use Google Cloud, you may need to import your project before you can create a key for it.

## How to get a Gemini API key in AI Studio

1. Open the API Keys page in Google AI Studio.
2. Accept the Terms of Service if you are asked. For new users, Google then creates a default project and a key for you. You can rename the project later in the Projects view.
3. If you have no key yet, or want another, create one on the API Keys page.
4. Copy the key and store it somewhere safe, such as a password manager or a secret store. Do not paste it into chat, tickets or public code.

### If you already have a Google Cloud project

AI Studio does not list your Cloud projects until you import them. Google's steps:

1. Go to the Dashboard in AI Studio and open Projects.
2. Click Import projects, select the project and click Import.
3. Go back to the API Keys page and create the key.

### If the Create API key button is greyed out

You probably lack permissions in that project. Ask an administrator for a role such as Project Editor. Google lists the permissions the action needs: `resourcemanager.projects.get`, `apikeys.keys.create`, `serviceusage.services.enable`, `iam.serviceAccounts.create` and `iam.serviceAccountApiKeyBindings.create`. If that is not possible, create a project that is not tied to an organization.

## Standard keys and auth keys

Google now describes two kinds of key. A standard key links requests to a Google Cloud project for billing and quotas, but does not identify the caller. An auth key is bound to a Google Cloud service account, is restricted to the Gemini API by default and gets faster enforcement against leaks.

Google says that starting May 28, 2026, new keys created in AI Studio are auth keys. The API rejects unrestricted standard keys, though standard keys with explicit restrictions still work. Google also says that since May 7, 2026, unrestricted keys that have been dormant too long are blocked and marked "Blocked" in AI Studio. In that case, create a new key or use an existing restricted one.

## How to set GEMINI_API_KEY

Google recommends putting the key in an environment variable. The client libraries look for `GEMINI_API_KEY` or `GOOGLE_API_KEY` on their own. If both are set, `GOOGLE_API_KEY` wins.

On Linux or macOS with Bash, add a line like this to the end of `~/.bashrc`, then run `source ~/.bashrc`:

```bash
export GEMINI_API_KEY="YOUR_API_KEY"
```

On macOS with Zsh, do the same in `~/.zshrc`. On Windows, search for "Environment Variables", open it from System Properties, click New under user or system variables, name it `GEMINI_API_KEY`, paste the key as the value and open a new terminal.

Google says to pass the key directly in code only when you cannot use environment variables. Its REST examples send the key in an `x-goog-api-key` header.

## How to keep the key safe

Google says to treat the key like a password. Someone who gets it can use your quota, run up charges and reach private resources.

- Never commit a key to source control such as Git.
- Never hardcode it in a web or mobile app, because users can extract it. Call the API through a backend instead.
- Read keys from environment variables, use Google Cloud Secret Manager in production and set billing alerts.
- To limit damage, add restrictions. In AI Studio, find a key labeled Unrestricted, click Add restrictions, choose Restrict to Gemini API only and click Restrict key. You need the `apikeys.keys.update` permission. Application restrictions, such as allowed IP addresses, are set on the Google Cloud console credentials page.

### What to do if a key leaks

Google's order matters: create a new key, deploy your app with it, then disable the old key once the new one works. Do not delete the old one first, or the app goes down. Then check billing and usage logs for activity you did not cause.

## How to replace an older standard key

1. Open the API Keys page and check the Key Type column for keys marked Standard.
2. Create a new key. It will be an auth key.
3. Copy it and update your code, environment variables and deployment settings.
4. Test the application.
5. Delete or revoke the old key.

## Limits to know

You can create up to 10 projects at a time from the Projects page. The API Keys page shows at most 100 keys and the Projects page at most 50 projects. AI Studio only shows unrestricted keys and keys restricted to the Gemini API, so manage any others in the Google Cloud console. Requests that cannot be matched to a named key appear under "(unknown keys)" on the Usage page.

Once the key is set, see the guide to [using Gemini 4 Argon in the app, AI Mode, Antigravity and the API](https://claudegpt.si/news/gemini-4-argon-how-to-use).

## Frequently asked questions

### Where do I get a Gemini API key?

On the API Keys page in Google AI Studio. New users get a default project and key after accepting the Terms of Service.

### What is the GEMINI_API_KEY environment variable?

It is the variable the Gemini client libraries read automatically. If GOOGLE_API_KEY is also set, Google says GOOGLE_API_KEY takes precedence.

### What do I do if my Gemini API key leaks?

Create a new key, deploy your app with it, then disable the old key once the new one works. Check billing and usage logs for unauthorized activity.

### Why can't I click Create API key in AI Studio?

You likely lack permissions in the project. Ask an administrator for a role such as Project Editor, or create a project not tied to an organization.

## Sources

- [Using Gemini API keys](https://ai.google.dev/gemini-api/docs/api-key), Google AI for Developers
- [Google AI Studio](https://aistudio.google.com), Google
