-
Notifications
You must be signed in to change notification settings - Fork 943
Disable thinking mode in Gemini 2.5 flash #1555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm working on this already. Should be ready at some point this week. |
A small example of how to achieve this will be very helpful. |
@amiyapatanaik refer to the docs; https://ai.pydantic.dev/api/models/gemini/#pydantic_ai.models.gemini.GeminiModelSettings Something like this should work: from pydantic_ai import Agent
from pydantic_ai.models.gemini import GeminiModel, ThinkingConfig
from pydantic_ai.providers.google_gla import GoogleGLAProvider
api_key = "your_key"
gemini_thinking_config: ThinkingConfig = {
"include_thoughts": False,
"thinking_budget": 0,
}
agent = Agent(
model=GeminiModel(
model_name="gemini-2.5-flash-preview-04-17",
provider=GoogleGLAProvider(
api_key=api_key,
),
),
model_settings={"gemini_thinking_config": gemini_thinking_config}, # type: ignore
)
result = agent.run_sync("Who are you?")
print(result.output) I need to ignore type issues, because the default ModelSettings class somehow doesn't seem to recognize |
I expected to give do something along the line of:
... but this is completely ignored and for Usage(), I can see that it's thinking along anyway. The SOLUTION is using gemini_thinking_config in ModelSettings.
EDIT: Thanks @tcrapts for pointing this out! |
@d-zimmermann |
Description
Gemini 2.5 flash has thinking mode enabled by default. This is is expensive. It can be turned off, but Pydantic AI doesn't support this.
AISDK from Vercel does have this. We need something similar:
References
No response
The text was updated successfully, but these errors were encountered: