Skip to content

Commit 7766b68

Browse files
Support reasoning_effort param for OpenAIModel (#854)
1 parent 35a097d commit 7766b68

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pydantic_ai_slim/pydantic_ai/models/openai.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@
5858
class OpenAIModelSettings(ModelSettings):
5959
"""Settings used for an OpenAI model request."""
6060

61-
# This class is a placeholder for any future openai-specific settings
61+
openai_reasoning_effort: chat.ChatCompletionReasoningEffort
62+
"""
63+
Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
64+
Currently supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
65+
result in faster responses and fewer tokens used on reasoning in a response.
66+
"""
6267

6368

6469
@dataclass(init=False)
@@ -202,6 +207,7 @@ async def _completions_create(
202207
presence_penalty=model_settings.get('presence_penalty', NOT_GIVEN),
203208
frequency_penalty=model_settings.get('frequency_penalty', NOT_GIVEN),
204209
logit_bias=model_settings.get('logit_bias', NOT_GIVEN),
210+
reasoning_effort=model_settings.get('openai_reasoning_effort', NOT_GIVEN),
205211
)
206212

207213
def _process_response(self, response: chat.ChatCompletion) -> ModelResponse:

0 commit comments

Comments
 (0)