The Gemini API is where the cheapest Gemini lives. There is no monthly fee, a free tier in Google AI Studio for testing, and per-token prices that start around $0.10 per million input tokens on Flash Lite at the time of writing. If any of your work is repeatable, this lesson will probably pay for itself in a month.
When the API beats the subscription
- You run the same task many times (summaries, extraction, classification, translation).
- Your usage is bursty — heavy one week, nothing the next — so a flat fee is wasted.
- You want a specific model, not whatever the app decides to give you.
- You want to build Gemini into a script, spreadsheet, or product.
- Your monthly token cost on Flash is below the subscription price — which for most people it is.
Step 1: get a key
Go to Google AI Studio, sign in, and create an API key. The free tier lets you test without a card; enabling billing moves you to paid rates and higher limits. Store the key in an environment variable named GEMINI_API_KEY. Never paste it into code you commit.
Step 2: your first call with curl
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-X POST \
-d '{
"contents": [{
"parts": [{ "text": "In two sentences, explain what a token is." }]
}]
}'The response is JSON. The text lives under candidates[0].content.parts[0].text, and usageMetadata reports the prompt and output token counts — read it, because that is your bill.
Step 3: the same call in Python
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="In two sentences, explain what a token is.",
)
print(response.text)
print(response.usage_metadata) # prompt and output token countsContext caching
If you send the same large block of context repeatedly — a manual, a codebase, a long system prompt — Gemini can cache it and charge a much lower rate for the cached tokens on later calls. Our catalogue lists a cached input price for the current models: Gemini 3.1 Pro Preview at $0.20 per million cached tokens against $2.00 standard at the time of writing, and Gemini 3.8 Flash at $0.075 against $0.75. Cached content is stored for a time you set and there is a storage charge; see the official caching docs for the current rules.
Batch mode
If you do not need answers immediately, batch mode lets you submit many requests together and collect results later at a lower rate. Our catalogue carries separate batch rows — Gemini 3.1 Pro Preview (batch) is listed at $1.00 in and $6.00 out against $2.00 and $12.00 standard — which is a halving on that model at the time of writing. Overnight summaries, backfills and bulk classification are the natural fit. Details in the official batch docs.
Knowledge check
You send the same 200,000-token product manual with every customer query. What is the biggest single cost saving available?