diff --git a/homeassistant/components/openai_conversation/config_flow.py b/homeassistant/components/openai_conversation/config_flow.py index 7304eb52da3..102d1bf012c 100644 --- a/homeassistant/components/openai_conversation/config_flow.py +++ b/homeassistant/components/openai_conversation/config_flow.py @@ -63,6 +63,7 @@ from .const import ( RECOMMENDED_WEB_SEARCH_CONTEXT_SIZE, RECOMMENDED_WEB_SEARCH_USER_LOCATION, UNSUPPORTED_MODELS, + WEB_SEARCH_MODELS, ) _LOGGER = logging.getLogger(__name__) @@ -160,9 +161,10 @@ class OpenAIOptionsFlow(OptionsFlow): errors[CONF_CHAT_MODEL] = "model_not_supported" if user_input.get(CONF_WEB_SEARCH): - if not user_input.get( - CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL - ).startswith("gpt-4o"): + if ( + user_input.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL) + not in WEB_SEARCH_MODELS + ): errors[CONF_WEB_SEARCH] = "web_search_not_supported" elif user_input.get(CONF_WEB_SEARCH_USER_LOCATION): user_input.update(await self.get_location_data()) diff --git a/homeassistant/components/openai_conversation/const.py b/homeassistant/components/openai_conversation/const.py index 41abc504219..f022b4840eb 100644 --- a/homeassistant/components/openai_conversation/const.py +++ b/homeassistant/components/openai_conversation/const.py @@ -41,3 +41,12 @@ UNSUPPORTED_MODELS: list[str] = [ "gpt-4o-mini-realtime-preview", "gpt-4o-mini-realtime-preview-2024-12-17", ] + +WEB_SEARCH_MODELS: list[str] = [ + "gpt-4.1", + "gpt-4.1-mini", + "gpt-4o", + "gpt-4o-search-preview", + "gpt-4o-mini", + "gpt-4o-mini-search-preview", +] diff --git a/homeassistant/components/openai_conversation/strings.json b/homeassistant/components/openai_conversation/strings.json index 42baf40d470..0a07fa354b2 100644 --- a/homeassistant/components/openai_conversation/strings.json +++ b/homeassistant/components/openai_conversation/strings.json @@ -40,7 +40,7 @@ }, "error": { "model_not_supported": "This model is not supported, please select a different model", - "web_search_not_supported": "Web search is only supported for gpt-4o and gpt-4o-mini models" + "web_search_not_supported": "Web search is not supported by this model" } }, "selector": {