@@ -502,15 +502,31 @@ class BaseChatOpenAI(BaseChatModel):
502
502
max_tokens : Optional [int ] = Field (default = None )
503
503
"""Maximum number of tokens to generate."""
504
504
reasoning_effort : Optional [str ] = None
505
- """Constrains effort on reasoning for reasoning models.
506
-
507
- Reasoning models only, like OpenAI o1 and o3-mini.
505
+ """Constrains effort on reasoning for reasoning models. For use with the Chat
506
+ Completions API.
507
+
508
+ Reasoning models only, like OpenAI o1, o3, and o4-mini.
508
509
509
510
Currently supported values are low, medium, and high. Reducing reasoning effort
510
511
can result in faster responses and fewer tokens used on reasoning in a response.
511
-
512
+
512
513
.. versionadded:: 0.2.14
513
514
"""
515
+ reasoning : Optional [dict [str , Any ]] = None
516
+ """Reasoning parameters for reasoning models, i.e., OpenAI o-series models (o1, o3,
517
+ o4-mini, etc.). For use with the Responses API.
518
+
519
+ Example:
520
+
521
+ .. code-block:: python
522
+
523
+ reasoning={
524
+ "effort": "medium", # can be "low", "medium", or "high"
525
+ "summary": "auto", # can be "auto", "concise", or "detailed"
526
+ }
527
+
528
+ .. versionadded:: 0.3.24
529
+ """
514
530
tiktoken_model_name : Optional [str ] = None
515
531
"""The model name to pass to tiktoken when using this class.
516
532
Tiktoken is used to count the number of tokens in documents to constrain
@@ -556,11 +572,41 @@ class BaseChatOpenAI(BaseChatModel):
556
572
However this does not prevent a user from directly passed in the parameter during
557
573
invocation.
558
574
"""
575
+
576
+ include : Optional [list [str ]] = None
577
+ """Additional fields to include in generations from Responses API.
578
+
579
+ Supported values:
580
+
581
+ - ``"file_search_call.results"``
582
+ - ``"message.input_image.image_url"``
583
+ - ``"computer_call_output.output.image_url"``
584
+ - ``"reasoning.encrypted_content"``
585
+ - ``"code_interpreter_call.outputs"``
586
+
587
+ .. versionadded:: 0.3.24
588
+ """
589
+
559
590
service_tier : Optional [str ] = None
560
591
"""Latency tier for request. Options are 'auto', 'default', or 'flex'. Relevant
561
592
for users of OpenAI's scale tier service.
562
593
"""
563
594
595
+ store : Optional [bool ] = None
596
+ """If True, the Responses API may store response data for future use. Defaults to
597
+ True.
598
+
599
+ .. versionadded:: 0.3.24
600
+ """
601
+
602
+ truncation : Optional [str ] = None
603
+ """Truncation strategy (Responses API). Can be ``"auto"`` or ``"disabled"``
604
+ (default). If ``"auto"``, model may drop input items from the middle of the
605
+ message sequence to fit the context window.
606
+
607
+ .. versionadded:: 0.3.24
608
+ """
609
+
564
610
use_responses_api : Optional [bool ] = None
565
611
"""Whether to use the Responses API instead of the Chat API.
566
612
@@ -685,7 +731,11 @@ def _default_params(self) -> dict[str, Any]:
685
731
"n" : self .n ,
686
732
"temperature" : self .temperature ,
687
733
"reasoning_effort" : self .reasoning_effort ,
734
+ "reasoning" : self .reasoning ,
735
+ "include" : self .include ,
688
736
"service_tier" : self .service_tier ,
737
+ "truncation" : self .truncation ,
738
+ "store" : self .store ,
689
739
}
690
740
691
741
params = {
@@ -3134,7 +3184,7 @@ def _construct_responses_api_payload(
3134
3184
for legacy_token_param in ["max_tokens" , "max_completion_tokens" ]:
3135
3185
if legacy_token_param in payload :
3136
3186
payload ["max_output_tokens" ] = payload .pop (legacy_token_param )
3137
- if "reasoning_effort" in payload :
3187
+ if "reasoning_effort" in payload and "reasoning" not in payload :
3138
3188
payload ["reasoning" ] = {"effort" : payload .pop ("reasoning_effort" )}
3139
3189
3140
3190
payload ["input" ] = _construct_responses_api_input (messages )
0 commit comments