Skip to content

Add thinking_budget parameter to ChatGoogleGenerativeAI to support Gemini 2.5 Flash #872

Description

@khoa1337

The new release of Gemini 2.5 Flash has introduced a new parameter to Google's SDK, as follows:

prompt = "Explain the Occam's Razor concept and provide everyday examples of it"
budget = 1024 # You can set this variable to any value between 0 and 24k

client = genai.Client(api_key="your-api-key")

response = client.models.generate_content(
model="gemini-2.5-flash-preview-04-17",
contents=prompt,
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(
thinking_budget=budget
)
)
)

print(response.text)

As seen in https://ai.google.dev/gemini-api/docs/thinking#set-budget

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions