GEMINI LABJP
NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20
Articles/Gemini Basics
Gemini Basics/2026-03-15Intermediate

Gemini 2.5 Pro Extended Thinking Mode — Deeper Reasoning for High-Precision Answers

Learn how Gemini 2.5 Pro's Extended Thinking mode enhances reasoning capabilities. Explore the mechanism behind deeper inference, ideal use cases, and implementation methods with code examples for complex problem-solving.

Gemini 2.5 Pro17Extended ThinkingReasoning2API12High Precision

Gemini 2.5 Pro Extended Thinking Mode

Setup and context

Gemini 2.5 Pro's Extended Thinking is a feature that deepens the AI's reasoning process, generating more accurate and well-founded answers to complex problems. Rather than providing instant responses, it takes time to analyze problems step-by-step, considers multiple approaches, and derives the final answer through comprehensive evaluation.


What is Extended Thinking?

Extended Thinking mode allows Gemini 2.5 Pro to perform an "invisible reasoning process" for a given problem. This process follows these steps:

  1. Problem Analysis: Break down the given problem into components
  2. Hypothesis Generation: Consider multiple approaches
  3. Reasoning: Verify the pros and cons of each approach
  4. Conclusion: Generate the optimal answer

This entire process is exposed to API users as "thinking" and can be referenced alongside the final answer.

Differences from Standard Mode

AspectStandard ModeExtended Thinking
Reasoning TimeShort (few seconds)Long (10-60 seconds)
AccuracyHigh (usually sufficient)Higher (for complex problems)
CostLowerSlightly higher
Use CasesText generation, Q&AMath, code, logic problems

Applicable Use Cases

Extended Thinking is particularly effective for complex problem-solving scenarios:

✓ Ideal Use Cases

  • Mathematical & Physics Calculations: Multi-step computations and proofs
  • Code Generation & Debugging: Complex algorithm implementation
  • Logic Problems: Puzzles and constraint satisfaction problems
  • Technical Design: Architecture decisions and best practice selection
  • Data Analysis: Statistical analysis and trend prediction

✗ Not Suitable For

  • Template or boilerplate generation
  • Simple information retrieval
  • Real-time chat responses

Basic API Usage

Step 1: Environment Setup

pip install google-genai

Step 2: Basic Extended Thinking Request

from google import genai
 
# Initialize client
client = genai.Client(api_key="YOUR_API_KEY")
 
# Solve a problem using Extended Thinking mode
response = client.models.generate_content(
    model="gemini-2.5-pro",
    contents="Solve this equation: 2x² + 5x - 3 = 0",
    config=genai.types.GenerateContentConfig(
        thinking={
            "type": "enabled",
            "budget_tokens": 5000,  # Max tokens for thinking
        }
    ),
)
 
# Display thinking process and final answer
for part in response.content.parts:
    if part.thinking:
        print("【Thinking Process】")
        print(part.thinking)
    elif part.text:
        print("【Final Answer】")
        print(part.text)

Step 3: Solving More Complex Problems

# Generate efficient code for computing Fibonacci numbers
response = client.models.generate_content(
    model="gemini-2.5-pro",
    contents="""
Write Python code meeting these requirements:
1. Function to compute the nth Fibonacci number
2. Achieve O(log n) time complexity
3. Use matrix exponentiation
4. Include test cases
    """,
    config=genai.types.GenerateContentConfig(
        thinking={
            "type": "enabled",
            "budget_tokens": 8000,
        }
    ),
)
 
for part in response.content.parts:
    if part.thinking:
        print("🤔 Thinking Process:")
        print(part.thinking[:500] + "..." if len(part.thinking) > 500 else part.thinking)
    elif part.text:
        print("\n💻 Generated Code:")
        print(part.text)

Practical Example: Complex Algorithm Problem

Solve the classic "3Sum" problem using Extended Thinking:

response = client.models.generate_content(
    model="gemini-2.5-pro",
    contents="""
Write efficient Python code to solve the 3Sum problem:
- Input: Integer array and target sum
- Output: All unique triplets that sum to target
- Time complexity: O(n²) or better
- Include test cases
 
Example: arr = [-1, 0, 1, 2, -1, -4], target = 0
Expected: [[-1, -1, 2], [-1, 0, 1]]
    """,
    config=genai.types.GenerateContentConfig(
        thinking={
            "type": "enabled",
            "budget_tokens": 10000,
        }
    ),
)
 
print("=== 3Sum Problem Solution ===\n")
for part in response.content.parts:
    if part.thinking:
        print("Thinking Process (Overview):")
        lines = part.thinking.split('\n')
        print('\n'.join(lines[:10]))
        print(f"... ({len(lines)} lines total)")
    elif part.text:
        print("\nFinal Code:\n")
        print(part.text)

Parameter Details

thinking Object

ParameterTypeDescription
typestringSet to "enabled" to activate Extended Thinking. Default is "disabled"
budget_tokensintMaximum tokens allocated for reasoning (1,000–100,000)

Larger budget_tokens values enable deeper thinking but increase response time and cost. Recommended range: 5,000–15,000.


Best Practices

  1. Enable only for complex problems: Use standard mode for simple questions
  2. Set budget_tokens appropriately: Adjust within 5,000–15,000 based on problem complexity
  3. Leverage thinking output: Review the reasoning to understand answer justification
  4. Implement error handling: Account for potential timeouts with retry logic

Conclusion

Gemini 2.5 Pro's Extended Thinking mode significantly improves AI accuracy and reliability for complex problem-solving. Whether you're tackling mathematical calculations, code generation, or logic problems, Extended Thinking delivers well-founded, high-precision answers. The API is straightforward—just configure the thinking parameter.

Try Extended Thinking in your projects today!

Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Gemini Basics2026-05-04
Gemini 3.2 Developer Monetization Blueprint — Building First-Mover Advantage with the New Model
With Gemini 3.2 reshaping the AI services market, here's how indie developers and small teams can raise client rates, design profitable own-products, and build first-mover positioning in a specific vertical — written from a working operator's perspective.
Gemini Basics2026-04-09
Gemini Thinking Mode Is Slow or Not Responding: How to Fix It
Gemini 2.5 Pro or Flash Thinking mode too slow, freezing, or timing out? Learn the most common causes and practical fixes—including timeout configuration, streaming setup, and thinking_budget tuning.
Gemini Basics2026-03-20
Gemini Practical Techniques [Part 1] — API Basics, Prompt Design & Multimodal Fundamentals
Curated practical techniques from Gemini Lab premium articles. Part 1 covers API basics, Function Calling, structured output, and multimodal input patterns.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →