How to Get Free Gemini API Key & Free Tier Rate Limits
Whenever I share the Gemini API sample codes, the first question I get is "Is it free?". The second one is "Why am I getting Error 429?".
Short answer is, yes. Google gives a free tier for Gemini API, and you can start using it without adding any credit card. But the free tier has limits on how many requests you can send per minute & per day. Once you cross it, the API stops responding till the limit resets.
In this page, lets see how to get the free API key step by step, what the rate limits mean, where to check the limits for your account & how to handle the 429 error in your code.
Also Read: How to use Gemini API in Python | Gemini API in Excel VBA
Steps to Get Free Gemini API Key
The API key is created from Google AI Studio. All you need is a Google account (Gmail account is enough).
- Open Google AI Studio API Keys page & login with your Google account.
- If you are using it for the first time, it will ask you to accept the terms of service. Accept it.
- Click on the "Create API key" button.
- AI Studio will create a Google Cloud project for you automatically & attach the key to it. You do not have to open Google Cloud console separately.
- Copy the key that is displayed & save it in a safe place.
That's it. The key is ready to use. New accounts start in the Free tier by default.
If you already have a Google Cloud project & want the key under that project, go to Projects in AI Studio, click "Import projects", select your project & then create the key from the API Keys page.
Note: Treat this key like a password. Do not paste it in code that you share with others, upload to Github or send in email. If it is leaked by mistake, delete that key in AI Studio & create a new one.
Check if the API Key is Working
Before writing any code, you can quickly test the key with curl. This command just lists the models available for your key. It works in Windows Command Prompt (Windows 10 & above), Mac & Linux.
curl "https://generativelanguage.googleapis.com/v1beta/models" -H "x-goog-api-key: PASTE_YOUR_API_KEY_HERE"
If the key is correct, you will see a long JSON list with model names like "models/gemini-3.8-flash". If you see "API key not valid", then the key is copied wrongly. Check for extra spaces at the beginning or end.
What are the Rate Limits in Gemini API Free Tier?
Google measures the usage in 3 ways. Your request is blocked if you cross any one of them.
- RPM - Requests Per Minute: How many API calls you can make in one minute. If you run a loop without any wait, this is the limit you will hit first.
- TPM - Tokens Per Minute: Total tokens (input + output) per minute. A token is roughly 3 to 4 characters of English text. Sending big PDFs or long emails uses up this limit quickly.
- RPD - Requests Per Day: Total requests in a day. This resets at midnight Pacific time. For us in India, it means the daily quota resets around 1:30 PM IST (12:30 PM IST when US daylight saving time is on).
Now, what are the actual numbers? Earlier Google used to publish a fixed table for this. Now the limits are different for each model, depend on your usage tier & keep changing whenever a new model is released. So, the correct numbers for your account are shown inside AI Studio itself.
Where to See Your Gemini API Limits & Usage?
- Login to Google AI Studio.
- Go to Dashboard -> Usage. Here you can see how many requests you have used, per model.
- On the same page, click "Rate limit" (or "View your active rate limits") to see RPM, TPM & RPD allowed for each model in your project.
Few things I noticed, which are good to know before you plan any automation.
- Limits are per project, not per API key: Creating 5 API keys in the same project will not give you 5 times the quota. All keys in a project share the same limit.
- Flash & Flash-Lite models are free: These are the models you should use in free tier. Flash-Lite is the cheapest & usually gets more requests per day.
- Top Pro models are not in free tier: The most advanced Pro models need a billing account. If you call them with a free key, you will get an error.
- Preview models have lower limits: Models with "preview" or "experimental" in the name are more restricted than the stable ones.
Free Tier vs Paid Tier - What is the Difference?
Other than the limits, there is one important difference that many people miss.
In free tier, the content you send (your prompts & the responses) can be used by Google to improve their products. In paid tier, it is not used. So, do not send confidential office data, customer details or anything personal using a free key. If you are building something for your company, it is better to move to the paid tier & also check with your IT team.
The tiers work like this:
- Free: Default for every new account. No billing needed.
- Tier 1: Link an active billing account in AI Studio ("Set up billing" button). Limits are increased immediately.
- Tier 2 & Tier 3: You move up automatically once you have spent a certain amount & few days have passed after the first payment. Each tier also has a monthly spend cap.
Paid tier is billed per token. For small personal automation like summarizing few emails a day, the cost is very low. But, set a budget alert in Google Cloud billing so that a wrong loop does not give you a surprise bill.
How to Handle Error 429 (Rate Limit Exceeded) in Python
When you cross the limit, the API returns HTTP 429 with the message "RESOURCE_EXHAUSTED". The program should not just crash at this point. It should wait for some time & try again.
Here is a simple retry function. Every time it gets a 429, it waits & doubles the waiting time for the next try (5, 10, 20 seconds & so on).
import time
from google import genai
from google.genai import errors
client = genai.Client()
def ask_gemini(userPrompt, maxRetry=5):
waitSeconds = 5
for attempt in range(maxRetry):
try:
response = client.models.generate_content(
model="gemini-3.8-flash",
contents=userPrompt
)
return response.text
except errors.APIError as e:
# Retry only for rate limit error, raise others
if e.code == 429:
print("Rate limit reached. Waiting " + str(waitSeconds) + " seconds...")
time.sleep(waitSeconds)
waitSeconds = waitSeconds * 2
else:
raise
return "Failed after " + str(maxRetry) + " attempts"
print(ask_gemini("Give me 3 tips to learn Excel VBA"))
If you are using VBA, the same idea applies. Check if the response starts with "Error 429" & use Application.Wait before calling again. In the Excel VBA Gemini code, I have added a 2 second wait between each row for this reason.
Tips to Stay Within Gemini Free Tier Limits
- Send many items in one request: Instead of sending 100 customer comments one by one, send 20 comments in one prompt & ask Gemini to return 20 answers, one per line. That is 5 requests instead of 100.
- Add a small wait in loops: 2 to 5 seconds between calls is usually enough to stay under the per minute limit.
- Use Flash-Lite for simple jobs: Classification, translation or short summaries do not need the bigger model.
- Don't send the same question again: Save the answers in a file or sheet & skip the rows that already have an answer.
- Send only what is needed: If you want the summary of an email, remove the long signature & old reply chain. Less text means less tokens.
With a free key & these small precautions, you can do quite a lot of daily automation without spending anything. Once the key is ready, try the Gemini formula in Google Sheets, it is the quickest way to see the API working.