[Chore]: feature flag aiohttp transport - users should opt into using aiohttp transport (#11132)

* fix: feature flag aiohttp transport

* fix: feature flag aiohttp transport
This commit is contained in:
Ishaan Jaff
2025-05-24 16:29:53 -07:00
committed by GitHub
parent c725cbbde6
commit 9fc8d1c82e
3 changed files with 23 additions and 2 deletions
+1 -1
View File
@@ -300,7 +300,7 @@ custom_prometheus_metadata_labels: List[str] = []
priority_reservation: Optional[Dict[str, float]] = None
######## Networking Settings ########
use_aiohttp_transport: bool = True
use_aiohttp_transport: bool = False
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"
+19 -1
View File
@@ -494,7 +494,7 @@ class AsyncHTTPHandler:
# httpx_aiohttp is included in litellm docker images and pip when python 3.9+ is used
#########################################################
if (
litellm.use_aiohttp_transport
AsyncHTTPHandler._should_use_aiohttp_transport()
and AsyncHTTPHandler.aiohttp_transport_exists()
):
return AsyncHTTPHandler._create_aiohttp_transport(
@@ -506,6 +506,24 @@ class AsyncHTTPHandler:
#########################################################
return AsyncHTTPHandler._create_httpx_transport()
@staticmethod
def _should_use_aiohttp_transport() -> bool:
"""
This is feature flagged for now and is opt in as we roll out to all users.
Controlled by either
- litellm.use_aiohttp_transport or os.getenv("USE_AIOHTTP_TRANSPORT") = "True"
"""
from litellm.secret_managers.main import str_to_bool
if (
str_to_bool(os.getenv("USE_AIOHTTP_TRANSPORT", "False"))
or litellm.use_aiohttp_transport
):
verbose_logger.debug("Using AiohttpTransport...")
return True
return False
@staticmethod
def _create_aiohttp_transport(
ssl_verify: Optional[bool] = None,
@@ -11,6 +11,7 @@ from fastapi import APIRouter, Depends, HTTPException, Request, Response, status
import litellm
from litellm._logging import verbose_proxy_logger
from litellm.constants import HEALTH_CHECK_TIMEOUT_SECONDS
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
from litellm.proxy._types import (
AlertType,
CallInfo,
@@ -547,6 +548,7 @@ async def health_readiness():
"cache": cache_type,
"litellm_version": version,
"success_callbacks": success_callback_names,
"use_aiohttp_transport": AsyncHTTPHandler._should_use_aiohttp_transport(),
**db_health_status,
}
else:
@@ -556,6 +558,7 @@ async def health_readiness():
"cache": cache_type,
"litellm_version": version,
"success_callbacks": success_callback_names,
"use_aiohttp_transport": AsyncHTTPHandler._should_use_aiohttp_transport(),
}
except Exception as e:
raise HTTPException(status_code=503, detail=f"Service Unhealthy ({str(e)})")