From 23aed52e8f697b6f9f31196efae7b9ec4d7c054f Mon Sep 17 00:00:00 2001 From: Nandana Dileep Date: Sun, 19 Apr 2026 14:44:52 +0530 Subject: [PATCH] fix: apply ssl_verify to streaming text completion requests `streaming()` and `async_streaming()` in the text-completion handler were passing `litellm.client_session` / `litellm.aclient_session` directly as the httpx client, which are `None` by default. When `None`, the OpenAI SDK instantiates its own client without any SSL override, so `ssl_verify: false` had no effect on streaming requests. Non-streaming async (`acompletion`) already used `BaseOpenAILLM._get_async_http_client()`, which reads `litellm.ssl_verify` and builds a properly configured httpx client. Apply the same pattern to all three remaining code paths (sync non-streaming, sync streaming, async streaming) and remove the now-unused `import litellm`. Fixes #26053 --- litellm/llms/openai/completion/handler.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/litellm/llms/openai/completion/handler.py b/litellm/llms/openai/completion/handler.py index 1641615126e..82e3e4b0e06 100644 --- a/litellm/llms/openai/completion/handler.py +++ b/litellm/llms/openai/completion/handler.py @@ -3,7 +3,6 @@ from typing import Callable, List, Optional, Union from openai import AsyncOpenAI, OpenAI -import litellm from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj from litellm.litellm_core_utils.streaming_handler import CustomStreamWrapper from litellm.llms.base import BaseLLM @@ -114,7 +113,7 @@ class OpenAITextCompletion(BaseLLM): openai_client = OpenAI( api_key=api_key, base_url=api_base, - http_client=litellm.client_session, + http_client=BaseOpenAILLM._get_sync_http_client(), timeout=timeout, max_retries=max_retries, # type: ignore organization=organization, @@ -224,7 +223,7 @@ class OpenAITextCompletion(BaseLLM): openai_client = OpenAI( api_key=api_key, base_url=api_base, - http_client=litellm.client_session, + http_client=BaseOpenAILLM._get_sync_http_client(), timeout=timeout, max_retries=max_retries, # type: ignore organization=organization, @@ -285,7 +284,7 @@ class OpenAITextCompletion(BaseLLM): openai_client = AsyncOpenAI( api_key=api_key, base_url=api_base, - http_client=litellm.aclient_session, + http_client=BaseOpenAILLM._get_async_http_client(), timeout=timeout, max_retries=max_retries, organization=organization,