@@ -89,10 +89,13 @@ class Parameters(BaseModel):
8989 gt = 0 ,
9090 )
9191
92- thinking_enable : bool = Field (
93- default = False ,
92+ thinking_enable : bool | None = Field (
93+ default = None ,
9494 title = "Thinking" ,
95- description = "Whether to enable thinking output." ,
95+ description = "Whether to enable thinking output."
96+ " ``None`` keeps the Gemini model's own default"
97+ " (2.5 Pro/Flash think by default);"
98+ " ``True``/``False`` explicitly turns thinking on/off." ,
9699 )
97100
98101 thinking_budget : int | None = Field (
@@ -234,11 +237,17 @@ async def _call_api(
234237 if self .parameters .top_p is not None :
235238 config ["top_p" ] = self .parameters .top_p
236239
237- if self .parameters .thinking_enable :
238- config ["thinking_config" ] = {
239- "include_thoughts" : True ,
240- "thinking_budget" : self .parameters .thinking_budget or 1024 ,
241- }
240+ if self .parameters .thinking_enable is not None :
241+ if self .parameters .thinking_enable :
242+ config ["thinking_config" ] = {
243+ "include_thoughts" : True ,
244+ "thinking_budget" : self .parameters .thinking_budget or 1024 ,
245+ }
246+ else :
247+ config ["thinking_config" ] = {
248+ "include_thoughts" : False ,
249+ "thinking_budget" : 0 ,
250+ }
242251
243252 fmt_tools , fmt_tool_choice = self ._format_tools (tools , tool_choice )
244253
0 commit comments