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]

Lazy load OpenAILikeChatConfig to avoid heavy import (#18075)

Alexsander Hamir233e89976a1f
diff --git a/litellm/__init__.py b/litellm/__init__.py
index 98e5a34bd6a..e1719f13263 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -1056,7 +1056,6 @@ from .utils import client
from .llms.bytez.chat.transformation import BytezChatConfig
from .llms.custom_llm import CustomLLM
-from .llms.openai_like.chat.handler import OpenAILikeChatConfig
from .llms.aiohttp_openai.chat.transformation import AiohttpOpenAIChatConfig
from .llms.galadriel.chat.transformation import GaladrielChatConfig
from .llms.github.chat.transformation import GithubChatConfig
@@ -1554,6 +1553,7 @@ if TYPE_CHECKING:
# LLM config classes - lazy loaded only
AmazonConverseConfig: Type[Any]
+ OpenAILikeChatConfig: Type[Any]
def __getattr__(name: str) -> Any:
diff --git a/litellm/_lazy_imports.py b/litellm/_lazy_imports.py
index 9da861a1028..94b3e4a8da1 100644
--- a/litellm/_lazy_imports.py
+++ b/litellm/_lazy_imports.py
@@ -157,6 +157,7 @@ DOTPROMPT_NAMES = (
# LLM config classes that support lazy loading via _lazy_import_llm_configs
LLM_CONFIG_NAMES = (
"AmazonConverseConfig",
+ "OpenAILikeChatConfig",
)
# Types that support lazy loading via _lazy_import_types
@@ -651,4 +652,12 @@ def _lazy_import_llm_configs(name: str) -> Any:
_globals["AmazonConverseConfig"] = _AmazonConverseConfig
return _AmazonConverseConfig
+ if name == "OpenAILikeChatConfig":
+ from .llms.openai_like.chat.handler import (
+ OpenAILikeChatConfig as _OpenAILikeChatConfig,
+ )
+
+ _globals["OpenAILikeChatConfig"] = _OpenAILikeChatConfig
+ return _OpenAILikeChatConfig
+
raise AttributeError(f"LLM config lazy import: unknown attribute {name!r}")
\ No newline at end of file