Google Gemini 2.5
The complete guide
Everything you need to know about Gemini 2.5 Pro and Flash — what they can do, how they compare to GPT-4o, and how to start using the API for free. Includes multimodal, grounding, thinking mode and 5 practical projects.
What is Google Gemini?
Gemini is a family of language models (LLMs) developed by Google DeepMind. It launched in late 2023 and within a year became one of the most serious competitors to OpenAI's GPT-4. In February 2024 the name was changed Bard to Gemini, and today the consumer interface is available at gemini.google.com.
What makes Gemini special is that it is multimodal from the ground up — it's not "a text model that had vision bolted on", but a model built to process text, images, audio, video and code together. In addition, Gemini has deep integration with Google services — Gmail, Docs, Drive, Search and more.
Google Workspace is very common in Israeli companies. Gemini is embedded directly in Gmail, Docs and Sheets — so many employees already "touch" it every day.
Gemini's versions — what are the differences?
As of April 2026, Google offers three main models in the 2.5 series:
A detailed version comparison
| Feature | 2.5 Pro | 2.5 Flash | Flash-8B / Lite |
|---|---|---|---|
| Context Window | 2M tokens | 1M tokens | 1M tokens |
| Input price (1M tokens) | $1.25 | $0.15 | $0.075 |
| Thinking Mode | Yes (advanced) | Yes (basic) | No |
| Multimodal | Full | Full | Partial |
| Latency | ~3-8 seconds | ~1-3 seconds | <1 second |
| Best for… | File analysis, code, research | Production apps, chatbots | Classification, simple questions |
A 2-million-token Context Window — what does it mean in practice?
2 million tokens equal roughly 1,500 books or 10 hours of video. In practice, it means you can feed Gemini an entire codebase, a full book, or a whole week's worth of meeting transcripts — and ask questions about it. This is the case where Gemini Pro beats everyone.
Gemini 2.5 vs GPT-4o vs Claude — a direct comparison
| Criterion | Gemini 2.5 Pro | GPT-4o | Claude 3.7 |
|---|---|---|---|
| Context Window | 2M tokens 🏆 | 128K | 200K |
| Writing code | Outstanding 🏆 | Excellent | Excellent |
| Hebrew | Good | Excellent 🏆 | Good |
| Image analysis | Outstanding 🏆 | Excellent | Good |
| Google integration | Perfect 🏆 | None | None |
| API price | Cheap 🏆 | Medium | Medium |
| Logic and reasoning | Outstanding 🏆 | Excellent | Excellent 🏆 |
Conclusion: Gemini 2.5 Pro is the best choice if you work with large files, long codebases, or Google products. GPT-4o still leads onHebrew.
Google AI Studio — the free entry point
Google AI Studio (aistudio.google.com) is the recommended way to start with Gemini. Free, no credit card, with 1,500 requests per day.
- Prompt Testing: Try different Prompts directly in the interface
- File Upload: Feed in PDFs, images, video and audio
- Get Code: Auto-generate Python/JS code for the API call
- Tune Models: Basic no-code fine-tuning
- Grounding with Search: Connect to Google Search in real time
AI Studio has a "System Instructions" field — that's the System Prompt. Put the personality, tone and constraints of your AI there. It will completely change the quality of the answers.
Getting started with the Gemini API — 5 minutes to Hello World
Get a free API Key from Google AI Studio and then:
# installation
pip install google-generativeai
# basic code
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-2.5-flash")
response = model.generate_content("Explain to me what Machine Learning is")
print(response.text)
Streaming — real-time answers
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-2.5-flash")
# Streaming — prints each word the moment it arrives
for chunk in model.generate_content("Write a short story about a robot in Tel Aviv", stream=True):
print(chunk.text, end="", flush=True)
Chat Session — keeping history
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-2.5-flash")
# open a session that keeps history
chat = model.start_chat(history=[])
resp1 = chat.send_message("My name is Daniel and I'm a Python developer")
resp2 = chat.send_message("What did I say a moment ago?")
print(resp2.text) # it will remember you are Daniel and a Python developer
# show history
for message in chat.history:
print(f"{message.role}: {message.parts[0].text[:50]}...")
JSON Mode — structured output
import google.generativeai as genai
import json
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-2.5-flash")
response = model.generate_content(
"Give me a list of 3 Israeli cities with their population. JSON only.",
generation_config={"response_mime_type": "application/json"}
)
data = json.loads(response.text)
# {"cities": [{"name": "Jerusalem", "population": 971000}, ...]}
Advanced example: analyzing a PDF document
import google.generativeai as genai
import pathlib
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-2.5-pro")
# upload a PDF
pdf_file = genai.upload_file(pathlib.Path("contract.pdf"))
# a question about the document
response = model.generate_content([
pdf_file,
"Summarize the 3 most important clauses in this contract"
])
print(response.text)
The Free Tier in AI Studio allows 1,500 RPD (Requests Per Day) for Flash. For Production apps — move to Vertex AI with pay-as-you-go billing.
Gemini Multimodal — sight, hearing and video
One of Gemini's greatest strengths is its multimodal capability — it can process images, PDFs, audio, video and YouTube URLs directly, without external tools.
Image analysis
import google.generativeai as genai
import PIL.Image
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel('gemini-2.5-pro')
# image from a local file
img = PIL.Image.open('screenshot.png')
response = model.generate_content(["Describe what you see in this image:", img])
print(response.text)
# image as Base64
import base64
with open("chart.jpg", "rb") as f:
image_data = base64.b64encode(f.read()).decode()
response = model.generate_content([
"Analyze this chart — what is the main trend?",
{"mime_type": "image/jpeg", "data": image_data}
])
print(response.text)
The image shows a bar chart comparing sales data across 4 quarters. You can see a steady rise of about 23% in the fourth quarter...
Audio analysis
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel('gemini-2.5-pro')
# upload an audio file
audio_file = genai.upload_file("meeting_recording.mp3", mime_type="audio/mp3")
# transcription + analysis
response = model.generate_content([
audio_file,
"""Perform the following actions:
1. Transcribe the recording
2. Summarize the main topics
3. List the Action Items mentioned"""
])
print(response.text)
Video and YouTube analysis
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel('gemini-2.5-pro')
# analyze a YouTube URL directly (unique to Gemini!)
response = model.generate_content([
"https://www.youtube.com/watch?v=VIDEO_ID",
"Summarize the video's main points in 5 bullets"
])
print(response.text)
# analyze a video from a file
video_file = genai.upload_file("demo.mp4", mime_type="video/mp4")
response = model.generate_content([
video_file,
"Describe what happens in the scene at 2:30"
])
Only Gemini supports direct analysis of YouTube URLs — no need to download, transcribe and upload separately. Just give it the URL and the timestamp.
File API — uploading large files
Gemini's File API lets you upload files up to 2GB to Google's servers and use them across multiple requests. Files are stored 48 hours.
- PDF, DOCX, TXT — documents
- MP3, WAV, FLAC, OGG — audio
- MP4, MOV, AVI, WEBM — video
- PNG, JPEG, GIF, WEBP — images
import google.generativeai as genai
import time
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel('gemini-2.5-pro')
# upload a file
sample_file = genai.upload_file(
path="annual_report.pdf",
display_name="Annual Report 2025"
)
# wait for processing (for large files)
while sample_file.state.name == "PROCESSING":
print("Processing...")
time.sleep(5)
sample_file = genai.get_file(sample_file.name)
# use the file
response = model.generate_content([
sample_file,
"Summarize the main points"
])
print(response.text)
# list all uploaded files
for f in genai.list_files():
print(f.display_name, f.state.name)
# delete a file
genai.delete_file(sample_file.name)
System Instructions — shaping the AI's personality
System Instructions are Gemini's System Prompt. They define the personality, tone, answer language, constraints and the "who" of the AI you're building.
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
# define a model with System Instructions
model = genai.GenerativeModel(
model_name='gemini-2.5-pro',
system_instruction="""You are an expert data-analysis assistant.
Always answer in English only.
Use Markdown tables when relevant.
Present data including percentages and trends.
Don't make up numbers — if you don't know, say "unknown".
Always prepare a 2-3 sentence summary at the end of every answer."""
)
response = model.generate_content("What are the trends in the Israeli real-estate market in 2025?")
print(response.text)
Example: building a Support Bot
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
support_bot = genai.GenerativeModel(
model_name='gemini-2.5-flash',
system_instruction="""You are a customer-support rep for a SaaS company.
Rules:
- Always answer in a pleasant, professional tone
- If the question is technical and you don't know — write: "I'll pass this to the technical team"
- For billing questions — always refer to the email billing@company.com
- Don't promise things not stated in these instructions"""
)
chat = support_bot.start_chat()
response = chat.send_message("I can't log in to my account")
print(response.text)
System Instructions persist throughout the conversation and are not "forgotten". They form the "DNA" of your Agent. Every Prompt sent after them behaves according to them.
Grounding with Google Search — real-time information
Grounding is the ability to connect Gemini to Google Search in real time — so the model searches the web before it answers. This ensures up-to-date information and reduces hallucinations.
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
# using Grounding with Google Search
model = genai.GenerativeModel('gemini-2.5-pro')
response = model.generate_content(
"What is the price of Bitcoin and Ethereum right now? What is the daily trend?",
tools=[{"google_search_retrieval": {}}]
)
print(response.text)
# Grounding metadata — the information sources
if response.candidates[0].grounding_metadata:
print("\n--- sources ---")
for chunk in response.candidates[0].grounding_metadata.grounding_chunks:
print(f"- {chunk.web.title}: {chunk.web.uri}")
According to Google Finance data, Bitcoin is currently trading at $67,450, up 2.3% over the last 24 hours...
Dynamic Retrieval — saving on costs
# Dynamic Retrieval — Gemini decides when to search
response = model.generate_content(
"What is the history of Tel Aviv?", # ← static info, won't search
tools=[{
"google_search_retrieval": {
"dynamic_retrieval_config": {
"mode": "MODE_DYNAMIC",
"dynamic_threshold": 0.3 # threshold: 0=always, 1=never
}
}
}]
)
# Gemini searches only if confidence < threshold
Gemini 2.5 Thinking Mode — extended thinking
Thinking Mode is a special mode in Gemini 2.5 Pro and Flash in which the model "thinks out loud" before it answers. Similar to OpenAI's o1 and Claude's Extended Thinking, Gemini devotes extra tokens to an internal reasoning process.
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
# Thinking Mode with budget_tokens
model = genai.GenerativeModel('gemini-2.5-pro')
response = model.generate_content(
"Solve: if I have 3 boxes, each with 7 apples, and I gave 12 to friends — how many are left?",
generation_config=genai.GenerationConfig(
thinking_config=genai.ThinkingConfig(
thinking_budget=8000 # tokens for internal thinking
)
)
)
print("Answer:", response.text)
# show the thinking process (if available)
if hasattr(response.candidates[0], 'thinking_content'):
print("Internal thinking:", response.candidates[0].thinking_content)
When to use Thinking Mode?
| Situation | Thinking OFF | Thinking ON |
|---|---|---|
| Simple questions | Recommended | A waste |
| Logic puzzles / math | Many errors | Highly recommended |
| Writing complex code | Basic | Recommended |
| Argument analysis | Shallow | Recommended |
| Translation / creative writing | Recommended | Not needed |
Thinking tokens are counted at full price. With budget_tokens=8000, each request may add another $0.01. Use this only for questions that genuinely require complex reasoning.
Tips and use cases — what Gemini does best
1. Analyzing an entire codebase
Feed in all the files in your project (up to 2M tokens) and ask: "What happens when a user signs up? Describe the flow". Gemini will do it in 30 seconds.
2. Processing recorded meetings
Feed in an audio/video file of a meeting — Gemini will produce a transcription, summary, Action Items and points of disagreement. Excellent for teams.
3. Deep Research with Grounding
Enable "Grounding with Google Search" and Gemini will search the web in real time while answering. Better for up-to-date research than GPT-4o WebSearch.
4. Automation in Google Workspace
Via Google Apps Script you can connect Gemini to Gmail, Sheets and Docs at no extra cost. Write an automatic summary bot for your emails.
// Google Apps Script — Automatic Gmail Summary
function summarizeEmail() {
const threads = GmailApp.getInboxThreads(0, 5);
const genAI = new GoogleAI("YOUR_API_KEY");
threads.forEach(thread => {
const body = thread.getMessages()[0].getBody();
const prompt = `Summarize the following email in 2 sentences:\n${body}`;
const summary = genAI.generateContent(prompt).text;
thread.addLabel(GmailApp.getUserLabelByName("Summarized"));
});
}
5. Generating images with Imagen 3
Gemini is connected to Imagen 3 — Google's image generator. Through the API you can generate high-quality photorealistic images.
5 practical projects with Gemini
From simple projects to building a full Agent — pick by your level:
Document Analyzer — automatic PDF analysis
BeginnerUpload any PDF — a contract, annual report, research — and get a structured summary with key points, conclusions and important clauses. Built in Python in 20 lines.
Video Analyzer — YouTube analysis
MediumGive a YouTube URL and get: a transcription, summary, notable quotes, a topic list — all automatic. Add Grounding for real-time fact-checking.
Visual Q&A — a Chatbot with images
MediumBuild a chatbot users can send images to and ask questions. We'll use Gradio for a quick interface and Chat Session for conversation memory.
RAG Pipeline — documents + Vector Store
AdvancedBuild a full RAG: Gemini Embeddings + Pinecone/ChromaDB + Gemini 2.5 Flash to answer questions from a corpus of documents. You can filter per-document.
Research Agent with Google Search
AdvancedAn Agent that researches a topic in depth: asks questions, searches Google Search, filters sources, summarizes findings — and produces a report. Based on Gemini Grounding + Thinking Mode.
Cheat sheet — Gemini API Quick Reference
Model comparison — by Use Case
| Use Case | Recommended model | Reason |
|---|---|---|
| Chatbot in Production | gemini-2.5-flash | Price + speed |
| Long PDF analysis | gemini-2.5-pro | 2M context |
| Writing complex code | gemini-2.5-pro + thinking | reasoning |
| Classification / tagging | flash-8b / lite | Cheapest |
| Up-to-date research | 2.5-pro + grounding | real-time search |
| Video / YouTube analysis | gemini-2.5-pro | multimodal |
Main parameters of generate_content
import google.generativeai as genai
model = genai.GenerativeModel('gemini-2.5-flash')
response = model.generate_content(
"Your question here",
generation_config=genai.GenerationConfig(
temperature=0.7, # 0=deterministic, 2=creative
top_p=0.95, # nucleus sampling
top_k=40, # top-k tokens
max_output_tokens=2048, # max output tokens
stop_sequences=["END"], # stop at this text
response_mime_type="application/json", # JSON mode
),
safety_settings={ # safety levels
"HARM_CATEGORY_HARASSMENT": "BLOCK_NONE",
}
)
Common patterns — Copy-Paste Ready
# ── 1. simple question ──
response = model.generate_content("question")
print(response.text)
# ── 2. Streaming ──
for chunk in model.generate_content("question", stream=True):
print(chunk.text, end="")
# ── 3. Chat with history ──
chat = model.start_chat(history=[
{"role": "user", "parts": ["Hello"]},
{"role": "model", "parts": ["Hello! How can I help?"]}
])
resp = chat.send_message("follow-up question")
# ── 4. image ──
import PIL.Image
img = PIL.Image.open("image.png")
response = model.generate_content(["Describe:", img])
# ── 5. JSON output ──
response = model.generate_content(
"Give JSON with fields: name, age, city",
generation_config={"response_mime_type": "application/json"}
)
# ── 6. Grounding ──
response = model.generate_content(
"Today's news in Israel",
tools=[{"google_search_retrieval": {}}]
)
# ── 7. File upload ──
f = genai.upload_file("doc.pdf")
response = model.generate_content([f, "Summarize"])
Common error codes and solutions
| Error | Reason | Solution |
|---|---|---|
| RESOURCE_EXHAUSTED | You exceeded the RPM/RPD quota | Add retry with exponential backoff |
| INVALID_ARGUMENT | File too large / wrong format | Check size limits (2GB max) |
| SAFETY_BLOCKED | Content blocked by Safety | Check response.prompt_feedback |
| DEADLINE_EXCEEDED | timeout (large file / thinking) | Increase timeout / use streaming |
| response.text — error | Safety block / empty response | Check response.candidates[0].finish_reason |
Summary — when to choose Gemini?
- A large file or long document? Gemini 2.5 Pro — the 2M context is unrivaled
- A Google Workspace product? Gemini — the integration is built in
- An API on a low budget? Gemini 2.5 Flash — the best price on the market
- High-quality Hebrew? GPT-4o still leads, Gemini is in the ballpark
- Complex reasoning? Gemini 2.5 Pro + Thinking Mode
- Real-time information? Gemini with Grounding + Google Search
- Video/image analysis? Gemini — multimodal from the ground up
The next step
Go to aistudio.google.com, try Gemini 2.5 Flash for free, and test with the examples from this guide. When you're ready — move to Vertex AI for Production projects.