I’m getting a Pydantic validation error when trying to use the thinking_budget parameter with the Google GenAI Python SDK. The error occurs even when following the official documentation example.
Issue: The ThinkingConfig class doesn’t accept the thinking_budget parameter, throwing a “Extra inputs are not permitted” validation error.
Environment:
-
Python version: 3.12.x
-
Google GenAI SDK version: 0.3.2 (from pyproject.toml)
-
Pydantic version: 2.11.x
-
Operating System: Windows 10
Code that reproduces the error:
from google import genai
from google.genai import types
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(file), ‘..’)))
from utils.api_key_manager import APIKeyManager
api_key = APIKeyManager().get_key(‘google’)
client = genai.Client(api_key=api_key)
prompt = “Provide a list of 3 famous physicists and their key contributions”
response = client.models.generate_content(
model=“gemini-2.5-pro”,
contents=prompt,
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(thinking_budget=1024)
# To turn off thinking, use: thinking_budget=0
# To turn on dynamic thinking, use: thinking_budget=-1
),
)
print(response.text)
Error message:
pydantic_core._pydantic_core.ValidationError: 1 validation error for ThinkingConfig
thinking_budget
Extra inputs are not permitted [type=extra_forbidden, input_value=1024, input_type=int]
Questions
-
Is the thinking_budget parameter supported in the current Python SDK version?
-
What is the correct way to configure thinking budget in Python?
-
Are there any version compatibility issues between the SDK and Pydantic?
The official documentation shows this syntax, but it’s not working with the current SDK version. Any guidance would be appreciated.