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
This commit is contained in:
Nandana Dileep 2026-04-19 14:44:52 +05:30
parent 2f22a1293e
commit 23aed52e8f

View file

@ -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,