Skip to content
Google Gemini Prompting Best Practices

The Trove library · other

Google Gemini Prompting Best Practices

By Google

Comprehensive guide to prompting best practices for Google Gemini models including Gemini 3.1 Pro, 3 Pro, 3 Flash, 2.5 Pro, 2.5 Flash, and 2.5 Flash-Lite. Covers universal techniques, model-specific tips, thinking mode, function calling, multimodal capabilities, grounding, caching, and agentic patterns sourced from official Google documentation.

  • 138 pages
  • 138 chapters
  • Updated February 22, 2026

Free to add

Read a preview
Use with your AI agent

Add the book to your library, then connect Trove to the AI tool you use.

See installation options

A look inside · First page

Chapter 1: Introduction & Model Overview

Google Gemini is a family of multimodal large language models developed by Google DeepMind. Designed to understand and generate across text, images, audio, video, and code, the Gemini model family offers a range of options tailored to different performance, latency, and cost requirements. This chapter provides a comprehensive overview of the current model lineup, their capabilities, pricing, and guidance on choosing the right model for your use case.

Current Gemini Model Lineup

The Gemini model family is organized into three active series, each representing a generation of capability improvements. Understanding which series and model to use is the first decision you need to make when building with Gemini.

Gemini 3 Series (Preview)

The Gemini 3 series represents the latest generation of models, currently available in preview. These models introduce simplified thinking controls, improved conciseness, and enhanced multimodal capabilities.

  • Gemini 3.1 Pro -- The most capable model in the 3 series, offering top-tier reasoning and generation quality. API ID: gemini-3.1-pro-preview.
  • Gemini 3 Pro -- A highly capable reasoning model balancing quality and efficiency. API ID: gemini-3-pro-preview.
  • Gemini 3 Flash -- Optimized for speed and cost efficiency while maintaining strong reasoning. API ID: gemini-3-flash-preview.
  • Gemini 3 Pro Image (Nano Banana Pro) -- Specialized for professional-grade image generation with 4K output, advanced text rendering, and search grounding. API ID: gemini-3-pro-image-preview.

All Gemini 3 models share a 1 million token context window, a 64K maximum output, and a knowledge cutoff of January 2025. They introduce the new thinkingLevel parameter (replacing thinkingBudget) and default to more concise responses compared to previous generations.

Gemini 2.5 Series (Generally Available)

The Gemini 2.5 series is the current generally available (GA) production-ready lineup. These models offer strong reasoning with configurable thinking budgets and are suitable for production deployments.

  • Gemini 2.5 Pro -- The most advanced GA reasoning model for complex tasks. API ID: gemini-2.5-pro. Input pricing: $1.25 per MTok (up to 200K context) / $2.50 per MTok (over 200K context). Output pricing: $10 per MTok (up to 200K) / $15 per MTok (over 200K). Thinking budget range: 128 to 32,768 tokens.
  • Gemini 2.5 Flash -- The best price-performance reasoning model. API ID: gemini-2.5-flash. Input pricing: $0.30 per MTok. Output pricing: $2.50 per MTok. Thinking budget range: 0 to 24,576 tokens (can be fully disabled).
  • Gemini 2.5 Flash-Lite -- The most cost-efficient model for high-volume workloads. API ID: gemini-2.5-flash-lite. Input pricing: $0.10 per MTok. Output pricing: $0.40 per MTok. No thinking support.

Gemini 2.0 (Deprecated)

  • Gemini 2.0 Flash -- Previously the workhorse model, now deprecated in favor of the 2.5 series. Existing integrations should plan migration to Gemini 2.5 Flash or Flash-Lite.

Model Comparison Table

ModelAPI IDStatusContext WindowMax OutputThinkingInput Price (per MTok)Output Price (per MTok)Best For
3.1 Progemini-3.1-pro-previewPreview1M64KthinkingLevel$2.00$12.00Most demanding reasoning tasks
3 Progemini-3-pro-previewPreview1M64KthinkingLevel$2.00$12.00Complex reasoning and generation
3 Flashgemini-3-flash-previewPreview1M64KthinkingLevel$0.50$3.00Fast, cost-effective reasoning
3 Pro Imagegemini-3-pro-image-previewPreview1M64KYes----Professional image generation
2.5 Progemini-2.5-proGA1M64K128-32768$1.25 / $2.50$10.00 / $15.00Complex coding, math, analysis
2.5 Flashgemini-2.5-flashGA1M64K0-24576$0.30$2.50High-volume reasoning tasks
2.5 Flash-Litegemini-2.5-flash-liteGA1M64KNone$0.10$0.40Classification, extraction, high-volume
2.0 Flashgemini-2.0-flashDeprecated1M64KNone----Legacy workloads (migrate away)

Platform Availability

Gemini models are accessible through three primary platforms, each serving different audiences and use cases.

Gemini Developer API

The Gemini Developer API is the most direct way to access Gemini models. It provides RESTful endpoints and official SDKs in Python, JavaScript/TypeScript, Go, and Java. This is the recommended starting point for individual developers, startups, and rapid prototyping.

Google AI Studio

Google AI Studio is a web-based IDE for experimenting with Gemini models. It provides a visual interface for testing prompts, adjusting parameters, and comparing model outputs without writing code. AI Studio is excellent for prompt development, few-shot example curation, and quick experimentation before committing to code.

Vertex AI

Vertex AI is Google Cloud's enterprise ML platform. It offers the same Gemini models but adds enterprise features including VPC security, data residency controls, IAM-based access management, model monitoring, batch prediction, and SLA-backed uptime guarantees. Use Vertex AI for production deployments in regulated industries or organizations with strict compliance requirements.

Specialized Variants

Beyond the core text-and-reasoning models, Google offers several specialized Gemini variants designed for specific tasks.

VariantPurpose
Flash Image / Nano BananaFast image generation optimized for high-volume, low-latency workflows
Nano Banana ProProfessional 4K image generation with text rendering and search grounding
LiveReal-time voice and video streaming over WebSocket connections
TTS (Text-to-Speech)High-quality speech synthesis with multiple voice options
EmbeddingsDense vector representations for semantic search and retrieval
Deep ResearchExtended multi-step research workflows with automatic source gathering
Computer UseBrowser automation through screenshots and UI action commands
RoboticsPhysical world interaction and robotic control planning

Decision Framework for Choosing the Right Model

Selecting the right Gemini model depends on four key dimensions: task complexity, latency requirements, cost sensitivity, and feature needs.

By Task Complexity

  • Simple tasks (classification, extraction, formatting): Use 2.5 Flash-Lite for maximum cost efficiency, or 3 Flash with thinkingLevel: minimal if you need the latest capabilities.
  • Moderate tasks (summarization, Q&A, content generation): Use 2.5 Flash with dynamic thinking, or 3 Flash with thinkingLevel: medium.
  • Complex tasks (multi-step reasoning, code generation, mathematical proofs): Use 2.5 Pro or 3 Pro with high thinking budgets.
  • Most demanding tasks (competition math, novel algorithm design, deep analysis): Use 2.5 Pro with Deep Think (budget 32768) or 3.1 Pro with thinkingLevel: high.

By Latency Requirements

  • Real-time / sub-second: Use the Live API variants for streaming, or 2.5 Flash-Lite for fastest batch responses.
  • Interactive (1-5 seconds): Use 2.5 Flash or 3 Flash with moderate thinking.
  • Batch / async: Use any model; consider batch API pricing discounts for non-urgent workloads.

By Cost Sensitivity

  • Budget-constrained: Start with 2.5 Flash-Lite ($0.10/$0.40 per MTok) and only upgrade if quality is insufficient.
  • Balanced: Use 2.5 Flash ($0.30/$2.50 per MTok) for the best quality-per-dollar with reasoning.
  • Quality-first: Use 2.5 Pro or 3.1 Pro when output quality justifies the cost.

Free vs Paid vs Enterprise Tier Comparison

FeatureFree TierPaid TierEnterprise (Vertex AI)
Rate limits15 RPM / 1,500 RPD2,000+ RPMCustom / negotiated
Context cachingLimitedFull accessFull access + SLA
Batch APINot available50% discount pricingFull access
Grounding (Search)1,500 RPD free$14-$35 per 1K queriesVolume pricing
SupportCommunityStandardPremium / dedicated
Data residencyNo controlLimitedFull control
SLANone99.9%99.95%+
ComplianceBasicSOC 2HIPAA, FedRAMP, etc.

The free tier is suitable for development and testing. The paid tier unlocks production-level rate limits and features. Enterprise (Vertex AI) adds the security, compliance, and operational controls required by large organizations.

Add this book to your library to keep reading.

What’s inside

09Batch API examplep. 9

13Fast classification -- no reasoning neededp. 13
14Comparing two approaches -- moderate reasoningp. 14

18When importing external conversation historyp. 18

20Deep Think for a hard optimization problemp. 20

24Build the function responsep. 24
25Send the full conversation back to the modelp. 25
26"The weather in Tokyo is currently 22 degrees Celsius and partly cloudyp. 26

28The response contains multiple function call partsp. 28
29Output:p. 29
30Call: get_weather({"location": "New York, NY"})p. 30
31Call: get_weather({"location": "London, UK"})p. 31

33Extract all function calls from the responsep. 33

35Build all function responsesp. 35
36Send all results back in a single turnp. 36
37"Here's the current weather:p. 37
38- New York: 18°C, sunnyp. 38
39- London: 12°C, overcastp. 39

42Model returns: get_current_location()p. 42
43Returns: {"city": "San Francisco", "state": "CA"}p. 43
44Model returns: get_weather({"location": "San Francisco, CA"})p. 44

46Pass functions directly -- the SDK handles everythingp. 46

48Response includes current news with source citationsp. 48

50Upload a file firstp. 50

53Connect to an MCP serverp. 53
54List available tools from the MCP serverp. 54

56The SDK handles everything automaticallyp. 56

58Bad: Unclear what this doesp. 58

60Bad: Free-form string invites errorsp. 60

62For older Gemini models or when you need strict determinismp. 62

65This will NOT work with Gemini 2.5 modelsp. 65
66Instead, use EITHER custom functions:p. 66

68Correct: Preserve the model's response exactly as receivedp. 68
69Send it back unchanged in the conversation historyp. 69
70INCORRECT: Reconstructing function calls loses the thought signaturep. 70
71Do NOT do this:p. 71

73Using the SDK's built-in chat -- signatures are handled automaticallyp. 73
74SDK automatically handles function execution, signatures, and response cyclesp. 74

76Upload the file oncep. 76

78Correct ordering: image first, then textp. 78

80Upload video via File APIp. 80
81Wait for processing to completep. 81

83Example: Processing a long video at low resolution for general summaryp. 83

86Less effectivep. 86

89Server-side: Generate an ephemeral tokenp. 89
90Send token.token to the client applicationp. 90

92Turn 1: Generate the initial imagep. 92
93Turn 2: Add elementsp. 93
94Turn 3: Modify the lightingp. 94

99Access the response textp. 99

101Step 1: Use Google Search to find relevant sourcesp. 101
102Step 2: Extract URLs from grounding metadata, then use URL Contextp. 102
103for deep analysis of the most relevant pagesp. 103

105These two requests share the same system instruction prefix.p. 105
106The system may automatically cache the shared content.p. 106
107Request 1p. 107

109Step 1: Create a cache with a large documentp. 109
110Step 2: Use the cache in subsequent requestsp. 110
111Step 3: Update the TTL if you need more timep. 111

113List all active cachesp. 113

115LESS EFFECTIVE: Asking for multiple facts in one queryp. 115

117CORRECT: Query after contextp. 117

121Deterministic output (e.g., for classification tasks)p. 121

123Short, concise answerp. 123

126Define toolsp. 126
127Create an ADK agentp. 127

129Stage 1: Research agentp. 129
130Stage 2: Analysis agentp. 130
131Stage 3: Writer agentp. 131

133The model returns actions like:p. 133

135Cache the agent's reference documentationp. 135

137Install ADKp. 137

About this book

Comprehensive guide to prompting best practices for Google Gemini models including Gemini 3.1 Pro, 3 Pro, 3 Flash, 2.5 Pro, 2.5 Flash, and 2.5 Flash-Lite. Covers universal techniques, model-specific tips, thinking mode, function calling, multimodal capabilities, grounding, caching, and agentic patterns sourced from official Google documentation.