DEV Community

Dex
Dex

Posted on

Automate a boring task for $0 with the Google AI Studio free API tier

Automate a boring task for $0 with the Google AI Studio free API tier

Google AI Studio gives you a free Gemini API key with a generous free tier. No credit card. Here is the full path from zero to a working automation.

1. Get your free API key

Go to aistudio.google.com, sign in with a Google account, and click "Get API key". Copy it. Treat it like a password: put it in an environment variable, never in your code.

export GEMINI_API_KEY="your-key-here"
Enter fullscreen mode Exit fullscreen mode

2. Make your first call

No SDK needed. Plain curl works:

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -d '{"contents":[{"parts":[{"text":"Summarize this in one sentence: The quick brown fox jumps over the lazy dog."}]}]}'
Enter fullscreen mode Exit fullscreen mode

gemini-2.5-flash-lite is the fastest model and has the most generous free-tier quota, so it is the right default for automations.

3. Build something real: a text summarizer

Say you wake up to 40 unread newsletters and threads. This script condenses pasted text into 5 bullets:

import os, sys, json, urllib.request

API_KEY = os.environ["GEMINI_API_KEY"]
MODEL = "gemini-2.5-flash-lite"
URL = f"https://generativelanguage.googleapis.com/v1beta/models/{MODEL}:generateContent"

def summarize(text):
    body = json.dumps({
        "contents": [{"parts": [{"text":
            "Summarize the following in exactly 5 short bullets:\n\n" + text}]}]
    }).encode()
    req = urllib.request.Request(
        URL, data=body,
        headers={"Content-Type": "application/json", "x-goog-api-key": API_KEY})
    with urllib.request.urlopen(req) as res:
        data = json.load(res)
    return data["candidates"][0]["content"]["parts"][0]["text"]

if __name__ == "__main__":
    print(summarize(sys.stdin.read()))
Enter fullscreen mode Exit fullscreen mode

Usage:

cat long-article.txt | python summarize.py
Enter fullscreen mode Exit fullscreen mode

Zero dependencies beyond the standard library. Run it on a schedule with cron and you have a free daily digest.

4. Know the limits

The free tier has rate limits (requests per minute and per day). They change, so check your current quota at aistudio.google.com under usage. If you hit a 429, slow down and retry later.

One real caveat: do not send private or customer data through the free tier. Keep it to public or personal content.

Where this goes

Once you see what one script can do, the next step is wiring it into a real workflow: inbox triage, lead follow-ups, report generation. That is the part I do for businesses.

I build AI automations for businesses. Chatbots, workflow automation, custom tools that cut manual work. Engineering proof: github.com/Dextheking1. DMs open on X: @FREEAIMETHODS.

Top comments (0)