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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
[Bug Fix] - gemini leaking FD for sync calls with litellm.completion (#12824)
Ishaan Jaff9022d144a684
diff --git a/litellm/llms/anthropic/chat/handler.py b/litellm/llms/anthropic/chat/handler.pyindex 04cf66cf021..620d2f05119 100644--- a/litellm/llms/anthropic/chat/handler.py+++ b/litellm/llms/anthropic/chat/handler.py@@ -27,6 +27,7 @@ from litellm.litellm_core_utils.core_helpers import map_finish_reasonfrom litellm.llms.custom_httpx.http_handler import (AsyncHTTPHandler,HTTPHandler,+ _get_httpx_client,get_async_httpx_client,)from litellm.types.llms.anthropic import (@@ -433,7 +434,9 @@ class AnthropicChatCompletion(BaseLLM):else:if client is None or not isinstance(client, HTTPHandler):- client = HTTPHandler(timeout=timeout) # type: ignore+ client = _get_httpx_client(+ params={"timeout": timeout}+ )else:client = clientdiff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.pyindex d09599e8789..e4a68dd82e0 100644--- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py+++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py@@ -35,6 +35,7 @@ from litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMExceptifrom litellm.llms.custom_httpx.http_handler import (AsyncHTTPHandler,HTTPHandler,+ _get_httpx_client,get_async_httpx_client,)from litellm.types.llms.anthropic import AnthropicThinkingParam@@ -1881,7 +1882,7 @@ class VertexLLM(VertexBase):if isinstance(timeout, float) or isinstance(timeout, int):timeout = httpx.Timeout(timeout)_params["timeout"] = timeout- client = HTTPHandler(**_params) # type: ignore+ client = _get_httpx_client(params=_params)else:client = client