You get a Gemini API key from Google AI Studio: new users get a default Google Cloud project and key created automatically once they accept the Terms of Service, and anyone else creates one on the API Keys page. As of October 2026, every new key made in AI Studio is an authorization key bound to a service account, and Google says the API rejects requests from unrestricted standard keys.
An API key is what lets an app, a script or a no-code tool talk to Gemini and bill the right account. It isn't your Google password, but Google's own docs say to treat it like one.
What a Gemini API key is tied to
Every Gemini API key belongs to a Google Cloud project. The project handles billing, collaborators and permissions, and Google AI Studio is a lightweight window onto those projects. If you are still deciding which provider to build on, this LLM API comparison sets ten of them side by side.
Here's the part people don't expect: Google applies rate limits per project, not per API key. Making five keys in one project doesn't give you five times the capacity. It just gives you five secrets to look after. AI Studio also caps what it shows: you can create a maximum of 10 projects at a time from its Projects page, and the API Keys and Projects pages display a maximum of 100 keys and 50 projects.
Get your key in Google AI Studio
For a first-time user, as of October 2026:
- Go to Google AI Studio.
- Accept the Terms of Service. If you're new, AI Studio creates a default Google Cloud project and an API key for you at this point.
- Open the Dashboard from the left panel and go to the API Keys page.
- If you need another key, click Create API key and follow the dialog to add a key-project pair.
- Copy the key and put it straight into an environment variable (see below), not into a note, an email or a chat.
- Optional: rename the default project from the Projects view in your dashboard, so you'll recognise it later.
New accounts start on the free tier, which Google's pricing page lists with Google AI Studio access and free input and output tokens on certain models. What that free tier covers is in my guide to whether the Gemini API is free, and if you're comparing vendors, this roundup of free AI API keys sets Gemini beside the others.
Already on Google Cloud? Import your project first
If you already have a Google Cloud account, AI Studio doesn't create a default project for you, and it doesn't display all your existing projects either. You import the ones you want:
- Go to Google AI Studio.
- Open the Dashboard from the left panel and select Projects.
- Click Import projects.
- Search for and select the Google Cloud project, then click Import.
- Go to the API Keys page in the dashboard and create a key in that project.
If you log in and can't see keys you know exist, this is the usual reason. Google's note is that you may need to import your Cloud projects into AI Studio before they show up.
Auth keys versus standard keys
Google is moving the Gemini API from standard keys to authorization keys to improve security. The difference matters if you've got older keys in a live tool:
| Key type | How it works | Status as of October 2026 |
|---|---|---|
| Standard key | Ties requests to a Cloud project for billing and quota, but doesn't identify the caller | Rejected if unrestricted. Keys with explicit restrictions keep working. |
| Authorization (auth) key | Bound to a Google Cloud service account, so requests run under that identity. Restricted to the Gemini API by default, with fast-acting leaked-key enforcement. | Every new key created in AI Studio since May 28, 2026 |
There's a second date to know. Starting May 7, 2026, the Gemini API blocks unrestricted keys that have been dormant for an extended period. They show a Blocked tag in AI Studio, and you'll need a new key or an existing restricted one.
To fix an old unrestricted key in AI Studio, find the Unrestricted label on the API Keys page, hover over it, click Add restrictions, select Restrict to Gemini API only, then Restrict key. That needs the apikeys.keys.update permission, which comes with roles like API Keys Admin or Editor. The cleaner route is Google's migration path: create a new key (it'll be an auth key), update your app, test it, then delete or revoke the old one.
When Create API key is greyed out
If the Create API key button is unavailable and the message says you don't have permission to create a key in this project, you're missing IAM permissions. Ask your Google Cloud project or organisation administrator for a role that includes these, such as Project Editor:
- resourcemanager.projects.get, so AI Studio can verify the project
- apikeys.keys.create, to generate the key
- serviceusage.services.enable, to make sure the Gemini API is switched on
- iam.serviceAccounts.create, to create the linked service account
- iam.serviceAccountApiKeyBindings.create, to bind that service account to the key
The last two exist because new keys are bound to a service account. If you can't get admin access, Google's fallback is to create a new Google Cloud project that isn't associated with an organisation. In a business, I'd rather you ask IT than quietly run a second project nobody else knows about.
Here's another page that fits alongside this one: how to use Google Keep.
Want AI doing the heavy lifting in your marketing?
I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.
Keep the key out of your code
Google's recommended option is an environment variable. Set GEMINI_API_KEY or GOOGLE_API_KEY, and Google's client libraries pick it up automatically. One catch: if both are set, GOOGLE_API_KEY takes precedence, so an old key left in that variable will quietly win.
Add this line to your .zshrc or .bashrc file on a Mac or Linux
export GEMINI_API_KEY=your-key-goes-here
On Windows, search for Environment Variables, click Environment Variables in the System Properties dialog, click New under User variables, name it GEMINI_API_KEY with your key as the value, click OK and open a new terminal. If you're mainly using Gemini from the terminal, my Gemini CLI walkthrough covers that set-up.
Google's security rules are short and worth following: never check keys into Git, never hardcode a key in a web or mobile app (keys in client-side code can be extracted), use a secret store such as Google Cloud Secret Manager in production, and set billing alerts. If a key leaks, generate a new one, update your app, then disable the leaked key once the new one works, and check your usage. Requests AI Studio can't match to a named key, including keys deleted more than 30 days ago, show up on the Usage page as unknown keys.
I'd also point you to Google Keep alternatives.
How I'd set it up
I'd create a separate key for each tool or app, store it in an environment variable, and skip pasting keys into code, chats, shared docs or a public repo. If you're handing a key to a freelancer or a no-code tool, make sure it's an auth key and you know which project it bills. Google's key rules have changed twice this year, so check its API key page for the latest before you build anything that depends on an old key.
If you're connecting an AI model to your business tools and want it done safely, that's the kind of AI enablement I help with. I run AI training and workshops for teams, and help businesses with AI enablement and workflow automation, so the busywork runs itself and people get time back. Most of that work is with SaaS marketing teams and small businesses. Here's how we can work together.
Frequently asked questions
Is a Gemini API key free?
Creating a key doesn't need billing. New accounts start on the free tier, which Google's pricing page lists with Google AI Studio access and free input and output tokens on certain models. Higher rate limits need a billing account.
Where do I find my Gemini API key?
On the API Keys page in Google AI Studio's dashboard. If you can't see it, you may need to import your Google Cloud project into AI Studio first.
Why can't I create a Gemini API key?
Usually you're missing IAM permissions in that Cloud project. Ask an admin for a role such as Project Editor, or create a new project that isn't associated with an organisation.
Do old Gemini API keys still work?
Standard keys with explicit restrictions keep working. Google says the API rejects requests from unrestricted standard keys, and since May 7, 2026 it blocks unrestricted keys that have been dormant for an extended period.