fix: allow users to disable aiohttp transport

This commit is contained in:
Ishaan Jaff
2025-05-31 12:32:24 -07:00
parent e011167317
commit 236975a742
2 changed files with 20 additions and 9 deletions
+2 -1
View File
@@ -303,7 +303,8 @@ priority_reservation: Optional[Dict[str, float]] = None
######## Networking Settings ########
use_aiohttp_transport: bool = True
use_aiohttp_transport: bool = True # Older variable, aiohttp is now the default. use disable_aiohttp_transport instead.
disable_aiohttp_transport: bool = False # Set this to true to use httpx instead
force_ipv4: bool = False # when True, litellm will force ipv4 for all LLM requests. Some users have seen httpx ConnectionError when using ipv6.
module_level_aclient = AsyncHTTPHandler(
timeout=request_timeout, client_alias="module level aclient"
+18 -8
View File
@@ -505,20 +505,30 @@ class AsyncHTTPHandler:
@staticmethod
def _should_use_aiohttp_transport() -> bool:
"""
This is feature flagged for now and is opt in as we roll out to all users.
AiohttpTransport is the default transport for litellm.
Controlled by either
- litellm.use_aiohttp_transport or os.getenv("USE_AIOHTTP_TRANSPORT") = "True"
Httpx can be used by the following
- litellm.disable_aiohttp_transport = True
- os.getenv("DISABLE_AIOHTTP_TRANSPORT") = "True"
"""
import os
from litellm.secret_managers.main import str_to_bool
#########################################################
# Check if user disabled aiohttp transport
########################################################
if (
str_to_bool(os.getenv("USE_AIOHTTP_TRANSPORT", "False"))
or litellm.use_aiohttp_transport
litellm.disable_aiohttp_transport is True
or str_to_bool(os.getenv("DISABLE_AIOHTTP_TRANSPORT", "False")) is True
):
verbose_logger.debug("Using AiohttpTransport...")
return True
return False
return False
#########################################################
# Default: Use AiohttpTransport
########################################################
verbose_logger.debug("Using AiohttpTransport...")
return True
@staticmethod
def _create_aiohttp_transport(