diff --git a/custom_components/extended_openai_conversation/__init__.py b/custom_components/extended_openai_conversation/__init__.py index a411379..7cd6276 100644 --- a/custom_components/extended_openai_conversation/__init__.py +++ b/custom_components/extended_openai_conversation/__init__.py @@ -30,6 +30,7 @@ intent, template, ) +from homeassistant.helpers.httpx_client import get_async_client from homeassistant.helpers.typing import ConfigType from homeassistant.util import ulid @@ -145,12 +146,14 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None: azure_endpoint=base_url, api_version=entry.data.get(CONF_API_VERSION), organization=entry.data.get(CONF_ORGANIZATION), + http_client=get_async_client(hass), ) else: self.client = AsyncOpenAI( api_key=entry.data[CONF_API_KEY], base_url=base_url, organization=entry.data.get(CONF_ORGANIZATION), + http_client=get_async_client(hass), ) @property diff --git a/custom_components/extended_openai_conversation/helpers.py b/custom_components/extended_openai_conversation/helpers.py index 41246c8..937a294 100644 --- a/custom_components/extended_openai_conversation/helpers.py +++ b/custom_components/extended_openai_conversation/helpers.py @@ -39,6 +39,7 @@ from homeassistant.core import HomeAssistant, State from homeassistant.exceptions import HomeAssistantError, ServiceNotFound from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.httpx_client import get_async_client from homeassistant.helpers.script import Script from homeassistant.helpers.template import Template import homeassistant.util.dt as dt_util @@ -141,10 +142,14 @@ async def validate_authentication( azure_endpoint=base_url, api_version=api_version, organization=organization, + http_client=get_async_client(hass), ) else: client = AsyncOpenAI( - api_key=api_key, base_url=base_url, organization=organization + api_key=api_key, + base_url=base_url, + organization=organization, + http_client=get_async_client(hass), ) await client.models.list(timeout=10)