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]

fix(lint): bring basedpyright rule counts back under their budget limits

mateo-berri469d5126f69a
diff --git a/enterprise/litellm_enterprise/enterprise_callbacks/__init__.py b/enterprise/litellm_enterprise/enterprise_callbacks/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/enterprise_callbacks/pagerduty/__init__.py b/enterprise/litellm_enterprise/enterprise_callbacks/pagerduty/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/__init__.py b/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/integrations/__init__.py b/enterprise/litellm_enterprise/integrations/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/litellm_core_utils/__init__.py b/enterprise/litellm_enterprise/litellm_core_utils/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/proxy/hooks/__init__.py b/enterprise/litellm_enterprise/proxy/hooks/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/proxy/vector_stores/__init__.py b/enterprise/litellm_enterprise/proxy/vector_stores/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/py.typed b/enterprise/litellm_enterprise/py.typed
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/types/__init__.py b/enterprise/litellm_enterprise/types/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/types/enterprise_callbacks/__init__.py b/enterprise/litellm_enterprise/types/enterprise_callbacks/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/enterprise/litellm_enterprise/types/proxy/__init__.py b/enterprise/litellm_enterprise/types/proxy/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/litellm-proxy-extras/litellm_proxy_extras/py.typed b/litellm-proxy-extras/litellm_proxy_extras/py.typed
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/litellm/__init__.py b/litellm/__init__.py
index 319da4e25eb..89310120768 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -2150,9 +2150,9 @@ def __getattr__(name: str) -> Any:
# Lazy load encoding from main.py to avoid heavy tiktoken import
if name == "encoding":
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
# Check if already cached
if "encoding" not in _globals:
from .main import encoding as _encoding
@@ -2162,9 +2162,9 @@ def __getattr__(name: str) -> Any:
# Lazy load bedrock_tool_name_mappings instance
if name == "bedrock_tool_name_mappings":
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
# Check if already cached
if "bedrock_tool_name_mappings" not in _globals:
from .llms.bedrock.chat.invoke_handler import (
@@ -2176,9 +2176,9 @@ def __getattr__(name: str) -> Any:
# Lazy load AzureOpenAIError exception class
if name == "AzureOpenAIError":
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
# Check if already cached
if "AzureOpenAIError" not in _globals:
from .llms.azure.common_utils import AzureOpenAIError as _AzureOpenAIError
@@ -2188,9 +2188,9 @@ def __getattr__(name: str) -> Any:
# Lazy load openaiOSeriesConfig instance
if name == "openaiOSeriesConfig":
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
if "openaiOSeriesConfig" not in _globals:
# Import the config class and instantiate it
config_class = __getattr__("OpenAIOSeriesConfig")
@@ -2206,9 +2206,9 @@ def __getattr__(name: str) -> Any:
"nvidiaNimEmbeddingConfig": "NvidiaNimEmbeddingConfig",
}
if name in _config_instances:
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
if name not in _globals:
# Import the config class and instantiate it
config_class = __getattr__(_config_instances[name])
@@ -2221,9 +2221,9 @@ def __getattr__(name: str) -> Any:
# Lazy load provider_list
if name == "provider_list":
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
# Check if already cached
if "provider_list" not in _globals:
# LlmProviders is eagerly imported above, so we can import it directly
@@ -2234,9 +2234,9 @@ def __getattr__(name: str) -> Any:
# Lazy load priority_reservation_settings instance
if name == "priority_reservation_settings":
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
# Check if already cached
if "priority_reservation_settings" not in _globals:
# Import the class and instantiate it
@@ -2246,9 +2246,9 @@ def __getattr__(name: str) -> Any:
# Lazy load logging_callback_manager instance
if name == "logging_callback_manager":
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
# Check if already cached
if "logging_callback_manager" not in _globals:
# Import the class and instantiate it
@@ -2258,9 +2258,9 @@ def __getattr__(name: str) -> Any:
# Lazy load _service_logger module
if name == "_service_logger":
- from ._lazy_imports import _get_litellm_globals
+ from ._lazy_imports import get_litellm_globals
- _globals = _get_litellm_globals()
+ _globals = get_litellm_globals()
# Check if already cached
if "_service_logger" not in _globals:
# Import the module lazily
diff --git a/litellm/_lazy_imports.py b/litellm/_lazy_imports.py
index 63142ee4f2f..933464d3f23 100644
--- a/litellm/_lazy_imports.py
+++ b/litellm/_lazy_imports.py
@@ -54,7 +54,7 @@ from ._lazy_imports_registry import (
)
-def _get_litellm_globals() -> dict:
+def get_litellm_globals() -> dict:
"""
Get the globals dictionary of the litellm module.
@@ -233,7 +233,7 @@ def _generic_lazy_import(name: str, import_map: dict[str, tuple[str, str]], cate
raise AttributeError(f"{category} lazy import: unknown attribute {name!r}")
# Step 2: Get the cache (where we store imported things)
- _globals: Final = _get_litellm_globals()
+ _globals: Final = get_litellm_globals()
# Step 3: If we've already imported it, just return the cached version
if name in _globals:
@@ -332,7 +332,7 @@ def _lazy_import_utils_module(name: str) -> Any:
Handler for utils module lazy imports.
This uses a custom implementation because utils module needs to use
- _get_utils_globals() instead of _get_litellm_globals() for caching.
+ _get_utils_globals() instead of get_litellm_globals() for caching.
"""
# Check if this attribute exists in our map
if name not in _UTILS_MODULE_IMPORT_MAP:
@@ -379,7 +379,7 @@ def _lazy_import_llm_client_cache(name: str) -> Any:
- "in_memory_llm_clients_cache" is a singleton instance of that class
So we need custom logic to handle both cases.
"""
- _globals: Final = _get_litellm_globals()
+ _globals: Final = get_litellm_globals()
# If already cached, return it
if name in _globals:
@@ -412,7 +412,7 @@ def _lazy_import_http_handlers(name: str) -> Any:
- They need configuration (timeout, etc.) from the module globals
- They use factory functions instead of direct instantiation
"""
- _globals: Final = _get_litellm_globals()
+ _globals: Final = get_litellm_globals()
if name == "module_level_aclient":
# Create an async HTTP client using the factory function
diff --git a/litellm/litellm_core_utils/audio_utils/utils.py b/litellm/litellm_core_utils/audio_utils/utils.py
index 0f9addb16f7..3b3775a8fe6 100644
--- a/litellm/litellm_core_utils/audio_utils/utils.py
+++ b/litellm/litellm_core_utils/audio_utils/utils.py
@@ -180,6 +180,7 @@ def get_audio_file_content_hash(file_obj: FileTypes) -> str:
if isinstance(file_obj, tuple):
if len(file_obj) < 2:
fallback_filename = str(file_obj[0]) if len(file_obj) > 0 else None
+ file_content_obj = None
else:
fallback_filename = str(file_obj[0]) if file_obj[0] is not None else None
file_content_obj = file_obj[1]
@@ -206,7 +207,7 @@ def get_audio_file_content_hash(file_obj: FileTypes) -> str:
except OSError:
fallback_filename = str(file_content_obj)
file_content = None
- elif hasattr(file_content_obj, "read"):
+ elif file_content_obj is not None and hasattr(file_content_obj, "read"):
try:
current_position: Final = file_content_obj.tell() if hasattr(file_content_obj, "tell") else None
if hasattr(file_content_obj, "seek"):
diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py
index d51d31eaa3b..3a1a426eaa9 100644
--- a/litellm/litellm_core_utils/prompt_templates/factory.py
+++ b/litellm/litellm_core_utils/prompt_templates/factory.py
@@ -3684,7 +3684,7 @@ def _convert_to_bedrock_tool_call_invoke(
# cache_control applies to the whole original
# tool call; attach after the last split block.
if tool.get("cache_control", None) is not None:
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
{"cache_control": tool["cache_control"]},
block_type="content_block",
model=model,
@@ -3701,7 +3701,7 @@ def _convert_to_bedrock_tool_call_invoke(
# Check for cache_control and add a separate cachePoint block
if tool.get("cache_control", None) is not None:
- cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
{"cache_control": tool["cache_control"]},
block_type="content_block",
model=model,
@@ -4360,7 +4360,7 @@ class BedrockConverseMessagesProcessor:
elif element["type"] == "document":
_part = BedrockConverseMessagesProcessor._process_document_message(element)
_parts.append(_part)
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
message_block=cast(OpenAIMessageContentListBlock, element),
block_type="content_block",
model=model,
@@ -4370,7 +4370,7 @@ class BedrockConverseMessagesProcessor:
user_content.extend(_parts)
elif message_block["content"] and isinstance(message_block["content"], str):
_part = BedrockContentBlock(text=messages[msg_i]["content"])
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
message_block, block_type="content_block", model=model
)
user_content.append(_part)
@@ -4417,7 +4417,7 @@ class BedrockConverseMessagesProcessor:
# Add a separate cachePoint block if cache_control is present
if tool_msg_cache_control is not None:
- cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
{"cache_control": tool_msg_cache_control},
block_type="content_block",
model=model,
@@ -4496,7 +4496,7 @@ class BedrockConverseMessagesProcessor:
assistants_part = await BedrockImageProcessor.process_image_async(image_url=image_url)
assistants_parts.append(assistants_part)
# Add cache point block for assistant content elements
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
message_block=cast(OpenAIMessageContentListBlock, element),
block_type="content_block",
model=model,
@@ -4510,7 +4510,7 @@ class BedrockConverseMessagesProcessor:
assistant_content.append(BedrockContentBlock(text=_assistant_content))
# If content is empty/whitespace, skip it (don't add a placeholder)
# Add cache point block for assistant string content
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
assistant_message_block, block_type="content_block", model=model
)
if _cache_point_block is not None:
@@ -4733,7 +4733,7 @@ def _bedrock_converse_messages_pt(
elif element["type"] == "document":
_part = BedrockConverseMessagesProcessor._process_document_message(element)
_parts.append(_part)
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
message_block=cast(OpenAIMessageContentListBlock, element),
block_type="content_block",
model=model,
@@ -4743,7 +4743,7 @@ def _bedrock_converse_messages_pt(
user_content.extend(_parts)
elif message_block["content"] and isinstance(message_block["content"], str):
_part = BedrockContentBlock(text=messages[msg_i]["content"])
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
message_block, block_type="content_block", model=model
)
user_content.append(_part)
@@ -4792,7 +4792,7 @@ def _bedrock_converse_messages_pt(
# Add a separate cachePoint block if cache_control is present
if tool_msg_cache_control is not None:
- cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
{"cache_control": tool_msg_cache_control},
block_type="content_block",
model=model,
@@ -4874,7 +4874,7 @@ def _bedrock_converse_messages_pt(
assistants_part = BedrockImageProcessor.process_image_sync(image_url=image_url)
assistants_parts.append(assistants_part)
# Add cache point block for assistant content elements
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
message_block=cast(OpenAIMessageContentListBlock, element),
block_type="content_block",
model=model,
@@ -4887,7 +4887,7 @@ def _bedrock_converse_messages_pt(
if _assistant_content.strip():
assistant_content.append(BedrockContentBlock(text=_assistant_content))
# Add cache point block for assistant string content
- _cache_point_block = litellm.AmazonConverseConfig()._get_cache_point_block(
+ _cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
assistant_message_block, block_type="content_block", model=model
)
if _cache_point_block is not None:
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py
index 0b1689b8ee4..193987a3543 100644
--- a/litellm/llms/bedrock/chat/converse_transformation.py
+++ b/litellm/llms/bedrock/chat/converse_transformation.py
@@ -1081,7 +1081,7 @@ class AmazonConverseConfig(BaseConfig):
optional_params["maxTokens"] = thinking_token_budget + DEFAULT_MAX_TOKENS
@overload
- def _get_cache_point_block(
+ def get_cache_point_block(
self,
message_block: OpenAIMessageContentListBlock
| ChatCompletionUserMessage
@@ -1093,7 +1093,7 @@ class AmazonConverseConfig(BaseConfig):
pass
@overload
- def _get_cache_point_block(
+ def get_cache_point_block(
self,
message_block: OpenAIMessageContentListBlock
| ChatCompletionUserMessage
@@ -1104,7 +1104,7 @@ class AmazonConverseConfig(BaseConfig):
) -> ContentBlock | None:
pass
- def _get_cache_point_block(
+ def get_cache_point_block(
self,
message_block: OpenAIMessageContentListBlock
| ChatCompletionUserMessage
@@ -1149,14 +1149,14 @@ class AmazonConverseConfig(BaseConfig):
system_prompt_indices.append(idx)
if isinstance(message["content"], str) and message["content"]:
system_content_blocks.append(SystemContentBlock(text=message["content"]))
- cache_block = self._get_cache_point_block(message, block_type="system", model=model)
+ cache_block = self.get_cache_point_block(message, block_type="system", model=model)
if cache_block:
system_content_blocks.append(cache_block)
elif isinstance(message["content"], list):
for m in message["content"]:
if m.get("type") == "text" and m.get("text"):
system_content_blocks.append(SystemContentBlock(text=m["text"]))
- cache_block = self._get_cache_point_block(m, block_type="system", model=model)
+ cache_block = self.get_cache_point_block(m, block_type="system", model=model)
if cache_block:
system_content_blocks.append(cache_block)
if len(system_prompt_indices) > 0:
diff --git a/litellm/llms/xai/oauth.py b/litellm/llms/xai/oauth.py
index 8f303e9585f..37dae93a725 100644
--- a/litellm/llms/xai/oauth.py
+++ b/litellm/llms/xai/oauth.py
@@ -40,7 +40,7 @@ class XAIOAuthLoginRequiredError(XAIOAuthError):
class _CallbackHandler(BaseHTTPRequestHandler):
- server: "_CallbackServer"
+ server: "_CallbackServer" # pyright: ignore[reportIncompatibleVariableOverride] # stdlib stubs type server as BaseServer; _CallbackServer is the only server this handler is registered on
def do_GET(self) -> None:
parsed: Final = urlparse(self.path)
diff --git a/litellm/proxy/_experimental/mcp_server/elicitation_handler.py b/litellm/proxy/_experimental/mcp_server/elicitation_handler.py
index 66c262a6eb9..ce7e963f55f 100644
--- a/litellm/proxy/_experimental/mcp_server/elicitation_handler.py
+++ b/litellm/proxy/_experimental/mcp_server/elicitation_handler.py
@@ -9,10 +9,19 @@ MCP Spec Reference:
https://modelcontextprotocol.io/specification/2025-11-25/client/elicitation
"""
-from typing import Any, Final, Union
+from typing import TYPE_CHECKING, Any, Final, Union
from litellm._logging import verbose_logger
+if TYPE_CHECKING:
+ from mcp.types import (
+ ElicitRequestFormParams,
+ ElicitRequestParams,
+ ElicitRequestURLParams,
+ ElicitResult,
+ ErrorData,
+ )
+
# Guard imports that require the mcp package
try:
from mcp.types import (
diff --git a/litellm/proxy/_experimental/mcp_server/sampling_handler.py b/litellm/proxy/_experimental/mcp_server/sampling_handler.py
index 45490385df8..0f5c02bd781 100644
--- a/litellm/proxy/_experimental/mcp_server/sampling_handler.py
+++ b/litellm/proxy/_experimental/mcp_server/sampling_handler.py
@@ -18,7 +18,15 @@ if typing.TYPE_CHECKING:
from fastapi import Request
from mcp.client.session import ClientSession
from mcp.shared.context import RequestContext
- from mcp.types import ContentBlock, SamplingMessageContentBlock
+ from mcp.types import (
+ ContentBlock,
+ CreateMessageResult,
+ CreateMessageResultWithTools,
+ ErrorData,
+ SamplingMessageContentBlock,
+ TextContent,
+ ToolUseContent,
+ )
from litellm.proxy._types import UserAPIKeyAuth
from litellm.proxy.utils import ProxyLogging
diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py
index f2267bbcf7f..ef7bfd4b4f6 100644
--- a/litellm/proxy/_experimental/mcp_server/server.py
+++ b/litellm/proxy/_experimental/mcp_server/server.py
@@ -79,6 +79,8 @@ from litellm.types.utils import CallTypes, StandardLoggingMCPToolCall
from litellm.utils import Rules, client, function_setup
if TYPE_CHECKING:
+ from mcp.server.session import ServerSession as _McpServerSession
+
from litellm.proxy._experimental.mcp_server.db import OAuthCredentialPayload
# Short-lived in-memory cache for BYOK credentials.
@@ -144,10 +146,6 @@ try:
# Robust auth lookup keyed by session_object.
_session_obj_auth_storage: "weakref.WeakKeyDictionary[Any, MCPAuthenticatedUser]" = weakref.WeakKeyDictionary()
-
- active_mcp_session_var: Final[contextvars.ContextVar[_McpServerSession | None]] = contextvars.ContextVar(
- "active_mcp_session", default=None
- )
except ImportError as e:
verbose_logger.debug("MCP module not found: %s", e)
MCP_AVAILABLE = False
@@ -163,6 +161,10 @@ except ImportError as e:
Server = None
TextResourceContents = None
+active_mcp_session_var: Final[contextvars.ContextVar["_McpServerSession | None"]] = contextvars.ContextVar(
+ "active_mcp_session", default=None
+)
+
# Global variables to track initialization
_SESSION_MANAGERS_INITIALIZED = False
diff --git a/litellm/proxy/example_config_yaml/custom_guardrail.py b/litellm/proxy/example_config_yaml/custom_guardrail.py
index 2f53bb4675a..979976ddfc4 100644
--- a/litellm/proxy/example_config_yaml/custom_guardrail.py
+++ b/litellm/proxy/example_config_yaml/custom_guardrail.py
@@ -1,11 +1,10 @@
-from typing import Any, Dict, Final, List, Literal, Optional, Union
+from typing import Dict, Final, Optional, Union
import litellm
from litellm._logging import verbose_proxy_logger
from litellm.caching.caching import DualCache
from litellm.integrations.custom_guardrail import CustomGuardrail
from litellm.proxy._types import UserAPIKeyAuth
-from litellm.proxy.guardrails.guardrail_helpers import should_proceed_based_on_metadata
from litellm.types.utils import CallTypesLiteral
# Global counter for tracking which guardrail was called (for load balancing tests)
diff --git a/litellm/proxy/example_config_yaml/custom_handler.py b/litellm/proxy/example_config_yaml/custom_handler.py
index 3bf998c726a..c0483dd3304 100644
--- a/litellm/proxy/example_config_yaml/custom_handler.py
+++ b/litellm/proxy/example_config_yaml/custom_handler.py
@@ -1,9 +1,7 @@
-import time
-from typing import Any, Final, Optional
+from typing import Final
import litellm
-from litellm import CustomLLM, ImageObject, ImageResponse, completion, get_llm_provider
-from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
+from litellm import CustomLLM
from litellm.types.utils import ModelResponse
diff --git a/litellm/types/adapter.py b/litellm/types/adapter.py
index 2995cfbc1c2..924fabcb86d 100644
--- a/litellm/types/adapter.py
+++ b/litellm/types/adapter.py
@@ -1,6 +1,4 @@
-from typing import List
-
-from typing_extensions import Dict, Required, TypedDict, override
+from typing_extensions import TypedDict
from litellm.integrations.custom_logger import CustomLogger
diff --git a/litellm/types/google_genai/main.py b/litellm/types/google_genai/main.py
index 467db318057..876a4d4533e 100644
--- a/litellm/types/google_genai/main.py
+++ b/litellm/types/google_genai/main.py
@@ -1,8 +1,6 @@
# Import types from the Google GenAI SDK
-from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypeAlias
+from typing import TYPE_CHECKING, Any, Dict, Optional
-from pydantic import BaseModel
-from typing_extensions import TypedDict
from litellm.types.llms.openai import BaseLiteLLMOpenAIResponseObject
diff --git a/litellm/types/integrations/argilla.py b/litellm/types/integrations/argilla.py
index 52dad347304..2def010a722 100644
--- a/litellm/types/integrations/argilla.py
+++ b/litellm/types/integrations/argilla.py
@@ -1,7 +1,4 @@
-import os
-from datetime import datetime as dt
-from enum import Enum
-from typing import Any, Dict, Final, List, Literal, Optional, Set
+from typing import Any, Dict, Final, List
from typing_extensions import TypedDict
diff --git a/litellm/types/llms/anthropic_skills.py b/litellm/types/llms/anthropic_skills.py
index 22257888493..0659b499bcc 100644
--- a/litellm/types/llms/anthropic_skills.py
+++ b/litellm/types/llms/anthropic_skills.py
@@ -2,10 +2,10 @@
Type definitions for Anthropic Skills API
"""
-from typing import Any, Dict, List, Literal, Optional, Union
+from typing import Any, Dict, List, Optional
-from pydantic import BaseModel, Field
-from typing_extensions import Required, TypedDict
+from pydantic import BaseModel
+from typing_extensions import TypedDict
# Skills API Request Types
diff --git a/litellm/types/llms/azure_ai.py b/litellm/types/llms/azure_ai.py
index ddc9dbe3c55..49b7349c67e 100644
--- a/litellm/types/llms/azure_ai.py
+++ b/litellm/types/llms/azure_ai.py
@@ -1,4 +1,4 @@
-from typing import Any, Dict, Final, Iterable, List, Literal, Optional, Union
+from typing import List, Literal
from typing_extensions import Required, TypedDict
diff --git a/litellm/types/llms/custom_llm.py b/litellm/types/llms/custom_llm.py
index d5499a41944..e57a7a28007 100644
--- a/litellm/types/llms/custom_llm.py
+++ b/litellm/types/llms/custom_llm.py
@@ -1,6 +1,4 @@
-from typing import List
-
-from typing_extensions import Dict, Required, TypedDict, override
+from typing_extensions import TypedDict
from litellm.llms.custom_llm import CustomLLM
diff --git a/litellm/types/llms/databricks.py b/litellm/types/llms/databricks.py
index 46f988ae4a0..c2bd0aa92bd 100644
--- a/litellm/types/llms/databricks.py
+++ b/litellm/types/llms/databricks.py
@@ -1,19 +1,12 @@
-import json
-from typing import Any, Dict, Final, List, Literal, Optional, Union
+from typing import Any, Dict, List, Literal, Optional, Union
from pydantic import BaseModel
from typing_extensions import (
- Protocol,
Required,
- Self,
TypedDict,
- TypeGuard,
- get_origin,
- override,
- runtime_checkable,
)
-from .openai import ChatCompletionToolCallChunk, ChatCompletionUsageBlock
+from .openai import ChatCompletionUsageBlock
class GenericStreamingChunk(TypedDict, total=False):
diff --git a/litellm/types/llms/ollama.py b/litellm/types/llms/ollama.py
index ca28120dd9d..9fcb6b755bd 100644
--- a/litellm/types/llms/ollama.py
+++ b/litellm/types/llms/ollama.py
@@ -1,16 +1,8 @@
-import json
-from typing import Any, List, Optional, Union
+from typing import List
-from pydantic import BaseModel
from typing_extensions import (
- Protocol,
Required,
- Self,
TypedDict,
- TypeGuard,
- get_origin,
- override,
- runtime_checkable,
)
diff --git a/litellm/types/llms/openrouter.py b/litellm/types/llms/openrouter.py
index 39ed7e104fb..73bf647d4ea 100644
--- a/litellm/types/llms/openrouter.py
+++ b/litellm/types/llms/openrouter.py
@@ -1,6 +1,4 @@
-import json
-from enum import Enum
-from typing import Any, Dict, List, Literal, Optional, Tuple, Union
+from typing import Dict
from typing_extensions import TypedDict
diff --git a/litellm/types/llms/rerank.py b/litellm/types/llms/rerank.py
index fac093161c1..83cdb1caa0b 100644
--- a/litellm/types/llms/rerank.py
+++ b/litellm/types/llms/rerank.py
@@ -1,16 +1,7 @@
-import json
-from enum import Enum
-from typing import Any, Dict, List, Literal, Optional, Tuple, Union
+from typing import Optional
from typing_extensions import (
- Protocol,
- Required,
- Self,
TypedDict,
- TypeGuard,
- get_origin,
- override,
- runtime_checkable,
)
diff --git a/litellm/types/proxy/management_endpoints/internal_user_endpoints.py b/litellm/types/proxy/management_endpoints/internal_user_endpoints.py
index faf2660a6f8..16f4c45e2f4 100644
--- a/litellm/types/proxy/management_endpoints/internal_user_endpoints.py
+++ b/litellm/types/proxy/management_endpoints/internal_user_endpoints.py
@@ -1,7 +1,6 @@
-from typing import Any, Dict, Final, List, Literal, Optional, Union
+from typing import Any, Dict, Final, List, Optional
-from fastapi import HTTPException
-from pydantic import BaseModel, EmailStr, field_validator
+from pydantic import BaseModel, field_validator
from litellm.proxy._types import (
LiteLLM_UserTableWithKeyCount,