◉GEMINI LABJP
●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…
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 ThinkingReasoningAPI12High 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.
◈ API / SDK2026-04-26
Production-Ready Function Calling with Gemini 2.5 Pro API — Realistic Patterns for Failures, Timeouts, and Hallucinations
Gemini 2.5 Pro's Function Calling is powerful, but it tends to land in 'works, but does odd things sometimes' territory in production. Here are the design patterns I arrived at running search, reservation, and notification agents.
◉ Gemini Basics2026-10-13
When Gemini's Activity Setting Won't Change on a Work Account: Three Screens to Check First
If the Gemini app's Activity setting doesn't behave on a work or school account, check three places in order: your own screen, the admin console, and Vault. Includes a short message to send your admin and a line to draw before pasting customer details.