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] Networking: remove limitations (#15302)

Alexsander Hamir49e04e02174e
diff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.py
index 3a67d5127b7..138c31ba716 100644
--- a/litellm/llms/custom_httpx/http_handler.py
+++ b/litellm/llms/custom_httpx/http_handler.py
@@ -164,7 +164,7 @@ class AsyncHTTPHandler:
self,
timeout: Optional[Union[float, httpx.Timeout]] = None,
event_hooks: Optional[Mapping[str, List[Callable[..., Any]]]] = None,
- concurrent_limit=1000,
+ concurrent_limit=None, # Kept for backward compatibility, but ignored (no limits)
client_alias: Optional[str] = None, # name for client in logs
ssl_verify: Optional[VerifyTypes] = None,
shared_session: Optional["ClientSession"] = None,
@@ -173,7 +173,6 @@ class AsyncHTTPHandler:
self.event_hooks = event_hooks
self.client = self.create_client(
timeout=timeout,
- concurrent_limit=concurrent_limit,
event_hooks=event_hooks,
ssl_verify=ssl_verify,
shared_session=shared_session,
@@ -183,7 +182,6 @@ class AsyncHTTPHandler:
def create_client(
self,
timeout: Optional[Union[float, httpx.Timeout]],
- concurrent_limit: int,
event_hooks: Optional[Mapping[str, List[Callable[..., Any]]]],
ssl_verify: Optional[VerifyTypes] = None,
shared_session: Optional["ClientSession"] = None,
@@ -209,10 +207,6 @@ class AsyncHTTPHandler:
transport=transport,
event_hooks=event_hooks,
timeout=timeout,
- limits=httpx.Limits(
- max_connections=concurrent_limit,
- max_keepalive_connections=concurrent_limit,
- ),
verify=ssl_config,
cert=cert,
headers=headers,
@@ -286,7 +280,7 @@ class AsyncHTTPHandler:
except (httpx.RemoteProtocolError, httpx.ConnectError):
# Retry the request with a new session if there is a connection error
new_client = self.create_client(
- timeout=timeout, concurrent_limit=1, event_hooks=self.event_hooks
+ timeout=timeout, event_hooks=self.event_hooks
)
try:
return await self.single_connection_post_request(
@@ -352,7 +346,7 @@ class AsyncHTTPHandler:
except (httpx.RemoteProtocolError, httpx.ConnectError):
# Retry the request with a new session if there is a connection error
new_client = self.create_client(
- timeout=timeout, concurrent_limit=1, event_hooks=self.event_hooks
+ timeout=timeout, event_hooks=self.event_hooks
)
try:
return await self.single_connection_post_request(
@@ -412,7 +406,7 @@ class AsyncHTTPHandler:
except (httpx.RemoteProtocolError, httpx.ConnectError):
# Retry the request with a new session if there is a connection error
new_client = self.create_client(
- timeout=timeout, concurrent_limit=1, event_hooks=self.event_hooks
+ timeout=timeout, event_hooks=self.event_hooks
)
try:
return await self.single_connection_post_request(
@@ -471,7 +465,7 @@ class AsyncHTTPHandler:
except (httpx.RemoteProtocolError, httpx.ConnectError):
# Retry the request with a new session if there is a connection error
new_client = self.create_client(
- timeout=timeout, concurrent_limit=1, event_hooks=self.event_hooks
+ timeout=timeout, event_hooks=self.event_hooks
)
try:
return await self.single_connection_post_request(
@@ -657,7 +651,7 @@ class AsyncHTTPHandler:
)
return LiteLLMAiohttpTransport(
client=lambda: ClientSession(
- connector=TCPConnector(**connector_kwargs),
+ connector=TCPConnector(limit=0, **connector_kwargs), # 0 = unlimited connections per host
trust_env=trust_env,
),
)
@@ -680,7 +674,7 @@ class HTTPHandler:
def __init__(
self,
timeout: Optional[Union[float, httpx.Timeout]] = None,
- concurrent_limit=1000,
+ concurrent_limit=None, # Kept for backward compatibility, but ignored (no limits)
client: Optional[httpx.Client] = None,
ssl_verify: Optional[Union[bool, str]] = None,
):
@@ -701,10 +695,6 @@ class HTTPHandler:
self.client = httpx.Client(
transport=transport,
timeout=timeout,
- limits=httpx.Limits(
- max_connections=concurrent_limit,
- max_keepalive_connections=concurrent_limit,
- ),
verify=ssl_config,
cert=cert,
headers=headers,
diff --git a/litellm/llms/openai/common_utils.py b/litellm/llms/openai/common_utils.py
index 00197a67e95..ce470f04aca 100644
--- a/litellm/llms/openai/common_utils.py
+++ b/litellm/llms/openai/common_utils.py
@@ -207,7 +207,6 @@ class BaseOpenAILLM:
ssl_config = get_ssl_configuration()
return httpx.AsyncClient(
- limits=httpx.Limits(max_connections=1000, max_keepalive_connections=100),
verify=ssl_config,
transport=AsyncHTTPHandler._create_async_transport(
ssl_context=ssl_config
@@ -228,7 +227,6 @@ class BaseOpenAILLM:
ssl_config = get_ssl_configuration()
return httpx.Client(
- limits=httpx.Limits(max_connections=1000, max_keepalive_connections=100),
verify=ssl_config,
follow_redirects=True,
)