Google’s Gemini models offer unique capabilities including a 1M-token context window, native multimodal processing of images, video, audio, and documents, and tight integration with the Google ecosystem.
Google offers three tiers of Gemini models, each balancing capability against speed and cost.
| Model | Input (per MTok) | Output (per MTok) | Context | Best For |
|---|---|---|---|---|
| Gemini 2.5 Pro | $1.25–$10 | $10–$30 | 1M | Complex reasoning |
| Gemini 2.5 Flash | $0.15–$0.60 | $0.60–$3.50 | 1M | Fast, cost-effective |
| Gemini 2.0 Flash | Free tier available | Free tier available | 1M | Prototyping |
Key differentiator: Gemini 2.5 Flash offers a generous free tier (up to 500 RPD at no cost), making it excellent for prototyping and learning before committing to paid usage.
Gemini’s 1M-token context window (roughly 700K words) opens use cases that were previously impossible with shorter context models.
Filling a 1M-token context costs $1.25–$10 per request depending on the model. For repeated queries over the same document, consider chunking + RAG as an alternative. Context length is a capability, not a mandate.
Gemini processes multiple input modalities natively, not through separate models.
import google.generativeai as genai
model = genai.GenerativeModel("gemini-2.5-flash")
# Analyse an image
response = model.generate_content([
"Describe what you see in this image.",
genai.upload_file("photo.jpg"),
])
print(response.text)
Google offers two platforms to access Gemini, each designed for different use cases.
google-generativeai SDKgoogle-cloud-aiplatform SDKFor this course, we use Google AI Studio with the google-generativeai SDK. The API surface is nearly identical; the main difference is authentication and enterprise features.
Getting started with the google-generativeai SDK requires minimal setup.
pip install google-generativeai
import google.generativeai as genai
from dotenv import load_dotenv
import os
load_dotenv()
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
model = genai.GenerativeModel("gemini-2.5-flash")
response = model.generate_content("Explain quantum entanglement simply.")
print(response.text)
print(f"Tokens: {response.usage_metadata.prompt_token_count} in, "
f"{response.usage_metadata.candidates_token_count} out")
Key difference from OpenAI/Anthropic: Gemini uses a GenerativeModel object rather than passing the model name to each call. You create the model once and call generate_content() on it. Chat sessions use model.start_chat().
Live demonstration: use Gemini’s long context to analyse a complete document.