You can get your Gemini API key from the API Keys page in Google AI Studio. Sign in, select or create an authorized project, and copy its credential into a secure location. Before using it, check the project’s billing tier and permissions. This guide reflects Google’s authorization-key changes and explains how to troubleshoot missing or rejected keys. For the distinction between Google’s developer workspace and a general-purpose assistant, see our Google AI Studio vs ChatGPT comparison. For current Gemini video model access and pricing, read our AI video generation API guide.
How to get your Gemini API key
Open Google AI Studio at aistudio.google.com and sign in with an eligible Google account. Accept the relevant service terms if prompted. In the dashboard, navigate to API Keys. New users may already have a default project and a key; check the listed keys before creating another one.
If you need a separate credential, choose Create API key and follow the dialog to associate it with a Google Cloud project. Give it a recognizable name if the interface offers that option. Copy the key to a secure secret store. Avoid copying it into a document, support message, or source code repository.
The project determines which usage limits, permissions and billing arrangement apply. If you have an existing Google Cloud project that is not visible, open the Projects view and import the authorized project before creating the key. Google notes that imported projects may need verification before accessing the free tier.
Standard keys vs. Gemini authorization keys
Google’s API key documentation, reviewed December 4, 2026, describes a migration to authorization keys. Since May 28, 2026, new keys created in AI Studio have been authorization keys by default. They are associated with a service account identity and limited to the Gemini API by default. Unlike older standard keys, authorization keys support more granular identity-based access control.
The Gemini API now rejects unrestricted standard keys. Existing restricted standard keys may continue to work under the documented conditions. If an old key fails, check its restrictions and follow the current migration guidance rather than removing security controls. Authorization keys are still sensitive credentials. Keep them secret and grant the associated identity only the permissions needed.
Is a Gemini API key free?
For other providers and their quotas, compare our free API keys for AI guide.
Creating a key and paying for model usage are separate operations. Eligible free-tier projects can access certain models within their applicable limits. The available models, quotas and features depend on the project, region, verification status and current service terms.
Do not assume that a key gives you unlimited free generations. Check the Billing Tier and Usage views in AI Studio and the current model pricing before making requests. Paid access requires a billing arrangement; Google documents prepaid and postpaid plans, including a minimum initial payment for applicable prepaid accounts. Do not activate billing simply to create a credential if your purpose is to use an eligible free-tier project.
A Gemini consumer subscription is not, by itself, proof that API usage is included. Also review the applicable data-use terms before sending sensitive content; free and paid service arrangements can differ.
Store your Gemini API key securely
For server-side applications, Google’s client libraries recognize GEMINI_API_KEY or GOOGLE_API_KEY. If both variables are set, GOOGLE_API_KEY takes precedence in those libraries. Use a single intended credential to avoid accidentally sending requests under the wrong project.
For an interactive Python test, you can enter the key through a hidden input prompt instead of placing the literal value in a script or shell history. For deployment, inject it from your hosting platform’s secret manager. Do not publish it in browser JavaScript or mobile application bundles. Our generative AI API security guide explains broader access and data-handling controls.
Test your key without exposing it
Install the official Google Gen AI Python SDK in a virtual environment:
python -m pip install -U google-genai
Save the following example as check_key.py. It requests model metadata rather than generating content. It can help identify invalid credentials or connectivity problems. Check Google’s applicable service terms and limits before making any API request.
from getpass import getpass
from google import genai
key = getpass("Gemini API key: ")
client = genai.Client(api_key=key)
for model in client.models.list():
print(model.name)
break
Run python check_key.py and enter your key when prompted. A successful response confirms that the credential can access the requested model-list operation, not that every listed model is available for inference at no cost. The example follows the SDK’s documented interface; it was not executed against a real Google account for this guide. No billable generation was performed.
Once you have verified the credential, choose a model explicitly supported by your project’s current tier. Use a server-side adapter to incorporate it into your application. Our chatbot API example provides a local request-handling prototype you can adapt.
Why can’t I create or use my Gemini API key?
The project is missing: Check your signed-in account, import the authorized project and verify the project’s status.
Create API key is unavailable: Organizational policy or missing cloud permissions may prevent project creation, key creation or service-account binding. Ask your administrator to grant the minimum necessary access; do not bypass workplace restrictions.
The key is rejected: Check that the credential is active, that you are using the intended project, and that the applicable API restriction is correct. Replace outdated or compromised credentials through the authorized project settings.
Requests hit a limit: Review the project’s usage and model availability. A quota error does not necessarily mean the key is invalid. Do not repeatedly retry a request if it may generate additional charges.
The integration fails: Verify whether your application expects the Gemini Developer API or a separate Google Cloud service. Integrations can require different authentication formats. Our AI provider integration guide covers credential configuration and test requests in business applications.
What to do if your Gemini API key is exposed
Revoke the exposed credential promptly through the authorized key-management interface and review recent usage. Create a replacement where appropriate, update your application’s secret store, and verify that the old credential no longer works. Removing a key from a Git file is insufficient if it remains in commit history or another person’s copy.
If unexpected charges or access appear, contact the relevant Google support channel and your administrator. Review associated service-account permissions and project usage rather than assuming the replacement key alone resolves the underlying exposure.
Frequently asked questions
Where do I find my existing Gemini API key? Open AI Studio’s API Keys page while signed in to the correct account and inspect the authorized project.
Do I need to create a new key for every application? Not always, but separate credentials can simplify access management and rotation. Separate projects when you need distinct quota, billing or permission boundaries.
Can I use a key from someone else’s project? Only when explicitly authorized and consistent with the project’s access and security policies.
Is a Google AI Studio key the same as a Google account password? No. It is an API credential associated with a project and, for authorization keys, a service account. Treat it as a secret.

