22
33from __future__ import annotations
44
5- from functools import partial
65import json
76import logging
87import re
3029)
3130from homeassistant .core import HomeAssistant , callback
3231from homeassistant .helpers import llm
32+ from homeassistant .helpers .httpx_client import get_async_client
3333from homeassistant .helpers .selector import (
3434 NumberSelector ,
3535 NumberSelectorConfig ,
@@ -89,8 +89,8 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None:
8989
9090 Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
9191 """
92- client = await hass . async_add_executor_job (
93- partial ( anthropic . AsyncAnthropic , api_key = data [CONF_API_KEY ])
92+ client = anthropic . AsyncAnthropic (
93+ api_key = data [CONF_API_KEY ], http_client = get_async_client ( hass )
9494 )
9595 await client .models .list (timeout = 10.0 )
9696
@@ -457,11 +457,9 @@ async def async_step_model(
457457
458458 async def _get_model_list (self ) -> list [SelectOptionDict ]:
459459 """Get list of available models."""
460- client = await self .hass .async_add_executor_job (
461- partial (
462- anthropic .AsyncAnthropic ,
463- api_key = self ._get_entry ().data [CONF_API_KEY ],
464- )
460+ client = anthropic .AsyncAnthropic (
461+ api_key = self ._get_entry ().data [CONF_API_KEY ],
462+ http_client = get_async_client (self .hass ),
465463 )
466464 return await get_model_list (client )
467465
@@ -470,11 +468,9 @@ async def _get_location_data(self) -> dict[str, str]:
470468 location_data : dict [str , str ] = {}
471469 zone_home = self .hass .states .get (ENTITY_ID_HOME )
472470 if zone_home is not None :
473- client = await self .hass .async_add_executor_job (
474- partial (
475- anthropic .AsyncAnthropic ,
476- api_key = self ._get_entry ().data [CONF_API_KEY ],
477- )
471+ client = anthropic .AsyncAnthropic (
472+ api_key = self ._get_entry ().data [CONF_API_KEY ],
473+ http_client = get_async_client (self .hass ),
478474 )
479475 location_schema = vol .Schema (
480476 {
0 commit comments