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
fix: shared_sessions not being used
AlexsanderHamir697cb0906011
diff --git a/litellm/llms/openai/openai.py b/litellm/llms/openai/openai.pyindex 2949e35e5e7..3282b7665c0 100644--- a/litellm/llms/openai/openai.py+++ b/litellm/llms/openai/openai.py@@ -1414,6 +1414,7 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM):timeout: Union[float, httpx.Timeout],aspeech: Optional[bool] = None,client=None,+ shared_session: Optional["ClientSession"] = None,) -> HttpxBinaryResponseContent:if aspeech is not None and aspeech is True:return self.async_audio_speech(@@ -1428,6 +1429,7 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM):max_retries=max_retries,timeout=timeout,client=client,+ shared_session=shared_session,) # type: ignoreopenai_client = self._get_openai_client(@@ -1437,6 +1439,7 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM):timeout=timeout,max_retries=max_retries,client=client,+ shared_session=shared_session,)response = cast(OpenAI, openai_client).audio.speech.create(@@ -1460,6 +1463,7 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM):max_retries: int,timeout: Union[float, httpx.Timeout],client=None,+ shared_session: Optional["ClientSession"] = None,) -> HttpxBinaryResponseContent:openai_client = cast(AsyncOpenAI,@@ -1470,6 +1474,7 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM):timeout=timeout,max_retries=max_retries,client=client,+ shared_session=shared_session,),)diff --git a/litellm/main.py b/litellm/main.pyindex 14d0b04b7b5..412d7f1c38e 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -5747,6 +5747,7 @@ def speech( # noqa: PLR0915proxy_server_request = kwargs.get("proxy_server_request", None)extra_headers = kwargs.get("extra_headers", None)model_info = kwargs.get("model_info", None)+ shared_session = kwargs.get("shared_session", None)model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider(model=model, custom_llm_provider=custom_llm_provider, api_base=api_base) # type: ignore@@ -5856,6 +5857,7 @@ def speech( # noqa: PLR0915timeout=timeout,client=client, # pass AsyncOpenAI, OpenAI clientaspeech=aspeech,+ shared_session=shared_session,)elif custom_llm_provider == "azure":# Check if this is Azure Speech Service (Cognitive Services TTS)