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]

refactor: use method-level import for MockOpenAITransport

Ryan Crabbefb123ec52b76
diff --git a/litellm/llms/openai/common_utils.py b/litellm/llms/openai/common_utils.py
index b9c474b327f..61f150f1c2e 100644
--- a/litellm/llms/openai/common_utils.py
+++ b/litellm/llms/openai/common_utils.py
@@ -22,7 +22,6 @@ from litellm.llms.custom_httpx.http_handler import (
AsyncHTTPHandler,
get_ssl_configuration,
)
-from litellm.llms.custom_httpx.mock_transport import MockOpenAITransport
def _get_client_init_params(cls: type) -> Tuple[str, ...]:
@@ -207,6 +206,8 @@ class BaseOpenAILLM:
return litellm.aclient_session
if getattr(litellm, "network_mock", False):
+ from litellm.llms.custom_httpx.mock_transport import MockOpenAITransport
+
return httpx.AsyncClient(transport=MockOpenAITransport())
# Get unified SSL configuration
@@ -230,6 +231,8 @@ class BaseOpenAILLM:
return litellm.client_session
if getattr(litellm, "network_mock", False):
+ from litellm.llms.custom_httpx.mock_transport import MockOpenAITransport
+
return httpx.Client(transport=MockOpenAITransport())
# Get unified SSL configuration