Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: allow users to disable aiohttp transport

Ishaan Jaff236975a74259
diff --git a/litellm/__init__.py b/litellm/__init__.py
index ff3e93fcda3..b99750b5928 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -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"
diff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.py
index aaf3b92e6bb..87941aedea7 100644
--- a/litellm/llms/custom_httpx/http_handler.py
+++ b/litellm/llms/custom_httpx/http_handler.py
@@ -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(