Skip to main content
An example of how to use the thinking budget parameter with the Gemini model. This requires google-genai > 1.10.0
Google has scheduled gemini-2.5-pro for shutdown on October 16, 2026 and recommends gemini-3.1-pro-preview. Gemini 3 models use thinking_level instead of a token thinking_budget. See Gemini deprecations and Gemini thinking.
agent_with_thinking_budget.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your Google API key

4

Migrate the Gemini thinking configuration

Replace Gemini(id="gemini-2.5-pro", thinking_budget=1280, include_thoughts=True) with Gemini(id="gemini-3.1-pro-preview", thinking_level="low", include_thoughts=True) in the saved file.
5

Run the example

Save the code above as agent_with_thinking_budget.py, then run:
Full source: cookbook/90_models/google/gemini/agent_with_thinking_budget.py