Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix: prevent KeyError crash in OpenAI reasoning models

karamvirsingh19984330164f9593
diff --git a/browser_use/llm/openai/chat.py b/browser_use/llm/openai/chat.py
index ecf05b654..ca0518d7f 100644
--- a/browser_use/llm/openai/chat.py
+++ b/browser_use/llm/openai/chat.py
@@ -184,8 +184,8 @@ class ChatOpenAI(BaseChatModel):
if self.reasoning_models and any(str(m).lower() in str(self.model).lower() for m in self.reasoning_models):
model_params['reasoning_effort'] = self.reasoning_effort
- del model_params['temperature']
- del model_params['frequency_penalty']
+ model_params.pop('temperature', None)
+ model_params.pop('frequency_penalty', None)
if output_format is None:
# Return string response