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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(imports): move collections.abc names out of typing and ratchet the lint budgets
mateo-berri397e8e491877
diff --git a/litellm/_lazy_imports.py b/litellm/_lazy_imports.pyindex b04fae86e47..9f7b26da7cd 100644--- a/litellm/_lazy_imports.py+++ b/litellm/_lazy_imports.py@@ -17,39 +17,40 @@ until they're actually needed.import importlibimport sys-from typing import Any, Optional, cast, Callable+from collections.abc import Callable+from typing import Any, Optional, cast# Import all the data structures that define what can be lazy-loaded# These are just lists of names and maps of where to find themfrom ._lazy_imports_registry import (+ _BEDROCK_TYPES_IMPORT_MAP,+ _CACHING_IMPORT_MAP,+ _COST_CALCULATOR_IMPORT_MAP,+ _DOTPROMPT_IMPORT_MAP,+ _LITELLM_LOGGING_IMPORT_MAP,+ _LLM_CONFIGS_IMPORT_MAP,+ _LLM_PROVIDER_LOGIC_IMPORT_MAP,+ _TOKEN_COUNTER_IMPORT_MAP,+ _TYPES_IMPORT_MAP,+ _TYPES_UTILS_IMPORT_MAP,+ # Import maps+ _UTILS_IMPORT_MAP,+ _UTILS_MODULE_IMPORT_MAP,+ BEDROCK_TYPES_NAMES,+ CACHING_NAMES,# Name tuplesCOST_CALCULATOR_NAMES,+ DOTPROMPT_NAMES,+ HTTP_HANDLER_NAMES,LITELLM_LOGGING_NAMES,- UTILS_NAMES,- TOKEN_COUNTER_NAMES,LLM_CLIENT_CACHE_NAMES,- BEDROCK_TYPES_NAMES,- TYPES_UTILS_NAMES,- CACHING_NAMES,- HTTP_HANDLER_NAMES,- DOTPROMPT_NAMES,LLM_CONFIG_NAMES,- TYPES_NAMES,LLM_PROVIDER_LOGIC_NAMES,+ TOKEN_COUNTER_NAMES,+ TYPES_NAMES,+ TYPES_UTILS_NAMES,UTILS_MODULE_NAMES,- # Import maps- _UTILS_IMPORT_MAP,- _COST_CALCULATOR_IMPORT_MAP,- _TYPES_UTILS_IMPORT_MAP,- _TOKEN_COUNTER_IMPORT_MAP,- _BEDROCK_TYPES_IMPORT_MAP,- _CACHING_IMPORT_MAP,- _LITELLM_LOGGING_IMPORT_MAP,- _DOTPROMPT_IMPORT_MAP,- _TYPES_IMPORT_MAP,- _LLM_CONFIGS_IMPORT_MAP,- _LLM_PROVIDER_LOGIC_IMPORT_MAP,- _UTILS_MODULE_IMPORT_MAP,+ UTILS_NAMES,)diff --git a/litellm/_redis.py b/litellm/_redis.pyindex 9e3b247f577..2728d45e0f3 100644--- a/litellm/_redis.py+++ b/litellm/_redis.py@@ -12,7 +12,8 @@ import json# s/o [@Frank Colson](https://www.linkedin.com/in/frank-colson-422b9b183/) for this redis implementationimport os-from typing import Callable, List, Optional, Union+from collections.abc import Callable+from typing import List, Optional, Unionimport redis # type: ignoreimport redis.asyncio as async_redis # type: ignorediff --git a/litellm/a2a_protocol/client.py b/litellm/a2a_protocol/client.pyindex a05f8dc390c..a8ee24f0c09 100644--- a/litellm/a2a_protocol/client.py+++ b/litellm/a2a_protocol/client.py@@ -4,7 +4,8 @@ LiteLLM A2A Client class.Provides a class-based interface for A2A agent invocation."""-from typing import TYPE_CHECKING, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import TYPE_CHECKING, Dict, Optionalfrom litellm.types.agents import LiteLLMSendMessageResponsediff --git a/litellm/a2a_protocol/litellm_completion_bridge/handler.py b/litellm/a2a_protocol/litellm_completion_bridge/handler.pyindex a84b23a2170..94d4bb5d899 100644--- a/litellm/a2a_protocol/litellm_completion_bridge/handler.py+++ b/litellm/a2a_protocol/litellm_completion_bridge/handler.py@@ -10,7 +10,8 @@ A2A Streaming Events (in order):4. Status update (kind: "status-update") - Final status "completed" with final=true"""-from typing import Any, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import Any, Dict, Optionalimport litellmfrom litellm._logging import verbose_loggerdiff --git a/litellm/a2a_protocol/main.py b/litellm/a2a_protocol/main.pyindex f04edf2579b..a2985f2c325 100644--- a/litellm/a2a_protocol/main.py+++ b/litellm/a2a_protocol/main.py@@ -12,11 +12,10 @@ Provides standalone functions with @client decorator for LiteLLM logging integraimport asyncioimport datetimeimport uuid+from collections.abc import AsyncIterator, Coroutinefrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Coroutine,Dict,Optional,Union,diff --git a/litellm/a2a_protocol/providers/base.py b/litellm/a2a_protocol/providers/base.pyindex 3ac1cb47fc8..f546bb0c501 100644--- a/litellm/a2a_protocol/providers/base.py+++ b/litellm/a2a_protocol/providers/base.py@@ -3,7 +3,8 @@ Base configuration for A2A protocol providers."""from abc import ABC, abstractmethod-from typing import Any, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import Any, Dict, Optionalclass BaseA2AProviderConfig(ABC):diff --git a/litellm/a2a_protocol/providers/bedrock_agentcore/config.py b/litellm/a2a_protocol/providers/bedrock_agentcore/config.pyindex f624aa393ed..d22379916e9 100644--- a/litellm/a2a_protocol/providers/bedrock_agentcore/config.py+++ b/litellm/a2a_protocol/providers/bedrock_agentcore/config.py@@ -2,7 +2,8 @@Bedrock AgentCore A2A provider configuration."""-from typing import Any, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import Any, Dict, Optionalfrom litellm.a2a_protocol.providers.base import BaseA2AProviderConfigfrom litellm.a2a_protocol.providers.bedrock_agentcore.handler import (diff --git a/litellm/a2a_protocol/providers/bedrock_agentcore/handler.py b/litellm/a2a_protocol/providers/bedrock_agentcore/handler.pyindex c613b68668f..5cbbdc62f4d 100644--- a/litellm/a2a_protocol/providers/bedrock_agentcore/handler.py+++ b/litellm/a2a_protocol/providers/bedrock_agentcore/handler.py@@ -6,7 +6,8 @@ completion bridge that would otherwise strip the envelope."""import json-from typing import Any, AsyncIterator, Dict, Optional, cast+from collections.abc import AsyncIterator+from typing import Any, Dict, Optional, castfrom litellm._logging import verbose_loggerfrom litellm.a2a_protocol.providers.bedrock_agentcore.transformation import (diff --git a/litellm/a2a_protocol/providers/bedrock_agentcore/transformation.py b/litellm/a2a_protocol/providers/bedrock_agentcore/transformation.pyindex 091a13ccea5..3aef69ca775 100644--- a/litellm/a2a_protocol/providers/bedrock_agentcore/transformation.py+++ b/litellm/a2a_protocol/providers/bedrock_agentcore/transformation.py@@ -6,7 +6,8 @@ and signs requests via AmazonAgentCoreConfig (SigV4 or JWT)."""import json-from typing import Any, AsyncIterator, Dict, Mapping, Optional, Tuple+from collections.abc import AsyncIterator, Mapping+from typing import Any, Dict, Optional, Tuplefrom litellm._logging import verbose_loggerfrom litellm.llms.bedrock.chat.agentcore.transformation import AmazonAgentCoreConfigdiff --git a/litellm/a2a_protocol/providers/langflow/config.py b/litellm/a2a_protocol/providers/langflow/config.pyindex 9edaf151c71..179b201cb44 100644--- a/litellm/a2a_protocol/providers/langflow/config.py+++ b/litellm/a2a_protocol/providers/langflow/config.py@@ -1,4 +1,5 @@-from typing import Any, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import Any, Dict, Optionalfrom litellm.a2a_protocol.litellm_completion_bridge.handler import (A2A_USER_API_KEY_HASH_PARAM,diff --git a/litellm/a2a_protocol/providers/pydantic_ai_agents/config.py b/litellm/a2a_protocol/providers/pydantic_ai_agents/config.pyindex 6f067aecd2b..dabf1e387a3 100644--- a/litellm/a2a_protocol/providers/pydantic_ai_agents/config.py+++ b/litellm/a2a_protocol/providers/pydantic_ai_agents/config.py@@ -2,7 +2,8 @@Pydantic AI provider configuration."""-from typing import Any, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import Any, Dict, Optionalfrom litellm.a2a_protocol.providers.base import BaseA2AProviderConfigfrom litellm.a2a_protocol.providers.pydantic_ai_agents.handler import PydanticAIHandlerdiff --git a/litellm/a2a_protocol/providers/pydantic_ai_agents/handler.py b/litellm/a2a_protocol/providers/pydantic_ai_agents/handler.pyindex 352005ff549..d9b060c2640 100644--- a/litellm/a2a_protocol/providers/pydantic_ai_agents/handler.py+++ b/litellm/a2a_protocol/providers/pydantic_ai_agents/handler.py@@ -5,7 +5,8 @@ Pydantic AI agents follow A2A protocol but don't support streaming natively.This handler provides fake streaming by converting non-streaming responses into streaming chunks."""-from typing import Any, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import Any, Dict, Optionalfrom litellm._logging import verbose_loggerfrom litellm.a2a_protocol.providers.pydantic_ai_agents.transformation import (diff --git a/litellm/a2a_protocol/providers/pydantic_ai_agents/transformation.py b/litellm/a2a_protocol/providers/pydantic_ai_agents/transformation.pyindex b9943d83c8a..632428d5a9c 100644--- a/litellm/a2a_protocol/providers/pydantic_ai_agents/transformation.py+++ b/litellm/a2a_protocol/providers/pydantic_ai_agents/transformation.py@@ -6,7 +6,8 @@ This module provides fake streaming by converting non-streaming responses into s"""import asyncio-from typing import Any, AsyncIterator, Dict, Optional, cast+from collections.abc import AsyncIterator+from typing import Any, Dict, Optional, castfrom uuid import uuid4from litellm._logging import verbose_loggerdiff --git a/litellm/a2a_protocol/providers/watsonx_orchestrate/config.py b/litellm/a2a_protocol/providers/watsonx_orchestrate/config.pyindex dbd4a0558f7..093b1f0c7d4 100644--- a/litellm/a2a_protocol/providers/watsonx_orchestrate/config.py+++ b/litellm/a2a_protocol/providers/watsonx_orchestrate/config.py@@ -2,7 +2,8 @@A2A provider configuration for IBM watsonx Orchestrate (WXO)."""-from typing import Any, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import Any, Dict, Optionalfrom litellm.a2a_protocol.providers.base import BaseA2AProviderConfigfrom litellm.a2a_protocol.providers.watsonx_orchestrate.handler import (diff --git a/litellm/a2a_protocol/providers/watsonx_orchestrate/handler.py b/litellm/a2a_protocol/providers/watsonx_orchestrate/handler.pyindex 07235c1118c..31a042907f2 100644--- a/litellm/a2a_protocol/providers/watsonx_orchestrate/handler.py+++ b/litellm/a2a_protocol/providers/watsonx_orchestrate/handler.py@@ -6,7 +6,8 @@ import asyncioimport hashlibimport jsonimport time-from typing import Any, AsyncIterator, Dict, NamedTuple, Optional, Tuple, cast+from collections.abc import AsyncIterator+from typing import Any, Dict, NamedTuple, Optional, Tuple, castimport httpxdiff --git a/litellm/a2a_protocol/providers/watsonx_orchestrate/transformation.py b/litellm/a2a_protocol/providers/watsonx_orchestrate/transformation.pyindex c9bda822aae..e945c721f52 100644--- a/litellm/a2a_protocol/providers/watsonx_orchestrate/transformation.py+++ b/litellm/a2a_protocol/providers/watsonx_orchestrate/transformation.py@@ -8,7 +8,8 @@ WXO uses a REST API (not A2A/JSON-RPC) with an async-poll execution model:"""import asyncio-from typing import Any, AsyncIterator, Dict, Optional+from collections.abc import AsyncIterator+from typing import Any, Dict, Optionalfrom uuid import uuid4from litellm._logging import verbose_loggerdiff --git a/litellm/a2a_protocol/streaming_iterator.py b/litellm/a2a_protocol/streaming_iterator.pyindex 1ef174a5eee..2885d9b2fb0 100644--- a/litellm/a2a_protocol/streaming_iterator.py+++ b/litellm/a2a_protocol/streaming_iterator.py@@ -3,8 +3,9 @@ A2A Streaming Iterator with token tracking and logging support."""import asyncio+from collections.abc import AsyncIteratorfrom datetime import datetime-from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, List, Optional+from typing import TYPE_CHECKING, Any, Dict, List, Optionalimport litellmfrom litellm._logging import verbose_loggerdiff --git a/litellm/anthropic_interface/exceptions/exceptions.py b/litellm/anthropic_interface/exceptions/exceptions.pyindex b289e493e6b..ae333d1f4ad 100644--- a/litellm/anthropic_interface/exceptions/exceptions.py+++ b/litellm/anthropic_interface/exceptions/exceptions.py@@ -1,6 +1,8 @@"""Anthropic error format type definitions."""-from typing_extensions import Literal, Required, TypedDict+from typing import Literal++from typing_extensions import Required, TypedDict# Known Anthropic error types# Source: https://docs.anthropic.com/en/api/errorsdiff --git a/litellm/anthropic_interface/messages/__init__.py b/litellm/anthropic_interface/messages/__init__.pyindex 52c9ecd5aa4..8fb9a9d1d04 100644--- a/litellm/anthropic_interface/messages/__init__.py+++ b/litellm/anthropic_interface/messages/__init__.py@@ -10,7 +10,8 @@ This is an __init__.py file to allow the following interface"""-from typing import Any, AsyncIterator, Coroutine, Dict, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Coroutine, Iterator+from typing import Any, Dict, List, Optional, Unionfrom litellm.llms.anthropic.experimental_pass_through.messages.handler import (anthropic_messages as _async_anthropic_messages,diff --git a/litellm/assistants/main.py b/litellm/assistants/main.pyindex d515cb278bc..7219f4385d1 100644--- a/litellm/assistants/main.py+++ b/litellm/assistants/main.py@@ -3,8 +3,9 @@import asyncioimport contextvarsimport os+from collections.abc import Coroutine, Iterablefrom functools import partial-from typing import Any, Coroutine, Dict, Iterable, List, Literal, Optional, Union+from typing import Any, Dict, List, Literal, Optional, Unionimport httpxfrom openai import AsyncOpenAI, OpenAIdiff --git a/litellm/batches/batch_utils.py b/litellm/batches/batch_utils.pyindex eef4cf8d87f..8303ec75393 100644--- a/litellm/batches/batch_utils.py+++ b/litellm/batches/batch_utils.py@@ -1,6 +1,7 @@import json+from collections.abc import Iterable, Iteratorfrom dataclasses import dataclass-from typing import Any, Iterable, Iterator, List, Literal, Optional, Tuple+from typing import Any, List, Literal, Optional, Tupleimport litellmfrom litellm._logging import verbose_loggerdiff --git a/litellm/batches/main.py b/litellm/batches/main.pyindex 3a2d9e13f77..9db2b0c2b5f 100644--- a/litellm/batches/main.py+++ b/litellm/batches/main.py@@ -13,8 +13,9 @@ https://platform.openai.com/docs/api-reference/batchimport asyncioimport contextvarsimport os+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, Literal, Optional, Union, cast+from typing import Any, Dict, Literal, Optional, Union, castimport httpxfrom openai.types.batch import BatchRequestCountsdiff --git a/litellm/caching/_internal_lru_cache.py b/litellm/caching/_internal_lru_cache.pyindex 54b0fe9690c..c5285b1dfba 100644--- a/litellm/caching/_internal_lru_cache.py+++ b/litellm/caching/_internal_lru_cache.py@@ -1,5 +1,6 @@+from collections.abc import Callablefrom functools import lru_cache-from typing import Callable, Optional, TypeVar+from typing import Optional, TypeVarT = TypeVar("T")diff --git a/litellm/caching/caching_handler.py b/litellm/caching/caching_handler.pyindex d8a2d2d76b7..c547b7aff61 100644--- a/litellm/caching/caching_handler.py+++ b/litellm/caching/caching_handler.py@@ -18,13 +18,11 @@ import asyncioimport datetimeimport inspectimport time+from collections.abc import AsyncGenerator, Callable, Generatorfrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,- Callable,Dict,- Generator,List,Optional,Tuple,diff --git a/litellm/completion_extras/litellm_responses_transformation/handler.py b/litellm/completion_extras/litellm_responses_transformation/handler.pyindex 15f5b28e30e..1b69154bf3d 100644--- a/litellm/completion_extras/litellm_responses_transformation/handler.py+++ b/litellm/completion_extras/litellm_responses_transformation/handler.py@@ -2,7 +2,8 @@Handler for transforming /chat/completions api requests to litellm.responses requests"""-from typing import TYPE_CHECKING, Any, Coroutine, Optional, Union+from collections.abc import Coroutine+from typing import TYPE_CHECKING, Any, Optional, Unionfrom typing_extensions import TypedDictdiff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.pyindex 89a44fcdeef..3e8c78c4741 100644--- a/litellm/completion_extras/litellm_responses_transformation/transformation.py+++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py@@ -4,14 +4,11 @@ Handler for transforming /chat/completions api requests to litellm.responses reqimport jsonimport os+from collections.abc import AsyncIterator, Callable, Iterable, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Callable,Dict,- Iterable,- Iterator,List,Literal,Optional,diff --git a/litellm/containers/endpoint_factory.py b/litellm/containers/endpoint_factory.pyindex bebdfa2f9e6..046beaac791 100644--- a/litellm/containers/endpoint_factory.py+++ b/litellm/containers/endpoint_factory.py@@ -8,9 +8,10 @@ that use the generic container handler.import asyncioimport contextvarsimport json+from collections.abc import Callablefrom functools import partialfrom pathlib import Path-from typing import Any, Callable, Dict, List, Literal, Optional, Type+from typing import Any, Dict, List, Literal, Optional, Typeimport litellmfrom litellm.constants import request_timeout as DEFAULT_REQUEST_TIMEOUTdiff --git a/litellm/containers/main.py b/litellm/containers/main.pyindex caf6c684844..b1114e080d3 100644--- a/litellm/containers/main.py+++ b/litellm/containers/main.py@@ -1,8 +1,9 @@import asyncioimport contextvarsimport json+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, List, Literal, Optional, Union, overload+from typing import Any, Dict, List, Literal, Optional, Union, overloadimport litellmfrom litellm.constants import request_timeout as DEFAULT_REQUEST_TIMEOUTdiff --git a/litellm/evals/main.py b/litellm/evals/main.pyindex d4e9d638583..078b9c7002f 100644--- a/litellm/evals/main.py+++ b/litellm/evals/main.py@@ -5,8 +5,9 @@ Provides create, list, get, update, delete, and cancel operations for evalsimport asyncioimport contextvars+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, List, Optional, Union+from typing import Any, Dict, List, Optional, Unionimport httpxdiff --git a/litellm/experimental_mcp_client/client.py b/litellm/experimental_mcp_client/client.pyindex da711463a44..8a5440c8553 100644--- a/litellm/experimental_mcp_client/client.py+++ b/litellm/experimental_mcp_client/client.py@@ -5,18 +5,17 @@ LiteLLM Proxy uses this MCP Client to connnect to other MCP servers.import asyncioimport base64import os+from collections.abc import Awaitable, Callable, Generatorfrom typing import (Any,- Awaitable,- Callable,Dict,- Generator,List,Optional,Tuple,TypeVar,Union,)+import httpxfrom mcp import ClientSession, ReadResourceResult, Resource, StdioServerParametersfrom mcp.client.sse import sse_client@@ -40,6 +39,7 @@ from mcp.types import ()from mcp.types import Tool as MCPToolfrom pydantic import AnyUrl+from litellm._logging import verbose_loggerfrom litellm.constants import MCP_CLIENT_TIMEOUT, MCP_NPM_CACHE_DIRfrom litellm.llms.custom_httpx.http_handler import get_ssl_configurationdiff --git a/litellm/files/main.py b/litellm/files/main.pyindex 3b359b55fe3..297adfcffaa 100644--- a/litellm/files/main.py+++ b/litellm/files/main.py@@ -9,9 +9,10 @@ import asyncioimport contextvarsimport timeimport uuid as uuid_module+from collections.abc import Coroutinefrom functools import partialfrom types import MappingProxyType-from typing import Any, Coroutine, Dict, Literal, Optional, Union, cast+from typing import Any, Dict, Literal, Optional, Union, castimport httpxdiff --git a/litellm/files/streaming.py b/litellm/files/streaming.pyindex 6d84f73dcfe..9422a973e21 100644--- a/litellm/files/streaming.py+++ b/litellm/files/streaming.py@@ -1,17 +1,17 @@import datetimeimport traceback+from collections.abc import AsyncIterator, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,Dict,- Iterator,Optional,Union,cast,)import anyio+from litellm.files.types import FileContentProviderif TYPE_CHECKING:diff --git a/litellm/files/types.py b/litellm/files/types.pyindex 6bf7b1a1cc2..93feb4676c6 100644--- a/litellm/files/types.py+++ b/litellm/files/types.py@@ -1,4 +1,5 @@-from typing import AsyncIterator, Dict, Iterator, Literal, NamedTuple, Union+from collections.abc import AsyncIterator, Iterator+from typing import Dict, Literal, NamedTuple, UnionFileContentProvider = Literal["openai", "azure", "vertex_ai", "bedrock", "hosted_vllm", "anthropic", "manus"]diff --git a/litellm/fine_tuning/main.py b/litellm/fine_tuning/main.pyindex ce5074cdaf5..c6ab8a749d0 100644--- a/litellm/fine_tuning/main.py+++ b/litellm/fine_tuning/main.py@@ -11,8 +11,9 @@ https://platform.openai.com/docs/api-reference/fine-tuningimport asyncioimport contextvarsimport os+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, Literal, Optional, Union+from typing import Any, Dict, Literal, Optional, Unionimport httpxdiff --git a/litellm/google_genai/adapters/handler.py b/litellm/google_genai/adapters/handler.pyindex 82777fb1378..e6d7486fdb3 100644--- a/litellm/google_genai/adapters/handler.py+++ b/litellm/google_genai/adapters/handler.py@@ -1,4 +1,5 @@-from typing import Any, AsyncIterator, Coroutine, Dict, List, Optional, Union, cast+from collections.abc import AsyncIterator, Coroutine+from typing import Any, Dict, List, Optional, Union, castimport litellmfrom litellm.types.router import GenericLiteLLMParamsdiff --git a/litellm/google_genai/adapters/transformation.py b/litellm/google_genai/adapters/transformation.pyindex 02dde12a30d..d15b6f47013 100644--- a/litellm/google_genai/adapters/transformation.py+++ b/litellm/google_genai/adapters/transformation.py@@ -1,5 +1,6 @@import json-from typing import Any, AsyncIterator, Dict, Iterator, List, Optional, Union, cast+from collections.abc import AsyncIterator, Iterator+from typing import Any, Dict, List, Optional, Union, castfrom litellm import verbose_loggerfrom litellm.litellm_core_utils.json_validation_rule import normalize_tool_schemadiff --git a/litellm/google_genai/main.py b/litellm/google_genai/main.pyindex 3b1e712342f..5e119b75af3 100644--- a/litellm/google_genai/main.py+++ b/litellm/google_genai/main.py@@ -1,7 +1,8 @@import asyncioimport contextvars+from collections.abc import Iteratorfrom functools import partial-from typing import TYPE_CHECKING, Any, ClassVar, Dict, Iterator, Optional, Union+from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Unionimport httpxfrom pydantic import BaseModel, ConfigDictdiff --git a/litellm/images/main.py b/litellm/images/main.pyindex 17ea9aa177b..99f2ddffeb3 100644--- a/litellm/images/main.py+++ b/litellm/images/main.py@@ -1,11 +1,11 @@import asyncioimport contextvarsimport importlib+from collections.abc import Coroutinefrom functools import partialfrom typing import (TYPE_CHECKING,Any,- Coroutine,Dict,List,Literal,diff --git a/litellm/integrations/custom_logger.py b/litellm/integrations/custom_logger.pyindex 8b831b55da3..d2f0acd15d4 100644--- a/litellm/integrations/custom_logger.py+++ b/litellm/integrations/custom_logger.py@@ -2,10 +2,10 @@# On success, logs events to Promptlayerimport reimport traceback+from collections.abc import AsyncGeneratorfrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,Dict,List,Optional,@@ -18,9 +18,9 @@ from pydantic import BaseModelfrom litellm._logging import verbose_loggerfrom litellm.constants import DEFAULT_MAX_RECURSE_DEPTH_SENSITIVE_DATA_MASKERfrom litellm.types.integrations.argilla import ArgillaItem+from litellm.types.integrations.custom_logger import AgenticLoopPlanfrom litellm.types.llms.openai import AllMessageValues, ChatCompletionRequestfrom litellm.types.prompts.init_prompts import PromptSpec-from litellm.types.integrations.custom_logger import AgenticLoopPlanfrom litellm.types.utils import (AdapterCompletionStreamWrapper,CallTypes,@@ -850,9 +850,9 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbacThis is useful for logging payloads that contain sensitive information."""- import litellmfrom copy import copy+ import litellmfrom litellm import Choices, Message, ModelResponseturn_off_message_logging: bool = getattr(self, "turn_off_message_logging", False)diff --git a/litellm/integrations/datadog/datadog.py b/litellm/integrations/datadog/datadog.pyindex 20239d831cc..28d3f330fcd 100644--- a/litellm/integrations/datadog/datadog.py+++ b/litellm/integrations/datadog/datadog.py@@ -18,8 +18,9 @@ import datetimeimport osimport timeimport traceback+from collections.abc import Sequencefrom datetime import datetime as datetimeObj-from typing import Any, Dict, List, Optional, Sequence, Union+from typing import Any, Dict, List, Optional, Unionimport httpxfrom httpx import Response@@ -28,16 +29,16 @@ import litellmfrom litellm._logging import verbose_loggerfrom litellm._uuid import uuidfrom litellm.integrations.custom_batch_logger import CustomBatchLogger-from litellm.integrations.datadog.datadog_mock_client import (- should_use_datadog_mock,- create_mock_datadog_client,-)from litellm.integrations.datadog.datadog_handler import (+ get_datadog_base_url_from_env,get_datadog_hostname,get_datadog_service,get_datadog_source,get_datadog_tags,- get_datadog_base_url_from_env,+)+from litellm.integrations.datadog.datadog_mock_client import (+ create_mock_datadog_client,+ should_use_datadog_mock,)from litellm.litellm_core_utils.dd_tracing import tracerfrom litellm.llms.custom_httpx.http_handler import (@@ -51,10 +52,10 @@ from litellm.types.integrations.datadog import (DD_ERRORS,DD_MAX_BATCH_SIZE,DD_MAX_PAYLOAD_SIZE_BYTES,- DataDogStatus,DatadogInitParams,DatadogPayload,DatadogProxyFailureHookJsonMessage,+ DataDogStatus,)from litellm.types.services import ServiceLoggerPayload, ServiceTypesfrom litellm.types.utils import StandardLoggingPayloaddiff --git a/litellm/integrations/langfuse/langfuse.py b/litellm/integrations/langfuse/langfuse.pyindex 8068a8c0b0c..86da03a078b 100644--- a/litellm/integrations/langfuse/langfuse.py+++ b/litellm/integrations/langfuse/langfuse.py@@ -2,11 +2,11 @@# On success, logs events to Langfuseimport osimport traceback+from collections.abc import Callablefrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- Callable,Dict,List,Optional,@@ -20,16 +20,16 @@ from packaging.version import Versionimport litellmfrom litellm._logging import verbose_loggerfrom litellm.constants import MAX_LANGFUSE_INITIALIZED_CLIENTS-from litellm.litellm_core_utils.core_helpers import (- safe_deep_copy,- reconstruct_model_name,- filter_exceptions_from_params,-)-from litellm.litellm_core_utils.redact_messages import redact_user_api_key_infofrom litellm.integrations.langfuse.langfuse_mock_client import (create_mock_langfuse_client,should_use_langfuse_mock,)+from litellm.litellm_core_utils.core_helpers import (+ filter_exceptions_from_params,+ reconstruct_model_name,+ safe_deep_copy,+)+from litellm.litellm_core_utils.redact_messages import redact_user_api_key_infofrom litellm.llms.custom_httpx.http_handler import _get_httpx_clientfrom litellm.secret_managers.main import str_to_boolfrom litellm.types.integrations.langfuse import *diff --git a/litellm/integrations/langfuse/langfuse_prompt_management.py b/litellm/integrations/langfuse/langfuse_prompt_management.pyindex 0e06f516ecd..a2b760aa31d 100644--- a/litellm/integrations/langfuse/langfuse_prompt_management.py+++ b/litellm/integrations/langfuse/langfuse_prompt_management.py@@ -4,10 +4,9 @@ Call Hook for LiteLLM Proxy which allows Langfuse prompt management.import osfrom functools import lru_cache-from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Tuple, Union, cast+from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Tuple, TypeAlias, Union, castfrom packaging.version import Version-from typing_extensions import TypeAliasfrom litellm.integrations.custom_logger import CustomLoggerfrom litellm.integrations.prompt_management_base import PromptManagementClientdiff --git a/litellm/integrations/otel/emitter.py b/litellm/integrations/otel/emitter.pyindex 8651cf586cd..21a243de9b9 100644--- a/litellm/integrations/otel/emitter.py+++ b/litellm/integrations/otel/emitter.py@@ -1,15 +1,15 @@"""The span engine: dedup, start, run the mapper chain, set status, end."""from collections import OrderedDict-from typing import Callable, Sequence+from collections.abc import Callable, Sequencefrom opentelemetry.context import Contextfrom opentelemetry.trace import Link, Span, Tracerfrom opentelemetry.trace.status import Status, StatusCode-from litellm.integrations.otel.model.config import OpenTelemetryV2Configfrom litellm.integrations.otel.mappers import resolve_mappersfrom litellm.integrations.otel.mappers.base import AttributeMapper, SpanData+from litellm.integrations.otel.model.config import OpenTelemetryV2Configfrom litellm.integrations.otel.model.payloads import (GuardrailSpanData,LLMCallSpanData,@@ -18,8 +18,6 @@ from litellm.integrations.otel.model.payloads import (ServiceSpanData,SpanError,)-from litellm.integrations.otel.plumbing.events import GenAIEventRecorder-from litellm.integrations.otel.plumbing.providers import to_otel_span_kindfrom litellm.integrations.otel.model.semconv import Error, ExceptionEvent, LiteLLMErrorfrom litellm.integrations.otel.model.spans import (SPAN_REGISTRY,@@ -30,6 +28,8 @@ from litellm.integrations.otel.model.spans import (mcp_tool_call_span_name,service_span_name,)+from litellm.integrations.otel.plumbing.events import GenAIEventRecorder+from litellm.integrations.otel.plumbing.providers import to_otel_span_kind# Roles emit() knows how to name and emit. PROXY_REQUEST and the management# routes are SERVER spans owned by the mounted FastAPI instrumentor, so theydiff --git a/litellm/integrations/otel/logger.py b/litellm/integrations/otel/logger.pyindex b8908696547..888d006e4f7 100644--- a/litellm/integrations/otel/logger.py+++ b/litellm/integrations/otel/logger.py@@ -1,9 +1,10 @@"""``CustomLogger`` adapter on the OpenTelemetry span engine."""from collections import OrderedDict+from collections.abc import Callable, Iterator, Mapping, Sequencefrom contextlib import contextmanagerfrom datetime import datetime-from typing import TYPE_CHECKING, Any, Callable, Iterator, Mapping, Sequence, cast+from typing import TYPE_CHECKING, Any, castfrom opentelemetry.context import Context, attach, get_currentfrom opentelemetry.sdk._logs import LoggerProvider@@ -13,20 +14,10 @@ from opentelemetry.trace import Span, Tracer, get_current_span, use_spanimport litellmfrom litellm._logging import verbose_loggerfrom litellm.integrations.custom_logger import CustomLogger-from litellm.integrations.otel.model.baggage import promoted_baggage-from litellm.integrations.otel.model.config import OpenTelemetryV2Config-from litellm.integrations.otel.plumbing.context import (- is_recordable_span,- mcp_message_transport_span,- request_root_span,- resolve_mcp_span_context,- resolve_parent_context,- resolve_request_span_context,- set_request_baggage,- set_request_root_span,-)from litellm.integrations.otel.emitter import SpanEmitter, stamp_errorfrom litellm.integrations.otel.mappers import resolve_mappers+from litellm.integrations.otel.model.baggage import promoted_baggage+from litellm.integrations.otel.model.config import OpenTelemetryV2Configfrom litellm.integrations.otel.model.metadata import (LLMCallEvent,RequestIdentity,@@ -42,6 +33,18 @@ from litellm.integrations.otel.model.payloads import (is_mcp_list_tools,is_mcp_tool_call,)+from litellm.integrations.otel.model.spans import SpanRole, span_role_for_service+from litellm.integrations.otel.model.utils import to_ns+from litellm.integrations.otel.plumbing.context import (+ is_recordable_span,+ mcp_message_transport_span,+ request_root_span,+ resolve_mcp_span_context,+ resolve_parent_context,+ resolve_request_span_context,+ set_request_baggage,+ set_request_root_span,+)from litellm.integrations.otel.plumbing.events import GenAIEventRecorderfrom litellm.integrations.otel.plumbing.metrics import (GenAIMetricRecorder,@@ -56,8 +59,6 @@ from litellm.integrations.otel.plumbing.providers import (resolve_meter_provider,)from litellm.integrations.otel.plumbing.routing import TenantTracerCache-from litellm.integrations.otel.model.spans import SpanRole, span_role_for_service-from litellm.integrations.otel.model.utils import to_nsif TYPE_CHECKING:from litellm.proxy._types import UserAPIKeyAuthdiff --git a/litellm/integrations/otel/mappers/__init__.py b/litellm/integrations/otel/mappers/__init__.pyindex 55504c5e8bf..2050677feb3 100644--- a/litellm/integrations/otel/mappers/__init__.py+++ b/litellm/integrations/otel/mappers/__init__.py@@ -6,7 +6,7 @@ carry both the canonical ``gen_ai.*`` keys and the OpenInference (Arize +Phoenix) keys. Add ``"langfuse"`` and it works for all three backends at once."""-from typing import Callable, Iterable+from collections.abc import Callable, Iterablefrom litellm.integrations.otel.mappers.base import (AttributeMap,diff --git a/litellm/integrations/otel/mappers/base.py b/litellm/integrations/otel/mappers/base.pyindex 809d956a9c7..85ae3ea33c4 100644--- a/litellm/integrations/otel/mappers/base.py+++ b/litellm/integrations/otel/mappers/base.py@@ -1,6 +1,6 @@"""Mapper protocol and attribute value types."""-from typing import Sequence+from collections.abc import Sequencefrom typing_extensions import Protocol, runtime_checkablediff --git a/litellm/integrations/otel/mappers/genai.py b/litellm/integrations/otel/mappers/genai.pyindex 70414734b72..4a8680e4af3 100644--- a/litellm/integrations/otel/mappers/genai.py+++ b/litellm/integrations/otel/mappers/genai.py@@ -7,7 +7,7 @@ Each span kind declares its schema as a flat ``attribute key -> extractor``table: one lambda per mapping operation, applied against the typed span data."""-from typing import Callable+from collections.abc import Callablefrom litellm.integrations.otel.mappers.base import AttributeMap, AttrValue, SpanDatafrom litellm.integrations.otel.mappers.utils import (diff --git a/litellm/integrations/otel/mappers/langfuse.py b/litellm/integrations/otel/mappers/langfuse.pyindex 79f8f618eff..6d4f1b4fd0a 100644--- a/litellm/integrations/otel/mappers/langfuse.py+++ b/litellm/integrations/otel/mappers/langfuse.py@@ -10,7 +10,7 @@ the JSON-serialized payloads. ``_llm_call`` just applies both tables."""import json-from typing import Callable+from collections.abc import Callablefrom litellm.integrations.otel.mappers.base import AttributeMap, AttrValue, SpanDatafrom litellm.integrations.otel.mappers.utils import (diff --git a/litellm/integrations/otel/mappers/langtrace.py b/litellm/integrations/otel/mappers/langtrace.pyindex 975864b51b4..99866cb18a6 100644--- a/litellm/integrations/otel/mappers/langtrace.py+++ b/litellm/integrations/otel/mappers/langtrace.py@@ -8,7 +8,7 @@ Scalar attributes are declared as a flat ``key -> extractor`` table (one lambdaper mapping operation); the prompt/completion blobs are serialized as a tail."""-from typing import Callable+from collections.abc import Callablefrom litellm.integrations.otel.mappers.base import AttributeMap, AttrValue, SpanDatafrom litellm.integrations.otel.mappers.utils import (diff --git a/litellm/integrations/otel/mappers/legacy.py b/litellm/integrations/otel/mappers/legacy.pyindex f17a62828e7..619c19f1cc0 100644--- a/litellm/integrations/otel/mappers/legacy.py+++ b/litellm/integrations/otel/mappers/legacy.py@@ -9,7 +9,8 @@ Like ``GenAIMapper``, each span kind declares its schema as a flat``attribute key -> extractor`` table: one lambda per mapping operation."""-from typing import Callable, Final+from collections.abc import Callable+from typing import Finalfrom litellm.integrations.otel.mappers.base import AttributeMap, AttrValue, SpanDatafrom litellm.integrations.otel.mappers.utils import (diff --git a/litellm/integrations/otel/mappers/openinference.py b/litellm/integrations/otel/mappers/openinference.pyindex 87c4d0d6484..59a655eb623 100644--- a/litellm/integrations/otel/mappers/openinference.py+++ b/litellm/integrations/otel/mappers/openinference.py@@ -7,13 +7,13 @@ Phoenix + any other OpenInference-aware backend simultaneously."""import json-from typing import Callable, Sequence+from collections.abc import Callable, Sequencefrom litellm.integrations.otel.mappers.base import AttributeMap, AttrValue, SpanDatafrom litellm.integrations.otel.mappers.utils import (+ MAX_TOOL_DEFINITION_ATTRS_PER_SPAN,collect,drop_none,- MAX_TOOL_DEFINITION_ATTRS_PER_SPAN,json_if,message_content,output_messages,diff --git a/litellm/integrations/otel/mappers/utils.py b/litellm/integrations/otel/mappers/utils.pyindex cbdb60f42c9..4e8118d5385 100644--- a/litellm/integrations/otel/mappers/utils.py+++ b/litellm/integrations/otel/mappers/utils.py@@ -6,7 +6,8 @@ they live in one place."""import json-from typing import Callable, Final, Mapping, Sequence+from collections.abc import Callable, Mapping, Sequence+from typing import Finalfrom litellm.integrations.otel.mappers.base import AttributeMap, AttrValuefrom litellm.integrations.otel.model.payloads import LLMCallSpanData, ToolDefinitiondiff --git a/litellm/integrations/otel/mappers/weave.py b/litellm/integrations/otel/mappers/weave.pyindex 2eb4ad817c7..d222e33f541 100644--- a/litellm/integrations/otel/mappers/weave.py+++ b/litellm/integrations/otel/mappers/weave.py@@ -6,7 +6,7 @@ OpenInference's vocabulary — compose ``["genai", "openinference", "weave"]``to feed a Weave backend."""-from typing import Callable+from collections.abc import Callablefrom litellm.integrations.otel.mappers.base import AttributeMap, AttrValue, SpanDatafrom litellm.integrations.otel.mappers.utils import collect, json_or_nonediff --git a/litellm/integrations/otel/model/config.py b/litellm/integrations/otel/model/config.pyindex 7f33129c560..270d9e33b86 100644--- a/litellm/integrations/otel/model/config.py+++ b/litellm/integrations/otel/model/config.py@@ -2,11 +2,10 @@from enum import Enumfrom functools import lru_cache-from typing import Any, List+from typing import Annotated, Any, Listfrom pydantic import AliasChoices, BaseModel, Field, field_validator, model_validatorfrom pydantic_settings import BaseSettings, NoDecode, SettingsConfigDict-from typing_extensions import Annotatedfrom litellm.integrations.otel.model.baggage import (BAGGAGE_PROMOTED_KEYS,diff --git a/litellm/integrations/otel/model/metadata.py b/litellm/integrations/otel/model/metadata.pyindex 7ff4f540908..8ac02e936a7 100644--- a/litellm/integrations/otel/model/metadata.py+++ b/litellm/integrations/otel/model/metadata.py@@ -36,8 +36,9 @@ model. They coincide on the SDK path, which is correct.from __future__ import annotations+from collections.abc import Mappingfrom dataclasses import dataclass, field-from typing import TYPE_CHECKING, Any, Mapping, cast+from typing import TYPE_CHECKING, Any, castfrom litellm.constants import LITELLM_LOGGING_NO_UPSTREAM_LLM_CALLfrom litellm.integrations.otel.model.semconv import resolve_operationdiff --git a/litellm/integrations/otel/model/payloads.py b/litellm/integrations/otel/model/payloads.pyindex 4a8f01858b5..892da9080f5 100644--- a/litellm/integrations/otel/model/payloads.py+++ b/litellm/integrations/otel/model/payloads.py@@ -3,9 +3,10 @@from __future__ import annotationsimport json+from collections.abc import Mappingfrom dataclasses import dataclass, fieldfrom enum import Enum-from typing import TYPE_CHECKING, ClassVar, Mapping, cast+from typing import TYPE_CHECKING, ClassVar, castfrom urllib.parse import urlsplitfrom litellm.integrations.otel.model.metadata import (diff --git a/litellm/integrations/otel/plumbing/context.py b/litellm/integrations/otel/plumbing/context.pyindex c03ef8d6d63..ef25c136c8f 100644--- a/litellm/integrations/otel/plumbing/context.py+++ b/litellm/integrations/otel/plumbing/context.py@@ -1,7 +1,7 @@"""Trace-context + Baggage helpers."""+from collections.abc import Mappingfrom contextvars import ContextVar, Token-from typing import Mappingfrom opentelemetry import baggagefrom opentelemetry.context import Context, get_currentdiff --git a/litellm/integrations/otel/plumbing/metrics.py b/litellm/integrations/otel/plumbing/metrics.pyindex 6ebaacafdc4..cd256852c13 100644--- a/litellm/integrations/otel/plumbing/metrics.py+++ b/litellm/integrations/otel/plumbing/metrics.py@@ -8,9 +8,10 @@ identical metrics. The attribute cardinality filter is reused from v1 by import(no duplication of the valid-name set or its validation)."""+from collections.abc import Mappingfrom dataclasses import dataclassfrom datetime import datetime-from typing import Any, Final, FrozenSet, Mapping, Optional, TypeAlias+from typing import Any, Final, FrozenSet, Optional, TypeAliasfrom opentelemetry.metrics import Histogram, Meterdiff --git a/litellm/integrations/otel/plumbing/providers.py b/litellm/integrations/otel/plumbing/providers.pyindex ede9acc6d8f..3c094f96b39 100644--- a/litellm/integrations/otel/plumbing/providers.py+++ b/litellm/integrations/otel/plumbing/providers.py@@ -1,6 +1,7 @@"""Provider / exporter factory + the Baggage span processor."""-from typing import TYPE_CHECKING, Any, Callable, Iterable+from collections.abc import Callable, Iterable+from typing import TYPE_CHECKING, Anyfrom opentelemetry import _logs, baggage, metricsfrom opentelemetry._events import EventLoggerdiff --git a/litellm/integrations/otel/plumbing/routing.py b/litellm/integrations/otel/plumbing/routing.pyindex 2f8945e903b..3c99e200bb4 100644--- a/litellm/integrations/otel/plumbing/routing.py+++ b/litellm/integrations/otel/plumbing/routing.py@@ -9,18 +9,19 @@ logger fan requests out to many tenants without needing a logger per tenant."""from collections import OrderedDict-from typing import Any, Mapping+from collections.abc import Mapping+from typing import Anyfrom opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.trace import Tracerfrom litellm._logging import verbose_loggerfrom litellm.integrations.otel.model.config import OpenTelemetryV2Config-from litellm.integrations.otel.presets import dynamic_otlp_headersfrom litellm.integrations.otel.plumbing.providers import (build_tracer_provider,get_tracer,)+from litellm.integrations.otel.presets import dynamic_otlp_headers# Exporter kinds that ignore headers — never rewritten with dynamic credentials._NON_OTLP_KINDS = ("console", "in_memory", "inmemory", "memory")diff --git a/litellm/integrations/otel/presets/__init__.py b/litellm/integrations/otel/presets/__init__.pyindex deaf953ede8..31690d37b93 100644--- a/litellm/integrations/otel/presets/__init__.py+++ b/litellm/integrations/otel/presets/__init__.py@@ -8,7 +8,7 @@ the factory in ``litellm_logging`` can resolve a name and build a single``OpenTelemetryV2`` instance from the result."""-from typing import Callable+from collections.abc import Callablefrom litellm.integrations.otel.presets.agentops import agentops_presetfrom litellm.integrations.otel.presets.arize import arize_dynamic_headers, arize_presetdiff --git a/litellm/integrations/otel/presets/utils.py b/litellm/integrations/otel/presets/utils.pyindex fdf8184441d..f66d36be5bc 100644--- a/litellm/integrations/otel/presets/utils.py+++ b/litellm/integrations/otel/presets/utils.py@@ -1,6 +1,6 @@"""Shared helpers for the integration presets."""-from typing import Iterable+from collections.abc import Iterabledef ensure_mappers(mapper_names: Iterable[str], *names: str) -> list[str]:diff --git a/litellm/integrations/otel/runtime.py b/litellm/integrations/otel/runtime.pyindex eb512375023..13b36a5b1eb 100644--- a/litellm/integrations/otel/runtime.py+++ b/litellm/integrations/otel/runtime.py@@ -7,9 +7,10 @@ V2 is not the active logger — so a call site can wrap a request phase or seedidentity unconditionally."""+from collections.abc import Callable, Iteratorfrom contextlib import contextmanagerfrom functools import cache-from typing import Any, Callable, Iterator, Optional+from typing import Any, Optional@cachediff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.pyindex 1bc7308f7df..f0251586c4f 100644--- a/litellm/integrations/prometheus.py+++ b/litellm/integrations/prometheus.py@@ -7,18 +7,15 @@ import asyncioimport mathimport osimport sys+from collections.abc import Awaitable, Callable, Mapping, Sequencefrom datetime import datetime, timedeltafrom typing import (TYPE_CHECKING,Any,- Awaitable,- Callable,Dict,List,Literal,- Mapping,Optional,- Sequence,Tuple,Union,cast,diff --git a/litellm/integrations/prompt_management_base.py b/litellm/integrations/prompt_management_base.pyindex 6d77e959e2d..a85ef4a3137 100644--- a/litellm/integrations/prompt_management_base.py+++ b/litellm/integrations/prompt_management_base.py@@ -1,7 +1,7 @@from abc import ABC, abstractmethod-from typing import Any, Dict, List, Optional, Tuple+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple-from typing_extensions import TYPE_CHECKING, TypedDict+from typing_extensions import TypedDictfrom litellm.types.llms.openai import AllMessageValuesfrom litellm.types.prompts.init_prompts import PromptSpecdiff --git a/litellm/integrations/weights_biases.py b/litellm/integrations/weights_biases.pyindex 6d002ac4a37..d2c93bc1bf4 100644--- a/litellm/integrations/weights_biases.py+++ b/litellm/integrations/weights_biases.py@@ -10,7 +10,9 @@ try:if sys.version_info >= (3, 8):from typing import Literal, Protocolelse:- from typing_extensions import Literal, Protocol+ from typing import Literal++ from typing_extensions import Protocollogger = logging.getLogger(__name__)diff --git a/litellm/interactions/agents/http_handler.py b/litellm/interactions/agents/http_handler.pyindex 394b0f72634..6359730519c 100644--- a/litellm/interactions/agents/http_handler.py+++ b/litellm/interactions/agents/http_handler.py@@ -6,7 +6,8 @@ Extends InteractionsHTTPHandler so that the shared HTTP infrastructureduplicated. BaseAgentsAPIConfig stays as pure transform code."""-from typing import Any, Coroutine, Dict, Optional, Union+from collections.abc import Coroutine+from typing import Any, Dict, Optional, Unionimport httpxdiff --git a/litellm/interactions/agents/main.py b/litellm/interactions/agents/main.pyindex ce63332c1a6..9f54b929bdc 100644--- a/litellm/interactions/agents/main.py+++ b/litellm/interactions/agents/main.py@@ -30,8 +30,9 @@ Usage:import asyncioimport contextvars+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, Optional, Union+from typing import Any, Dict, Optional, Unionimport httpxdiff --git a/litellm/interactions/agents/utils.py b/litellm/interactions/agents/utils.pyindex e9405928a3d..a195dca1d25 100644--- a/litellm/interactions/agents/utils.py+++ b/litellm/interactions/agents/utils.py@@ -2,7 +2,8 @@Utility functions for the Agents API SDK."""-from typing import Dict, Mapping, Optional+from collections.abc import Mapping+from typing import Dict, Optionalfrom litellm.llms.base_llm.agents.transformation import BaseAgentsAPIConfigdiff --git a/litellm/interactions/http_handler.py b/litellm/interactions/http_handler.pyindex 0e5769933fe..a04c2ca3807 100644--- a/litellm/interactions/http_handler.py+++ b/litellm/interactions/http_handler.py@@ -4,12 +4,10 @@ HTTP Handler for Interactions API requests.This module handles the HTTP communication for the Google Interactions API."""+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom typing import (Any,- AsyncIterator,- Coroutine,Dict,- Iterator,Optional,Union,)diff --git a/litellm/interactions/litellm_responses_transformation/handler.py b/litellm/interactions/litellm_responses_transformation/handler.pyindex 4b108ee47d7..28b485cb3f5 100644--- a/litellm/interactions/litellm_responses_transformation/handler.py+++ b/litellm/interactions/litellm_responses_transformation/handler.py@@ -2,12 +2,10 @@Handler for transforming interactions API requests to litellm.responses requests."""+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom typing import (Any,- AsyncIterator,- Coroutine,Dict,- Iterator,Optional,Union,cast,diff --git a/litellm/interactions/litellm_responses_transformation/streaming_iterator.py b/litellm/interactions/litellm_responses_transformation/streaming_iterator.pyindex 6b10a36c179..670f18c598c 100644--- a/litellm/interactions/litellm_responses_transformation/streaming_iterator.py+++ b/litellm/interactions/litellm_responses_transformation/streaming_iterator.py@@ -3,12 +3,11 @@ Streaming iterator for transforming Responses API stream to Interactions API str"""from collections import deque+from collections.abc import AsyncIterator, Iteratorfrom typing import (Any,- AsyncIterator,Deque,Dict,- Iterator,List,Optional,cast,diff --git a/litellm/interactions/main.py b/litellm/interactions/main.pyindex 8634269ee94..481b1052790 100644--- a/litellm/interactions/main.py+++ b/litellm/interactions/main.py@@ -33,8 +33,9 @@ Usage:import asyncioimport contextvars+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom functools import partial-from typing import Any, AsyncIterator, Coroutine, Dict, Iterator, List, Optional, Union+from typing import Any, Dict, List, Optional, Unionimport httpxdiff --git a/litellm/litellm_core_utils/asyncify.py b/litellm/litellm_core_utils/asyncify.pyindex 09585171147..0b174c8621c 100644--- a/litellm/litellm_core_utils/asyncify.py+++ b/litellm/litellm_core_utils/asyncify.py@@ -1,6 +1,7 @@import asyncioimport functools-from typing import Awaitable, Callable, Optional+from collections.abc import Awaitable, Callable+from typing import Optionalimport anyioimport anyio.to_threaddiff --git a/litellm/litellm_core_utils/cached_imports.py b/litellm/litellm_core_utils/cached_imports.pyindex 1a3943cc517..b897f61757a 100644--- a/litellm/litellm_core_utils/cached_imports.py+++ b/litellm/litellm_core_utils/cached_imports.py@@ -5,12 +5,13 @@ This module provides cached import functionality to avoid repeated importsinside functions that are critical to performance."""-from typing import TYPE_CHECKING, Callable, Optional, Type+from collections.abc import Callable+from typing import TYPE_CHECKING, Optional, Type# Type annotations for cached importsif TYPE_CHECKING:- from litellm.litellm_core_utils.litellm_logging import Loggingfrom litellm.litellm_core_utils.coroutine_checker import CoroutineChecker+ from litellm.litellm_core_utils.litellm_logging import Logging# Global cache variables_LiteLLMLogging: Optional[Type["Logging"]] = Nonediff --git a/litellm/litellm_core_utils/cloud_storage_security.py b/litellm/litellm_core_utils/cloud_storage_security.pyindex a62dfe61805..077af32e3d0 100644--- a/litellm/litellm_core_utils/cloud_storage_security.py+++ b/litellm/litellm_core_utils/cloud_storage_security.py@@ -1,7 +1,8 @@import posixpathimport re+from collections.abc import Mapping, Sequencefrom types import MappingProxyType-from typing import Any, Mapping, Optional, Sequence, Tuple, cast+from typing import Any, Optional, Tuple, castfrom urllib.parse import quote, unquotefrom litellm._uuid import uuiddiff --git a/litellm/litellm_core_utils/completion_timeout.py b/litellm/litellm_core_utils/completion_timeout.pyindex 794749a39bf..bf6e6315c66 100644--- a/litellm/litellm_core_utils/completion_timeout.py+++ b/litellm/litellm_core_utils/completion_timeout.py@@ -2,7 +2,8 @@from __future__ import annotations-from typing import Callable, Optional, Union+from collections.abc import Callable+from typing import Optional, Unionimport httpxdiff --git a/litellm/litellm_core_utils/core_helpers.py b/litellm/litellm_core_utils/core_helpers.pyindex cecc35ee1c1..60fca1ae037 100644--- a/litellm/litellm_core_utils/core_helpers.py+++ b/litellm/litellm_core_utils/core_helpers.py@@ -1,7 +1,8 @@# What is this?## Helper utilitiesimport copy-from typing import TYPE_CHECKING, Any, Iterable, List, Literal, Optional, Union+from collections.abc import Iterable+from typing import TYPE_CHECKING, Any, List, Literal, Optional, Unionimport httpxdiff --git a/litellm/litellm_core_utils/health_check_helpers.py b/litellm/litellm_core_utils/health_check_helpers.pyindex 9fc036e2a99..031c221ad72 100644--- a/litellm/litellm_core_utils/health_check_helpers.py+++ b/litellm/litellm_core_utils/health_check_helpers.py@@ -2,7 +2,8 @@Helper functions for health check calls."""-from typing import TYPE_CHECKING, Callable, Dict, Literal, Optional+from collections.abc import Callable+from typing import TYPE_CHECKING, Dict, Literal, Optionalfrom litellm.types.utils import LIST_BATCHES_SUPPORTED_PROVIDERSdiff --git a/litellm/litellm_core_utils/initialize_dynamic_callback_params.py b/litellm/litellm_core_utils/initialize_dynamic_callback_params.pyindex 06a9e98c5ac..4e1ca181ecc 100644--- a/litellm/litellm_core_utils/initialize_dynamic_callback_params.py+++ b/litellm/litellm_core_utils/initialize_dynamic_callback_params.py@@ -1,4 +1,5 @@-from typing import Any, Dict, Iterator, Optional+from collections.abc import Iterator+from typing import Any, Dict, Optionalfrom litellm.types.utils import StandardCallbackDynamicParamsdiff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.pyindex c2dc7189934..db47ab0b367 100644--- a/litellm/litellm_core_utils/litellm_logging.py+++ b/litellm/litellm_core_utils/litellm_logging.py@@ -10,12 +10,12 @@ import subprocessimport sysimport timeimport traceback+from collections.abc import Callablefrom datetime import datetime as dt_objectfrom functools import lru_cachefrom typing import (TYPE_CHECKING,Any,- Callable,Dict,List,Literal,@@ -37,11 +37,6 @@ from litellm import (turn_off_message_logging,)from litellm._logging import _is_debugging_on, _redact_string, verbose_logger-from litellm.exceptions import (- BudgetExceededError,- validate_rate_limit_category,- validate_rate_limit_type,-)from litellm._uuid import uuidfrom litellm.batches.batch_utils import _handle_completed_batchfrom litellm.caching.caching import DualCache, InMemoryCache@@ -56,6 +51,11 @@ from litellm.cost_calculator import (RealtimeAPITokenUsageProcessor,_select_model_name_for_cost_calc,)+from litellm.exceptions import (+ BudgetExceededError,+ validate_rate_limit_category,+ validate_rate_limit_type,+)from litellm.integrations.agentops import AgentOpsfrom litellm.integrations.anthropic_cache_control_hook import AnthropicCacheControlHookfrom litellm.integrations.arize.arize import ArizeLoggerdiff --git a/litellm/litellm_core_utils/llm_cost_calc/utils.py b/litellm/litellm_core_utils/llm_cost_calc/utils.pyindex fbc06b76c72..73427769b15 100644--- a/litellm/litellm_core_utils/llm_cost_calc/utils.py+++ b/litellm/litellm_core_utils/llm_cost_calc/utils.py@@ -1,9 +1,10 @@# What is this?## Helper utilities for cost_per_token()+from collections.abc import Mappingfrom dataclasses import dataclassfrom types import MappingProxyType-from typing import Any, Literal, Mapping, Optional, Tuple, TypedDict, cast+from typing import Any, Literal, Optional, Tuple, TypedDict, castimport litellmfrom litellm._logging import verbose_loggerdiff --git a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.pyindex 47daf33824e..861c5747963 100644--- a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py+++ b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py@@ -3,7 +3,8 @@ import jsonimport reimport timeimport traceback-from typing import Dict, Iterable, List, Literal, Optional, Tuple, Union, cast+from collections.abc import Iterable+from typing import Dict, List, Literal, Optional, Tuple, Union, castimport litellmfrom litellm._logging import verbose_logger@@ -28,9 +29,6 @@ from litellm.types.utils import (Function,HiddenParams,ImageResponse,-)-from litellm.types.utils import Logprobs as TextCompletionLogprobs-from litellm.types.utils import (Message,ModelResponse,ModelResponseStream,@@ -44,6 +42,7 @@ from litellm.types.utils import (TranscriptionUsageTokensObject,Usage,)+from litellm.types.utils import Logprobs as TextCompletionLogprobsfrom .get_headers import get_response_headersdiff --git a/litellm/litellm_core_utils/logging_callback_manager.py b/litellm/litellm_core_utils/logging_callback_manager.pyindex 00e12ee7ce9..71ad4c3b4e9 100644--- a/litellm/litellm_core_utils/logging_callback_manager.py+++ b/litellm/litellm_core_utils/logging_callback_manager.py@@ -1,4 +1,5 @@-from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Set, Type, Union+from collections.abc import Callable+from typing import TYPE_CHECKING, Dict, List, Optional, Set, Type, Unionimport litellmfrom litellm._logging import verbose_loggerdiff --git a/litellm/litellm_core_utils/logging_worker.py b/litellm/litellm_core_utils/logging_worker.pyindex a9d5c8a8eb7..3e1f1a9818e 100644--- a/litellm/litellm_core_utils/logging_worker.py+++ b/litellm/litellm_core_utils/logging_worker.py@@ -2,19 +2,21 @@# for the sake of performance and scalability.import asyncio+import atexitimport contextvarsimport logging-from typing import Coroutine, Optional-import atexit+from collections.abc import Coroutine+from typing import Optional+from typing_extensions import TypedDictfrom litellm._logging import verbose_loggerfrom litellm.constants import (+ LOGGING_WORKER_AGGRESSIVE_CLEAR_COOLDOWN_SECONDS,+ LOGGING_WORKER_CLEAR_PERCENTAGE,LOGGING_WORKER_CONCURRENCY,LOGGING_WORKER_MAX_QUEUE_SIZE,LOGGING_WORKER_MAX_TIME_PER_COROUTINE,- LOGGING_WORKER_CLEAR_PERCENTAGE,- LOGGING_WORKER_AGGRESSIVE_CLEAR_COOLDOWN_SECONDS,MAX_ITERATIONS_TO_CLEAR_QUEUE,MAX_TIME_TO_CLEAR_QUEUE,)diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.pyindex c43089950ee..e70520998ca 100644--- a/litellm/litellm_core_utils/prompt_templates/common_utils.py+++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py@@ -6,6 +6,7 @@ import ioimport jsonimport mimetypesimport re+from collections.abc import Mappingfrom os import PathLikefrom pathlib import Pathfrom typing import (@@ -14,7 +15,6 @@ from typing import (Dict,List,Literal,- Mapping,Optional,Tuple,Union,diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.pyindex 0ac22b5bb1e..0310d85b810 100644--- a/litellm/litellm_core_utils/streaming_handler.py+++ b/litellm/litellm_core_utils/streaming_handler.py@@ -6,13 +6,11 @@ import loggingimport threadingimport timeimport traceback+from collections.abc import AsyncIterator, Callable, Iteratorfrom dataclasses import dataclassfrom typing import (Any,- AsyncIterator,- Callable,Dict,- Iterator,List,NoReturn,Optional,@@ -36,15 +34,13 @@ from litellm.types.llms.openai import OpenAIChatCompletionChunkfrom litellm.types.router import GenericLiteLLMParamsfrom litellm.types.utils import (Delta,-)-from litellm.types.utils import GenericStreamingChunk as GChunk-from litellm.types.utils import (LlmProviders,ModelResponse,ModelResponseStream,StreamingChoices,Usage,)+from litellm.types.utils import GenericStreamingChunk as GChunkfrom ..exceptions import OpenAIErrorfrom .core_helpers import map_finish_reason, process_response_headersdiff --git a/litellm/litellm_core_utils/token_counter.py b/litellm/litellm_core_utils/token_counter.pyindex 071b16c8378..939b8d2b60f 100644--- a/litellm/litellm_core_utils/token_counter.py+++ b/litellm/litellm_core_utils/token_counter.py@@ -3,12 +3,11 @@import base64import ioimport struct+from collections.abc import Callable, Mappingfrom typing import (Any,- Callable,List,Literal,- Mapping,Optional,Tuple,Union,@@ -30,8 +29,8 @@ from litellm.constants import (MAX_TILE_WIDTH,)from litellm.litellm_core_utils.default_encoding import encoding as default_encoding-from litellm.llms.custom_httpx.http_handler import _get_httpx_clientfrom litellm.litellm_core_utils.url_utils import safe_get+from litellm.llms.custom_httpx.http_handler import _get_httpx_clientfrom litellm.types.llms.anthropic import (AnthropicMessagesToolResultParam,AnthropicMessagesToolUseParam,diff --git a/litellm/llms/a2a/chat/transformation.py b/litellm/llms/a2a/chat/transformation.pyindex 113c000f352..d8b67bcf22f 100644--- a/litellm/llms/a2a/chat/transformation.py+++ b/litellm/llms/a2a/chat/transformation.py@@ -3,7 +3,8 @@ A2A Protocol Transformation for LiteLLM"""import uuid-from typing import Any, Dict, Iterator, List, Optional, Union+from collections.abc import Iterator+from typing import Any, Dict, List, Optional, Unionimport httpxdiff --git a/litellm/llms/anthropic/batches/handler.py b/litellm/llms/anthropic/batches/handler.pyindex 52bf29a5519..c83c96e50c4 100644--- a/litellm/llms/anthropic/batches/handler.py+++ b/litellm/llms/anthropic/batches/handler.py@@ -3,7 +3,8 @@ Anthropic Batches API Handler"""import asyncio-from typing import TYPE_CHECKING, Any, Coroutine, Optional, Union+from collections.abc import Coroutine+from typing import TYPE_CHECKING, Any, Optional, Unionimport httpxdiff --git a/litellm/llms/anthropic/chat/handler.py b/litellm/llms/anthropic/chat/handler.pyindex c8872306e82..39780ac5df4 100644--- a/litellm/llms/anthropic/chat/handler.py+++ b/litellm/llms/anthropic/chat/handler.py@@ -4,10 +4,10 @@ Calling + translation logic for anthropic's `/v1/messages` endpointimport copyimport json+from collections.abc import Callablefrom typing import (TYPE_CHECKING,Any,- Callable,Dict,List,Literal,diff --git a/litellm/llms/anthropic/completion/transformation.py b/litellm/llms/anthropic/completion/transformation.pyindex d06eac51101..4b652512322 100644--- a/litellm/llms/anthropic/completion/transformation.py+++ b/litellm/llms/anthropic/completion/transformation.py@@ -6,7 +6,8 @@ Litellm provider slug: `anthropic_text/<model_name>`import jsonimport time-from typing import AsyncIterator, Dict, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import Dict, List, Optional, Unionimport httpxdiff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.pyindex 7299fc16897..5870a3bf7de 100644--- a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py+++ b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py@@ -1,10 +1,8 @@+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Coroutine,Dict,- Iterator,List,Optional,Tuple,diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.pyindex d9bcfa19a7f..f1261ef1413 100644--- a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py+++ b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py@@ -4,12 +4,11 @@ import copyimport jsonimport tracebackfrom collections import deque+from collections.abc import AsyncIterator, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,Dict,- Iterator,List,Literal,Optional,diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.pyindex 86c9c1db481..9826bcb2490 100644--- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py+++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py@@ -1,12 +1,11 @@import copyimport hashlibimport json+from collections.abc import AsyncIterator, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,Dict,- Iterator,List,Literal,Optional,diff --git a/litellm/llms/anthropic/experimental_pass_through/context_management/dispatcher.py b/litellm/llms/anthropic/experimental_pass_through/context_management/dispatcher.pyindex f7af09ee62a..d86210c0ebb 100644--- a/litellm/llms/anthropic/experimental_pass_through/context_management/dispatcher.py+++ b/litellm/llms/anthropic/experimental_pass_through/context_management/dispatcher.py@@ -1,7 +1,8 @@"""Dispatch ``context_management`` edits to registered polyfill editors."""import inspect-from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union, cast+from collections.abc import Awaitable, Callable+from typing import Any, Dict, List, Optional, Tuple, Union, castfrom litellm._logging import verbose_loggerfrom litellm.types.llms.anthropic import AppliedEditdiff --git a/litellm/llms/anthropic/experimental_pass_through/messages/agentic_streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/messages/agentic_streaming_iterator.pyindex 4bf36a0d5c6..3e3d9c19af9 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/agentic_streaming_iterator.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/agentic_streaming_iterator.py@@ -9,7 +9,8 @@ follow-up response is chained as Phase 2 of the same iterator."""import json-from typing import Any, AsyncIterator, Dict, List, Optional, cast+from collections.abc import AsyncIterator+from typing import Any, Dict, List, Optional, castfrom litellm._logging import verbose_loggerdiff --git a/litellm/llms/anthropic/experimental_pass_through/messages/handler.py b/litellm/llms/anthropic/experimental_pass_through/messages/handler.pyindex 1a4144de39e..2230e8fc0db 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/handler.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/handler.py@@ -7,13 +7,11 @@import asyncioimport contextvars+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom functools import partialfrom typing import (Any,- AsyncIterator,- Coroutine,Dict,- Iterator,List,Optional,Union,@@ -39,10 +37,9 @@ from litellm.types.router import GenericLiteLLMParamsfrom litellm.types.utils import CallTypesfrom litellm.utils import ProviderConfigManager, client-from ..utils import is_reasoning_auto_summary_enabled-from ..adapters.handler import LiteLLMMessagesToCompletionTransformationHandlerfrom ..responses_adapters.handler import LiteLLMMessagesToResponsesAPIHandler+from ..utils import is_reasoning_auto_summary_enabledfrom .interceptors import get_messages_interceptorsfrom .utils import AnthropicMessagesRequestUtils, mock_responsediff --git a/litellm/llms/anthropic/experimental_pass_through/messages/interceptors/advisor.py b/litellm/llms/anthropic/experimental_pass_through/messages/interceptors/advisor.pyindex a36f825951a..af1284b6c62 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/interceptors/advisor.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/interceptors/advisor.py@@ -15,17 +15,18 @@ How it works:"""import uuid-from typing import Any, AsyncIterator, Dict, List, Optional, Union+from collections.abc import AsyncIterator+from typing import Any, Dict, List, Optional, Unionimport litellmimport litellm.constants as _cfrom litellm.litellm_core_utils.url_utils import validate_urlfrom litellm.llms.anthropic.common_utils import strip_advisor_blocks_from_messagesfrom litellm.router_utils.cooldown_handlers import mark_advisor_orchestration_failure+from litellm.types.llms.anthropic import ANTHROPIC_ADVISOR_TOOL_TYPEfrom litellm.types.llms.anthropic_messages.anthropic_response import (AnthropicMessagesResponse,)-from litellm.types.llms.anthropic import ANTHROPIC_ADVISOR_TOOL_TYPEADVISOR_MAX_USES: int = _c.ADVISOR_MAX_USESADVISOR_NATIVE_PROVIDERS: frozenset = _c.ADVISOR_NATIVE_PROVIDERSdiff --git a/litellm/llms/anthropic/experimental_pass_through/messages/interceptors/base.py b/litellm/llms/anthropic/experimental_pass_through/messages/interceptors/base.pyindex 7b0334a3524..922c668e9c8 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/interceptors/base.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/interceptors/base.py@@ -1,5 +1,6 @@from abc import ABC, abstractmethod-from typing import AsyncIterator, Dict, List, Optional, Union+from collections.abc import AsyncIterator+from typing import Dict, List, Optional, Unionfrom litellm.types.llms.anthropic_messages.anthropic_response import (AnthropicMessagesResponse,diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/mcp_handler.py b/litellm/llms/anthropic/experimental_pass_through/messages/mcp_handler.pyindex 813d4a62089..92dcfe9e5b1 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/mcp_handler.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/mcp_handler.py@@ -7,7 +7,8 @@ tool through a ``tool_use`` content block, and results are fed back as``tool_result`` blocks in a user message."""-from typing import Any, AsyncIterator, Mapping, Sequence, Union+from collections.abc import AsyncIterator, Mapping, Sequence+from typing import Any, Unionfrom litellm._logging import verbose_loggerfrom litellm.responses.mcp.request_context import MCPRequestContextdiff --git a/litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.pyindex 5f2b23d7eca..38c13e69ad7 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.py@@ -1,7 +1,8 @@import asyncioimport json+from collections.abc import AsyncIteratorfrom datetime import datetime-from typing import Any, AsyncIterator, List, Protocol, Union, runtime_checkable+from typing import Any, List, Protocol, Union, runtime_checkableimport httpxfrom pydantic import TypeAdapterdiff --git a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.pyindex b2cef62cc50..f82868bc1e1 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py@@ -1,4 +1,5 @@-from typing import Any, AsyncIterator, Dict, List, Optional, Tuple+from collections.abc import AsyncIterator+from typing import Any, Dict, List, Optional, Tupleimport httpxdiff --git a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/handler.pyindex 7911845a598..d98d984de4f 100644--- a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/handler.py+++ b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/handler.py@@ -4,7 +4,8 @@ Handler for the Anthropic v1/messages -> OpenAI Responses API path.Used when the target model is an OpenAI or Azure model."""-from typing import Any, AsyncIterator, Coroutine, Dict, List, Optional, Union+from collections.abc import AsyncIterator, Coroutine+from typing import Any, Dict, List, Optional, Unionimport litellmfrom litellm.types.llms.anthropic import AnthropicMessagesRequestdiff --git a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.pyindex 4fd49a35417..29c9f3d059b 100644--- a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py+++ b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py@@ -3,7 +3,8 @@import jsonimport tracebackfrom collections import deque-from typing import Any, AsyncIterator, Dict+from collections.abc import AsyncIterator+from typing import Any, Dictfrom litellm import verbose_loggerfrom litellm._uuid import uuiddiff --git a/litellm/llms/anthropic/files/handler.py b/litellm/llms/anthropic/files/handler.pyindex ccd12d1adb1..ef86029de58 100644--- a/litellm/llms/anthropic/files/handler.py+++ b/litellm/llms/anthropic/files/handler.py@@ -1,7 +1,8 @@import asyncioimport jsonimport time-from typing import Any, Coroutine, Optional, Union+from collections.abc import Coroutine+from typing import Any, Optional, Unionimport httpxdiff --git a/litellm/llms/aws_polly/text_to_speech/transformation.py b/litellm/llms/aws_polly/text_to_speech/transformation.pyindex c85bc9c4032..dcbed3d94df 100644--- a/litellm/llms/aws_polly/text_to_speech/transformation.py+++ b/litellm/llms/aws_polly/text_to_speech/transformation.py@@ -6,7 +6,8 @@ Reference: https://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html"""import json-from typing import TYPE_CHECKING, Any, Coroutine, Dict, Optional, Tuple, Union+from collections.abc import Coroutine+from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Unionimport httpxdiff --git a/litellm/llms/azure/assistants.py b/litellm/llms/azure/assistants.pyindex 08a04d0c8c7..2bd34ba6a3e 100644--- a/litellm/llms/azure/assistants.py+++ b/litellm/llms/azure/assistants.py@@ -1,4 +1,5 @@-from typing import Any, Coroutine, Dict, Iterable, Literal, Optional, Union+from collections.abc import Coroutine, Iterable+from typing import Any, Dict, Literal, Optional, Unionimport httpxfrom openai import AsyncAzureOpenAI, AzureOpenAIdiff --git a/litellm/llms/azure/audio_transcriptions.py b/litellm/llms/azure/audio_transcriptions.pyindex a39f86fd5b1..14737714c97 100644--- a/litellm/llms/azure/audio_transcriptions.py+++ b/litellm/llms/azure/audio_transcriptions.py@@ -1,9 +1,10 @@-from litellm._uuid import uuid-from typing import Any, Coroutine, Optional, Union+from collections.abc import Coroutine+from typing import Any, Optional, Unionfrom openai import AsyncAzureOpenAI, AzureOpenAIfrom pydantic import BaseModel+from litellm._uuid import uuidfrom litellm.litellm_core_utils.audio_utils.utils import get_audio_file_namefrom litellm.types.utils import FileTypesfrom litellm.utils import (diff --git a/litellm/llms/azure/azure.py b/litellm/llms/azure/azure.pyindex ccb9eb8f5c8..a01ee93daee 100644--- a/litellm/llms/azure/azure.py+++ b/litellm/llms/azure/azure.py@@ -1,7 +1,8 @@import asyncioimport jsonimport time-from typing import Any, Callable, Coroutine, Dict, List, Optional, Union+from collections.abc import Callable, Coroutine+from typing import Any, Dict, List, Optional, Unionimport httpx # type: ignorefrom openai import (diff --git a/litellm/llms/azure/chat/o_series_handler.py b/litellm/llms/azure/chat/o_series_handler.pyindex d0f5153b0eb..d6d902d67fb 100644--- a/litellm/llms/azure/chat/o_series_handler.py+++ b/litellm/llms/azure/chat/o_series_handler.py@@ -4,7 +4,8 @@ Handler file for calls to Azure OpenAI's o1/o3 family of modelsWritten separately to handle faking streaming for o1 and o3 models."""-from typing import TYPE_CHECKING, Any, Callable, Optional, Union+from collections.abc import Callable+from typing import TYPE_CHECKING, Any, Optional, Unionimport httpxdiff --git a/litellm/llms/azure/common_utils.py b/litellm/llms/azure/common_utils.pyindex 91f5793e269..36aab49c714 100644--- a/litellm/llms/azure/common_utils.py+++ b/litellm/llms/azure/common_utils.py@@ -2,7 +2,8 @@ import asyncioimport hashlibimport jsonimport os-from typing import Any, Callable, Dict, Literal, NamedTuple, Optional, Union, cast+from collections.abc import Callable+from typing import Any, Dict, Literal, NamedTuple, Optional, Union, castimport httpxfrom openai import AsyncAzureOpenAI, AsyncOpenAI, AzureOpenAI, OpenAIdiff --git a/litellm/llms/azure/completion/handler.py b/litellm/llms/azure/completion/handler.pyindex 2c0b67a9e56..a9c7b9f459c 100644--- a/litellm/llms/azure/completion/handler.py+++ b/litellm/llms/azure/completion/handler.py@@ -1,4 +1,5 @@-from typing import Any, Callable, Optional+from collections.abc import Callable+from typing import Any, Optionalfrom openai import AsyncAzureOpenAI, AzureOpenAIdiff --git a/litellm/llms/azure/files/handler.py b/litellm/llms/azure/files/handler.pyindex 8b277bdd49a..7efffd5a102 100644--- a/litellm/llms/azure/files/handler.py+++ b/litellm/llms/azure/files/handler.py@@ -1,4 +1,5 @@-from typing import Any, Coroutine, Optional, Union, cast+from collections.abc import Coroutine+from typing import Any, Optional, Union, castimport httpxfrom openai import AsyncAzureOpenAI, AsyncOpenAI, AzureOpenAI, OpenAIdiff --git a/litellm/llms/azure/fine_tuning/handler.py b/litellm/llms/azure/fine_tuning/handler.pyindex f4a4166c8b4..100b5c43d90 100644--- a/litellm/llms/azure/fine_tuning/handler.py+++ b/litellm/llms/azure/fine_tuning/handler.py@@ -1,4 +1,5 @@-from typing import Any, Coroutine, Dict, Optional, Union, cast+from collections.abc import Coroutine+from typing import Any, Dict, Optional, Union, castimport httpxfrom openai import AsyncAzureOpenAI, AsyncOpenAI, AzureOpenAI, OpenAIdiff --git a/litellm/llms/azure/text_to_speech/transformation.py b/litellm/llms/azure/text_to_speech/transformation.pyindex c3e5f16b03a..31caf624ffc 100644--- a/litellm/llms/azure/text_to_speech/transformation.py+++ b/litellm/llms/azure/text_to_speech/transformation.py@@ -4,7 +4,8 @@ Azure AVA (Cognitive Services) Text-to-Speech transformationMaps OpenAI TTS spec to Azure Cognitive Services TTS API"""-from typing import TYPE_CHECKING, Any, Coroutine, Dict, Optional, Tuple, Union+from collections.abc import Coroutine+from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Unionfrom urllib.parse import urlparseimport httpxdiff --git a/litellm/llms/azure_ai/agents/handler.py b/litellm/llms/azure_ai/agents/handler.pyindex 6083580ed45..2061ba70a94 100644--- a/litellm/llms/azure_ai/agents/handler.py+++ b/litellm/llms/azure_ai/agents/handler.py@@ -22,11 +22,10 @@ import asyncioimport jsonimport timeimport uuid+from collections.abc import AsyncIterator, Callablefrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Callable,Dict,List,Optional,diff --git a/litellm/llms/azure_ai/anthropic/handler.py b/litellm/llms/azure_ai/anthropic/handler.pyindex d510e5bd13e..b7a441169dd 100644--- a/litellm/llms/azure_ai/anthropic/handler.py+++ b/litellm/llms/azure_ai/anthropic/handler.py@@ -4,7 +4,8 @@ Azure Anthropic handler - reuses AnthropicChatCompletion logic with Azure authenimport copyimport json-from typing import TYPE_CHECKING, Callable, Union+from collections.abc import Callable+from typing import TYPE_CHECKING, Unionimport httpxdiff --git a/litellm/llms/base_llm/anthropic_messages/transformation.py b/litellm/llms/base_llm/anthropic_messages/transformation.pyindex 448c1d07009..146912347d8 100644--- a/litellm/llms/base_llm/anthropic_messages/transformation.py+++ b/litellm/llms/base_llm/anthropic_messages/transformation.py@@ -1,5 +1,6 @@from abc import ABC, abstractmethod-from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, List, Optional, Tuple, Union+from collections.abc import AsyncIterator+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Unionimport httpxdiff --git a/litellm/llms/base_llm/bridges/completion_transformation.py b/litellm/llms/base_llm/bridges/completion_transformation.pyindex 911f53fb76f..7e6899b96e4 100644--- a/litellm/llms/base_llm/bridges/completion_transformation.py+++ b/litellm/llms/base_llm/bridges/completion_transformation.py@@ -3,7 +3,8 @@ Bridge for transforming API requests to another API requests"""from abc import ABC, abstractmethod-from typing import TYPE_CHECKING, Any, AsyncIterator, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import TYPE_CHECKING, Any, List, Optional, Unionif TYPE_CHECKING:from pydantic import BaseModeldiff --git a/litellm/llms/base_llm/chat/transformation.py b/litellm/llms/base_llm/chat/transformation.pyindex ab901a467e8..01e133cd5a7 100644--- a/litellm/llms/base_llm/chat/transformation.py+++ b/litellm/llms/base_llm/chat/transformation.py@@ -4,11 +4,10 @@ Common base config for all LLM providersimport typesfrom abc import ABC, abstractmethod+from collections.abc import AsyncIterator, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Iterator,List,Optional,Tuple,diff --git a/litellm/llms/base_llm/files/transformation.py b/litellm/llms/base_llm/files/transformation.pyindex a9b99eb06fc..e5ae92d4b9c 100644--- a/litellm/llms/base_llm/files/transformation.py+++ b/litellm/llms/base_llm/files/transformation.py@@ -1,5 +1,6 @@from abc import ABC, abstractmethod-from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Union+from collections.abc import Iterator+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Unionimport httpxfrom openai.types.file_deleted import FileDeleteddiff --git a/litellm/llms/bedrock/base_aws_llm.py b/litellm/llms/bedrock/base_aws_llm.pyindex 6b89fb69739..03d443c5081 100644--- a/litellm/llms/bedrock/base_aws_llm.py+++ b/litellm/llms/bedrock/base_aws_llm.py@@ -4,11 +4,11 @@ import jsonimport osimport reimport urllib.parse+from collections.abc import Callablefrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- Callable,ClassVar,Dict,Literal,diff --git a/litellm/llms/bedrock/chat/invoke_handler.py b/litellm/llms/bedrock/chat/invoke_handler.pyindex c28627d5aec..9a2576b9dd4 100644--- a/litellm/llms/bedrock/chat/invoke_handler.py+++ b/litellm/llms/bedrock/chat/invoke_handler.py@@ -1,7 +1,6 @@import types+from collections.abc import AsyncIterator, Iteratorfrom typing import (- AsyncIterator,- Iterator,Optional,Tuple,cast,@@ -37,14 +36,12 @@ from litellm.types.utils import (ChatCompletionMessageToolCall,Choices,Delta,-)-from litellm.types.utils import GenericStreamingChunk as GChunk-from litellm.types.utils import (ModelResponse,ModelResponseStream,StreamingChoices,Usage,)+from litellm.types.utils import GenericStreamingChunk as GChunkfrom ..common_utils import (BedrockError,diff --git a/litellm/llms/bedrock/chat/mantle/transformation.py b/litellm/llms/bedrock/chat/mantle/transformation.pyindex d7ffff65ff0..d7deade8df9 100644--- a/litellm/llms/bedrock/chat/mantle/transformation.py+++ b/litellm/llms/bedrock/chat/mantle/transformation.py@@ -7,7 +7,8 @@ The bedrock-mantle endpoint uses the Anthropic Messages API format but is servedat a different endpoint (bedrock-mantle.{region}.api.aws) with AWS SigV4 auth."""-from typing import TYPE_CHECKING, Any, AsyncIterator, Iterator, List, Optional+from collections.abc import AsyncIterator, Iterator+from typing import TYPE_CHECKING, Any, List, Optionalfrom litellm.llms.bedrock.chat.invoke_transformations.anthropic_claude3_transformation import (AmazonAnthropicClaudeConfig,diff --git a/litellm/llms/bedrock/common_utils.py b/litellm/llms/bedrock/common_utils.pyindex 93998f0610e..a6615a23866 100644--- a/litellm/llms/bedrock/common_utils.py+++ b/litellm/llms/bedrock/common_utils.py@@ -9,13 +9,13 @@ import functoolsimport jsonimport osimport re+from collections.abc import Mappingfrom typing import (TYPE_CHECKING,Any,Dict,List,Literal,- Mapping,Optional,TypedDict,Union,diff --git a/litellm/llms/bedrock/embed/embedding.py b/litellm/llms/bedrock/embed/embedding.pyindex ff138709ac0..0e82baad74b 100644--- a/litellm/llms/bedrock/embed/embedding.py+++ b/litellm/llms/bedrock/embed/embedding.py@@ -5,7 +5,8 @@ Handles embedding calls to Bedrock's `/invoke` endpointimport copyimport jsonimport urllib.parse-from typing import Any, Callable, List, Optional, Tuple, Union, get_args+from collections.abc import Callable+from typing import Any, List, Optional, Tuple, Union, get_argsimport httpxdiff --git a/litellm/llms/bedrock/files/handler.py b/litellm/llms/bedrock/files/handler.pyindex 8c6282d627e..5015ebe5774 100644--- a/litellm/llms/bedrock/files/handler.py+++ b/litellm/llms/bedrock/files/handler.py@@ -1,6 +1,6 @@import asyncio-from collections.abc import Mapping-from typing import Any, Coroutine, Optional, Tuple, Union+from collections.abc import Coroutine, Mapping+from typing import Any, Optional, Tuple, Unionimport httpxdiff --git a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.pyindex 08c13448d8c..7b6084c03fc 100644--- a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py+++ b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py@@ -1,7 +1,7 @@+from collections.abc import AsyncIteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,Dict,List,Optional,@@ -53,9 +53,8 @@ from litellm.types.llms.anthropic import (from litellm.types.llms.bedrock import BedrockInvokeAnthropicMessagesRequestfrom litellm.types.llms.openai import AllMessageValuesfrom litellm.types.router import GenericLiteLLMParams-from litellm.types.utils import GenericStreamingChunk+from litellm.types.utils import GenericStreamingChunk, ModelResponseStreamfrom litellm.types.utils import GenericStreamingChunk as GChunk-from litellm.types.utils import ModelResponseStreamfrom litellm.utils import _supports_factoryif TYPE_CHECKING:diff --git a/litellm/llms/bedrock/messages/mantle_transformation.py b/litellm/llms/bedrock/messages/mantle_transformation.pyindex 65a2ab3b9a7..2be6ba736c2 100644--- a/litellm/llms/bedrock/messages/mantle_transformation.py+++ b/litellm/llms/bedrock/messages/mantle_transformation.py@@ -6,7 +6,8 @@ AmazonAnthropicClaudeMessagesConfig. Overrides only the URL and model-prefixstripping that are specific to the bedrock-mantle endpoint."""-from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, List, Optional, Tuple+from collections.abc import AsyncIterator+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tupleimport httpxdiff --git a/litellm/llms/bedrock_mantle/chat/transformation.py b/litellm/llms/bedrock_mantle/chat/transformation.pyindex 8fc720daa29..007258b50f6 100644--- a/litellm/llms/bedrock_mantle/chat/transformation.py+++ b/litellm/llms/bedrock_mantle/chat/transformation.py@@ -10,7 +10,8 @@ Auth: Bearer token (litellm_params.api_key, BEDROCK_MANTLE_API_KEY, or theBedrockMantleAuthMixin in common_utils."""-from typing import Iterator, AsyncIterator, Any, List, Optional, Tuple, Union+from collections.abc import AsyncIterator, Iterator+from typing import Any, List, Optional, Tuple, Unionimport litellmfrom litellm._logging import verbose_logger@@ -23,8 +24,8 @@ from litellm.secret_managers.main import get_secret_strfrom litellm.types.llms.openai import AllMessageValuesfrom litellm.types.router import GenericLiteLLMParams-from ..common_utils import mantle_base_segmentfrom ...openai_like.chat.transformation import OpenAILikeChatConfig+from ..common_utils import mantle_base_segmentclass BedrockMantleChatConfig(BedrockMantleAuthMixin, OpenAILikeChatConfig):diff --git a/litellm/llms/codestral/completion/handler.py b/litellm/llms/codestral/completion/handler.pyindex 6a91601e6fc..b369898f4ab 100644--- a/litellm/llms/codestral/completion/handler.py+++ b/litellm/llms/codestral/completion/handler.py@@ -2,8 +2,9 @@## handler file for TextCompletionCodestral Integration - https://codestral.com/import json+from collections.abc import Callablefrom functools import partial-from typing import Callable, List, Optional, Union+from typing import List, Optional, Unionimport httpx # type: ignorediff --git a/litellm/llms/cohere/chat/transformation.py b/litellm/llms/cohere/chat/transformation.pyindex 10eea949390..b30817cb7c3 100644--- a/litellm/llms/cohere/chat/transformation.py+++ b/litellm/llms/cohere/chat/transformation.py@@ -1,6 +1,7 @@import jsonimport time-from typing import TYPE_CHECKING, Any, AsyncIterator, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import TYPE_CHECKING, Any, List, Optional, Unionimport httpxdiff --git a/litellm/llms/cohere/chat/v2_transformation.py b/litellm/llms/cohere/chat/v2_transformation.pyindex 909130077e4..a08411745d9 100644--- a/litellm/llms/cohere/chat/v2_transformation.py+++ b/litellm/llms/cohere/chat/v2_transformation.py@@ -1,22 +1,22 @@import time-from typing import TYPE_CHECKING, Any, AsyncIterator, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import TYPE_CHECKING, Any, List, Optional, Unionimport httpximport litellmfrom litellm.llms.base_llm.chat.transformation import BaseLLMException+from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfigfrom litellm.types.llms.cohere import CohereV2ChatResponsefrom litellm.types.llms.openai import (AllMessageValues,- ChatCompletionToolCallChunk,ChatCompletionAnnotation,ChatCompletionAnnotationURLCitation,+ ChatCompletionToolCallChunk,)-from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfigfrom litellm.types.utils import ModelResponse, Usage-from ..common_utils import CohereError-from ..common_utils import CohereV2ModelResponseIterator+from ..common_utils import CohereError, CohereV2ModelResponseIteratorfrom ..common_utils import validate_environment as cohere_validate_environmentif TYPE_CHECKING:diff --git a/litellm/llms/cohere/embed/handler.py b/litellm/llms/cohere/embed/handler.pyindex bd2859fa3dc..4699d55c356 100644--- a/litellm/llms/cohere/embed/handler.py+++ b/litellm/llms/cohere/embed/handler.py@@ -3,7 +3,8 @@ Legacy /v1/embedding handler for Bedrock Cohere."""import json-from typing import Any, Callable, Optional, Union+from collections.abc import Callable+from typing import Any, Optional, Unionimport httpxdiff --git a/litellm/llms/cometapi/chat/transformation.py b/litellm/llms/cometapi/chat/transformation.pyindex 1a0a3e88547..56d230057de 100644--- a/litellm/llms/cometapi/chat/transformation.py+++ b/litellm/llms/cometapi/chat/transformation.py@@ -5,7 +5,8 @@ Based on OpenAI-compatible API interface implementationDocumentation: [CometAPI Documentation Link]"""-from typing import Any, AsyncIterator, Iterator, List, Optional, Tuple, Union+from collections.abc import AsyncIterator, Iterator+from typing import Any, List, Optional, Tuple, Unionimport httpxdiff --git a/litellm/llms/custom_httpx/aiohttp_handler.py b/litellm/llms/custom_httpx/aiohttp_handler.pyindex 9726314409b..dd78f677795 100644--- a/litellm/llms/custom_httpx/aiohttp_handler.py+++ b/litellm/llms/custom_httpx/aiohttp_handler.py@@ -1,4 +1,5 @@-from typing import TYPE_CHECKING, Any, Callable, Optional, Tuple, Union, cast+from collections.abc import Callable+from typing import TYPE_CHECKING, Any, Optional, Tuple, Union, castimport aiohttpimport httpx # type: ignore@@ -12,12 +13,12 @@ from litellm.llms.base_llm.chat.transformation import BaseConfigfrom litellm.llms.base_llm.image_variations.transformation import (BaseImageVariationConfig,)+from litellm.llms.custom_httpx.aiohttp_transport import LiteLLMAiohttpTransportfrom litellm.llms.custom_httpx.http_handler import (AsyncHTTPHandler,HTTPHandler,_get_httpx_client,)-from litellm.llms.custom_httpx.aiohttp_transport import LiteLLMAiohttpTransportfrom litellm.types.llms.openai import FileTypesfrom litellm.types.utils import HttpHandlerRequestFields, ImageResponse, LlmProvidersfrom litellm.utils import CustomStreamWrapper, ModelResponse, ProviderConfigManagerdiff --git a/litellm/llms/custom_httpx/aiohttp_transport.py b/litellm/llms/custom_httpx/aiohttp_transport.pyindex 2c5f455692c..ac1785ed1ea 100644--- a/litellm/llms/custom_httpx/aiohttp_transport.py+++ b/litellm/llms/custom_httpx/aiohttp_transport.py@@ -5,7 +5,8 @@ import osimport sslimport typingimport urllib.request-from typing import Any, Callable, ClassVar, Dict, Optional, Union+from collections.abc import Callable+from typing import Any, ClassVar, Dict, Optional, Unionimport aiohttpimport aiohttp.client_exceptionsdiff --git a/litellm/llms/custom_httpx/container_handler.py b/litellm/llms/custom_httpx/container_handler.pyindex 7d6a25bc090..351b5e2216f 100644--- a/litellm/llms/custom_httpx/container_handler.py+++ b/litellm/llms/custom_httpx/container_handler.py@@ -6,8 +6,9 @@ endpoint defined in endpoints.json, eliminating the need for individual handler"""import json+from collections.abc import Coroutinefrom pathlib import Path-from typing import TYPE_CHECKING, Any, Coroutine, Dict, Optional, Type, Union+from typing import TYPE_CHECKING, Any, Dict, Optional, Type, Unionimport httpxdiff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.pyindex c92f8bcc937..148da723399 100644--- a/litellm/llms/custom_httpx/http_handler.py+++ b/litellm/llms/custom_httpx/http_handler.py@@ -6,13 +6,12 @@ import socketimport sslimport sysimport time+from collections.abc import Callable, Mappingfrom typing import (TYPE_CHECKING,Any,- Callable,Dict,List,- Mapping,Optional,Tuple,Union,diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.pyindex b64d8e3dc7e..f4edb8f0526 100644--- a/litellm/llms/custom_httpx/llm_http_handler.py+++ b/litellm/llms/custom_httpx/llm_http_handler.py@@ -2,18 +2,15 @@ import asyncioimport jsonimport osimport ssl+from collections.abc import AsyncIterator, Coroutine, Iterator, Mappingfrom contextlib import asynccontextmanagerfrom functools import lru_cachefrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Coroutine,Dict,- Iterator,List,Literal,- Mapping,Optional,Tuple,TypeVar,diff --git a/litellm/llms/custom_llm.py b/litellm/llms/custom_llm.pyindex e0af3986465..a5475da077b 100644--- a/litellm/llms/custom_llm.py+++ b/litellm/llms/custom_llm.py@@ -8,13 +8,10 @@- async_streaming"""+from collections.abc import AsyncIterator, Callable, Coroutine, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Callable,- Coroutine,- Iterator,Optional,Union,)diff --git a/litellm/llms/dashscope/chat/transformation.py b/litellm/llms/dashscope/chat/transformation.pyindex 743bf494d92..def3a367384 100644--- a/litellm/llms/dashscope/chat/transformation.py+++ b/litellm/llms/dashscope/chat/transformation.py@@ -2,12 +2,11 @@Translates from OpenAI's `/v1/chat/completions` to DashScope's `/v1/chat/completions`"""-from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, overload--from litellm.types.llms.openai import ChatCompletionToolParam+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Tuple, Union, overloadfrom litellm.secret_managers.main import get_secret_str-from litellm.types.llms.openai import AllMessageValues+from litellm.types.llms.openai import AllMessageValues, ChatCompletionToolParamfrom ...openai.chat.gpt_transformation import OpenAIGPTConfigdiff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.pyindex 9c05899c719..85a2eccde2f 100644--- a/litellm/llms/databricks/chat/transformation.py+++ b/litellm/llms/databricks/chat/transformation.py@@ -3,12 +3,10 @@ Translates from OpenAI's `/v1/chat/completions` to Databricks' `/chat/completion"""import os+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Coroutine,- Iterator,List,Literal,Optional,diff --git a/litellm/llms/deepinfra/chat/transformation.py b/litellm/llms/deepinfra/chat/transformation.pyindex 494c53354f7..0dd1b73f9fa 100644--- a/litellm/llms/deepinfra/chat/transformation.py+++ b/litellm/llms/deepinfra/chat/transformation.py@@ -1,5 +1,6 @@import json-from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, cast, overload+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Tuple, Union, cast, overloadimport litellmfrom litellm.constants import MIN_NON_ZERO_TEMPERATUREdiff --git a/litellm/llms/deepseek/chat/transformation.py b/litellm/llms/deepseek/chat/transformation.pyindex 525de1476e2..d04105ad614 100644--- a/litellm/llms/deepseek/chat/transformation.py+++ b/litellm/llms/deepseek/chat/transformation.py@@ -2,7 +2,8 @@Translates from OpenAI's `/v1/chat/completions` to DeepSeek's `/v1/chat/completions`"""-from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, cast, overload+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Tuple, Union, cast, overloadimport litellmfrom litellm.litellm_core_utils.prompt_templates.common_utils import (diff --git a/litellm/llms/deprecated_providers/aleph_alpha.py b/litellm/llms/deprecated_providers/aleph_alpha.pyindex f58297997b6..a9061eac453 100644--- a/litellm/llms/deprecated_providers/aleph_alpha.py+++ b/litellm/llms/deprecated_providers/aleph_alpha.py@@ -1,7 +1,8 @@import jsonimport timeimport types-from typing import Callable, Optional+from collections.abc import Callable+from typing import Optionalimport httpx # type: ignorediff --git a/litellm/llms/deprecated_providers/palm.py b/litellm/llms/deprecated_providers/palm.pyindex a8523ecfa0e..45ff8870075 100644--- a/litellm/llms/deprecated_providers/palm.py+++ b/litellm/llms/deprecated_providers/palm.py@@ -2,7 +2,8 @@ import copyimport timeimport tracebackimport types-from typing import Callable, Optional+from collections.abc import Callable+from typing import Optionalimport httpxdiff --git a/litellm/llms/docker_model_runner/chat/transformation.py b/litellm/llms/docker_model_runner/chat/transformation.pyindex 137a39e0984..2db070699dd 100644--- a/litellm/llms/docker_model_runner/chat/transformation.py+++ b/litellm/llms/docker_model_runner/chat/transformation.py@@ -4,7 +4,8 @@ Translates from OpenAI's `/v1/chat/completions` to Docker Model Runner's `/enginDocker Model Runner API Reference: https://docs.docker.com/ai/model-runner/api-reference/"""-from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, overload+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Tuple, Union, overloadfrom litellm.litellm_core_utils.prompt_templates.common_utils import (handle_messages_with_content_list_to_str_conversion,diff --git a/litellm/llms/fireworks_ai/chat/transformation.py b/litellm/llms/fireworks_ai/chat/transformation.pyindex eeae8c76888..e1228ef05d7 100644--- a/litellm/llms/fireworks_ai/chat/transformation.py+++ b/litellm/llms/fireworks_ai/chat/transformation.py@@ -1,8 +1,7 @@import json+from collections.abc import AsyncIterator, Iteratorfrom typing import (Any,- AsyncIterator,- Iterator,List,Literal,Optional,@@ -18,10 +17,10 @@ from litellm._logging import verbose_loggerfrom litellm._uuid import uuidfrom litellm.constants import RESPONSE_FORMAT_TOOL_NAMEfrom litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj-from litellm.litellm_core_utils.prompt_templates.common_utils import unpack_legacy_defsfrom litellm.litellm_core_utils.llm_response_utils.get_headers import (get_response_headers,)+from litellm.litellm_core_utils.prompt_templates.common_utils import unpack_legacy_defsfrom litellm.secret_managers.main import get_secret_strfrom litellm.types.llms.openai import (AllMessageValues,@@ -48,7 +47,7 @@ from ...openai.chat.gpt_transformation import (OpenAIChatCompletionStreamingHandler,OpenAIGPTConfig,)-from ..common_utils import FireworksAIMixin, FireworksAIException+from ..common_utils import FireworksAIException, FireworksAIMixindef _extract_fireworks_hidden_params(payload: dict) -> dict:diff --git a/litellm/llms/gemini/common_utils.py b/litellm/llms/gemini/common_utils.pyindex f02e25c5735..3367c65f8d5 100644--- a/litellm/llms/gemini/common_utils.py+++ b/litellm/llms/gemini/common_utils.py@@ -2,7 +2,8 @@ import base64import datetimeimport jsonimport math-from typing import Any, Dict, List, Optional, Sequence, Union+from collections.abc import Sequence+from typing import Any, Dict, List, Optional, Unionimport httpxdiff --git a/litellm/llms/gigachat/chat/transformation.py b/litellm/llms/gigachat/chat/transformation.pyindex dbf04fd015d..6c9bbea2970 100644--- a/litellm/llms/gigachat/chat/transformation.py+++ b/litellm/llms/gigachat/chat/transformation.py@@ -7,7 +7,8 @@ Transforms OpenAI-format requests to GigaChat format and back.import jsonimport timeimport uuid-from typing import TYPE_CHECKING, Any, AsyncIterator, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import TYPE_CHECKING, Any, List, Optional, Unionimport httpxdiff --git a/litellm/llms/groq/chat/handler.py b/litellm/llms/groq/chat/handler.pyindex 2553af6df77..0cddc13243f 100644--- a/litellm/llms/groq/chat/handler.py+++ b/litellm/llms/groq/chat/handler.py@@ -2,7 +2,8 @@Handles the chat completion request for groq"""-from typing import Callable, List, Optional, Union, cast+from collections.abc import Callable+from typing import List, Optional, Union, castfrom httpx._config import Timeoutdiff --git a/litellm/llms/groq/chat/transformation.py b/litellm/llms/groq/chat/transformation.pyindex 089c0cac62c..2af71b77fcd 100644--- a/litellm/llms/groq/chat/transformation.py+++ b/litellm/llms/groq/chat/transformation.py@@ -2,9 +2,9 @@Translate from OpenAI's `/v1/chat/completions` to Groq's `/v1/chat/completions`"""+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom typing import (Any,- Coroutine,List,Literal,Optional,@@ -12,22 +12,18 @@ from typing import (Union,cast,overload,- Iterator,- AsyncIterator,)import httpx--from litellm.llms.openai.chat.gpt_transformation import (- OpenAIChatCompletionStreamingHandler,-)-from litellm.llms.openai.common_utils import OpenAIError-from pydantic import BaseModelimport litellmfrom litellm._logging import verbose_loggerfrom litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj+from litellm.llms.openai.chat.gpt_transformation import (+ OpenAIChatCompletionStreamingHandler,+)+from litellm.llms.openai.common_utils import OpenAIErrorfrom litellm.secret_managers.main import get_secret_strfrom litellm.types.llms.openai import (AllMessageValues,diff --git a/litellm/llms/heroku/chat/transformation.py b/litellm/llms/heroku/chat/transformation.pyindex 2efa9fe673f..2935f73c762 100644--- a/litellm/llms/heroku/chat/transformation.py+++ b/litellm/llms/heroku/chat/transformation.py@@ -5,13 +5,14 @@ this is OpenAI compatible - no translation needed / occurs"""import os+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Tuple, Union, overload-from typing import Optional, List, Tuple, Union, Coroutine, Any, Literal, overloadfrom litellm.litellm_core_utils.prompt_templates.common_utils import (handle_messages_with_content_list_to_str_conversion,)-from litellm.types.llms.openai import AllMessageValuesfrom litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig+from litellm.types.llms.openai import AllMessageValues# Base error class for Herokudiff --git a/litellm/llms/hosted_vllm/chat/transformation.py b/litellm/llms/hosted_vllm/chat/transformation.pyindex db98749eae0..8b5dff1fed8 100644--- a/litellm/llms/hosted_vllm/chat/transformation.py+++ b/litellm/llms/hosted_vllm/chat/transformation.py@@ -3,9 +3,9 @@ Translate from OpenAI's `/v1/chat/completions` to VLLM's `/v1/chat/completions`"""import json+from collections.abc import Coroutinefrom typing import (Any,- Coroutine,Dict,List,Literal,diff --git a/litellm/llms/huggingface/embedding/handler.py b/litellm/llms/huggingface/embedding/handler.pyindex f72a79e084d..6aa5706c40b 100644--- a/litellm/llms/huggingface/embedding/handler.py+++ b/litellm/llms/huggingface/embedding/handler.py@@ -1,6 +1,7 @@import jsonimport os-from typing import Any, Callable, Dict, List, Literal, Optional, Union, get_args+from collections.abc import Callable+from typing import Any, Dict, List, Literal, Optional, Union, get_argsimport httpxdiff --git a/litellm/llms/litellm_proxy/skills/transformation.py b/litellm/llms/litellm_proxy/skills/transformation.pyindex 7fa58ad9df2..eb1ac290807 100644--- a/litellm/llms/litellm_proxy/skills/transformation.py+++ b/litellm/llms/litellm_proxy/skills/transformation.py@@ -7,7 +7,8 @@ API requests to database operations via LiteLLMSkillsHandler.Pattern follows litellm/llms/litellm_proxy/responses/transformation.py"""-from typing import TYPE_CHECKING, Any, Coroutine, Dict, List, Optional, Union+from collections.abc import Coroutine+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Unionfrom litellm.types.llms.anthropic_skills import (DeleteSkillResponse,diff --git a/litellm/llms/mistral/chat/transformation.py b/litellm/llms/mistral/chat/transformation.pyindex 0f202a22c96..62b3ef92c48 100644--- a/litellm/llms/mistral/chat/transformation.py+++ b/litellm/llms/mistral/chat/transformation.py@@ -6,11 +6,9 @@ Why separate file? Make it easy to see how transformation worksDocs - https://docs.mistral.ai/api/"""+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom typing import (Any,- AsyncIterator,- Coroutine,- Iterator,List,Literal,Optional,@@ -29,8 +27,8 @@ from litellm.litellm_core_utils.prompt_templates.common_utils import (strip_none_values_from_message,)from litellm.llms.openai.chat.gpt_transformation import (- OpenAIGPTConfig,OpenAIChatCompletionStreamingHandler,+ OpenAIGPTConfig,)from litellm.secret_managers.main import get_secret_strfrom litellm.types.llms.mistral import MistralThinkingBlock, MistralToolCallMessagediff --git a/litellm/llms/modelscope/chat/transformation.py b/litellm/llms/modelscope/chat/transformation.pyindex 1a54be6e1c8..4625b29d627 100644--- a/litellm/llms/modelscope/chat/transformation.py+++ b/litellm/llms/modelscope/chat/transformation.py@@ -2,7 +2,8 @@Translates from OpenAI's `/v1/chat/completions` to ModelScope's `/v1/chat/completions`"""-from typing import Any, Coroutine, Literal, Optional, Tuple, Union, cast, overload+from collections.abc import Coroutine+from typing import Any, Literal, Optional, Tuple, Union, cast, overloadfrom typing_extensions import overridediff --git a/litellm/llms/moonshot/chat/transformation.py b/litellm/llms/moonshot/chat/transformation.pyindex 07a963e95fd..bcd63827324 100644--- a/litellm/llms/moonshot/chat/transformation.py+++ b/litellm/llms/moonshot/chat/transformation.py@@ -2,7 +2,8 @@Translates from OpenAI's `/v1/chat/completions` to Moonshot AI's `/v1/chat/completions`"""-from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, cast, overload+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Tuple, Union, cast, overloadimport litellmfrom litellm.litellm_core_utils.prompt_templates.common_utils import (diff --git a/litellm/llms/nlp_cloud/chat/handler.py b/litellm/llms/nlp_cloud/chat/handler.pyindex b0563d8b553..a9f1c600492 100644--- a/litellm/llms/nlp_cloud/chat/handler.py+++ b/litellm/llms/nlp_cloud/chat/handler.py@@ -1,5 +1,6 @@import json-from typing import Callable, Optional, Union+from collections.abc import Callable+from typing import Optional, Unionimport litellmfrom litellm.llms.custom_httpx.http_handler import (diff --git a/litellm/llms/oci/chat/transformation.py b/litellm/llms/oci/chat/transformation.pyindex 496656dd5ac..a90e19ad9eb 100644--- a/litellm/llms/oci/chat/transformation.py+++ b/litellm/llms/oci/chat/transformation.py@@ -10,12 +10,11 @@ implement the LiteLLM BaseConfig interface. Heavy-lifting lives in:"""import json+from collections.abc import AsyncIterator, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,Dict,- Iterator,List,Optional,Tuple,@@ -27,6 +26,7 @@ import httpximport litellmfrom litellm.constants import DEFAULT_OCI_CHAT_MAX_TOKENSfrom litellm.litellm_core_utils.logging_utils import track_llm_api_timing+from litellm.litellm_core_utils.streaming_handler import CustomStreamWrapperfrom litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMExceptionfrom litellm.llms.custom_httpx.http_handler import (AsyncHTTPHandler,@@ -71,7 +71,6 @@ from litellm.types.utils import (ModelResponseStream,)from litellm.utils import supports_reasoning-from litellm.litellm_core_utils.streaming_handler import CustomStreamWrapperif TYPE_CHECKING:from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObjdiff --git a/litellm/llms/ollama/chat/transformation.py b/litellm/llms/ollama/chat/transformation.pyindex 694f8cdd6c2..2917e86b58e 100644--- a/litellm/llms/ollama/chat/transformation.py+++ b/litellm/llms/ollama/chat/transformation.py@@ -1,11 +1,9 @@import jsonimport time-from litellm._uuid import uuid+from collections.abc import AsyncIterator, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Iterator,List,Optional,Union,@@ -16,6 +14,7 @@ from httpx._models import Headers, Responsefrom pydantic import BaseModelimport litellm+from litellm._uuid import uuidfrom litellm.litellm_core_utils.core_helpers import map_finish_reasonfrom litellm.litellm_core_utils.prompt_templates.common_utils import (_extract_reasoning_content,diff --git a/litellm/llms/ollama/completion/transformation.py b/litellm/llms/ollama/completion/transformation.pyindex 204b0d15c03..051e4e2b28a 100644--- a/litellm/llms/ollama/completion/transformation.py+++ b/litellm/llms/ollama/completion/transformation.py@@ -1,12 +1,13 @@import jsonimport time-from litellm._uuid import uuid-from typing import TYPE_CHECKING, Any, AsyncIterator, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import TYPE_CHECKING, Any, List, Optional, Unionfrom httpx._models import Headers, Responseimport litellmfrom litellm._logging import verbose_proxy_logger+from litellm._uuid import uuidfrom litellm.litellm_core_utils.prompt_templates.common_utils import (get_str_from_messages,)diff --git a/litellm/llms/oobabooga/chat/oobabooga.py b/litellm/llms/oobabooga/chat/oobabooga.pyindex 40d88e8e125..531baa9b43d 100644--- a/litellm/llms/oobabooga/chat/oobabooga.py+++ b/litellm/llms/oobabooga/chat/oobabooga.py@@ -1,5 +1,6 @@import json-from typing import Any, Callable, Optional+from collections.abc import Callable+from typing import Any, Optionalimport litellmfrom litellm.llms.custom_httpx.http_handler import _get_httpx_clientdiff --git a/litellm/llms/openai/chat/gpt_transformation.py b/litellm/llms/openai/chat/gpt_transformation.pyindex f2498c0a7e2..ff8bd446962 100644--- a/litellm/llms/openai/chat/gpt_transformation.py+++ b/litellm/llms/openai/chat/gpt_transformation.py@@ -3,13 +3,12 @@ Support for gpt model family"""import json+import os+from collections.abc import AsyncIterator, Coroutine, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Coroutine,Dict,- Iterator,List,Literal,Optional,@@ -18,8 +17,6 @@ from typing import (cast,overload,)--import osfrom urllib.parse import urlparseimport httpxdiff --git a/litellm/llms/openai/chat/o_series_transformation.py b/litellm/llms/openai/chat/o_series_transformation.pyindex 78a5b3512a4..6008ad332da 100644--- a/litellm/llms/openai/chat/o_series_transformation.py+++ b/litellm/llms/openai/chat/o_series_transformation.py@@ -11,7 +11,8 @@ Translations handled by LiteLLM:- Logprobs => drop param (if user opts in to dropping param)"""-from typing import Any, Coroutine, List, Literal, Optional, Union, cast, overload+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Union, cast, overloadimport litellmfrom litellm import verbose_loggerdiff --git a/litellm/llms/openai/completion/handler.py b/litellm/llms/openai/completion/handler.pyindex 376d2636ba7..d4c8139adc3 100644--- a/litellm/llms/openai/completion/handler.py+++ b/litellm/llms/openai/completion/handler.py@@ -1,5 +1,6 @@import json-from typing import Callable, List, Optional, Union+from collections.abc import Callable+from typing import List, Optional, Unionfrom openai import AsyncOpenAI, OpenAIdiff --git a/litellm/llms/openai/cost_calculation.py b/litellm/llms/openai/cost_calculation.pyindex 25376419b9e..ffb8dbb9820 100644--- a/litellm/llms/openai/cost_calculation.py+++ b/litellm/llms/openai/cost_calculation.py@@ -3,7 +3,8 @@ Helper util for handling openai-specific cost calculation- e.g.: prompt caching"""-from typing import Any, Literal, Mapping, Optional, Tuple+from collections.abc import Mapping+from typing import Any, Literal, Optional, Tuplefrom litellm._logging import verbose_loggerfrom litellm.litellm_core_utils.llm_cost_calc.utils import generic_cost_per_tokendiff --git a/litellm/llms/openai/fine_tuning/handler.py b/litellm/llms/openai/fine_tuning/handler.pyindex e0914a9ff0d..de9d7fa581a 100644--- a/litellm/llms/openai/fine_tuning/handler.py+++ b/litellm/llms/openai/fine_tuning/handler.py@@ -1,4 +1,5 @@-from typing import Any, Coroutine, Dict, Optional, Union, cast+from collections.abc import Coroutine+from typing import Any, Dict, Optional, Union, castimport httpxfrom openai import AsyncAzureOpenAI, AsyncOpenAI, AzureOpenAI, OpenAIdiff --git a/litellm/llms/openai/image_variations/handler.py b/litellm/llms/openai/image_variations/handler.pyindex 00cbb87e31d..37d3272cff5 100644--- a/litellm/llms/openai/image_variations/handler.py+++ b/litellm/llms/openai/image_variations/handler.py@@ -2,7 +2,8 @@OpenAI Image Variations Handler"""-from typing import Callable, Optional+from collections.abc import Callable+from typing import Optionalimport httpxfrom openai import AsyncOpenAI, OpenAIdiff --git a/litellm/llms/openai/openai.py b/litellm/llms/openai/openai.pyindex 8fc7e6d0ebd..d67b765edd8 100644--- a/litellm/llms/openai/openai.py+++ b/litellm/llms/openai/openai.py@@ -1,13 +1,9 @@import timeimport types+from collections.abc import AsyncIterator, Callable, Coroutine, Iterable, Iteratorfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Callable,- Coroutine,- Iterable,- Iterator,List,Literal,Optional,diff --git a/litellm/llms/openai_like/chat/handler.py b/litellm/llms/openai_like/chat/handler.pyindex 0da0f3d90f0..866cb7a9531 100644--- a/litellm/llms/openai_like/chat/handler.py+++ b/litellm/llms/openai_like/chat/handler.py@@ -5,7 +5,8 @@ For handling OpenAI-like chat completions, like IBM WatsonX, etc."""import json-from typing import Any, Callable, Optional, Union+from collections.abc import Callable+from typing import Any, Optional, Unionimport httpxdiff --git a/litellm/llms/openai_like/dynamic_config.py b/litellm/llms/openai_like/dynamic_config.pyindex 31c913d5d4e..6e6a40bed38 100644--- a/litellm/llms/openai_like/dynamic_config.py+++ b/litellm/llms/openai_like/dynamic_config.py@@ -2,7 +2,8 @@Dynamic configuration class generator for JSON-based providers."""-from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, overload+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Tuple, Union, overloadfrom litellm._logging import verbose_loggerfrom litellm.litellm_core_utils.prompt_templates.common_utils import (diff --git a/litellm/llms/openrouter/chat/transformation.py b/litellm/llms/openrouter/chat/transformation.pyindex ca287f5de04..10a3e208089 100644--- a/litellm/llms/openrouter/chat/transformation.py+++ b/litellm/llms/openrouter/chat/transformation.py@@ -6,12 +6,13 @@ Calls done in OpenAI/openai.py as OpenRouter is openai-compatible.Docs: https://openrouter.ai/docs/parameters"""+from collections.abc import AsyncIterator, Iteratorfrom enum import Enum-from typing import Any, AsyncIterator, Iterator, List, Optional, Tuple, Union, cast+from typing import Any, List, Optional, Tuple, Union, castimport httpx-import litellm+import litellmfrom litellm.llms.base_llm.base_model_iterator import BaseModelResponseIteratorfrom litellm.llms.base_llm.chat.transformation import BaseLLMExceptionfrom litellm.types.llms.openai import AllMessageValues, ChatCompletionToolParamdiff --git a/litellm/llms/petals/completion/handler.py b/litellm/llms/petals/completion/handler.pyindex 4a4a820d56d..8d0f02ddd0f 100644--- a/litellm/llms/petals/completion/handler.py+++ b/litellm/llms/petals/completion/handler.py@@ -1,5 +1,6 @@import time-from typing import Callable, Optional, Union+from collections.abc import Callable+from typing import Optional, Unionimport litellmfrom litellm.litellm_core_utils.prompt_templates.factory import (diff --git a/litellm/llms/predibase/chat/handler.py b/litellm/llms/predibase/chat/handler.pyindex fe8ee508fcd..d1eb4e590d3 100644--- a/litellm/llms/predibase/chat/handler.py+++ b/litellm/llms/predibase/chat/handler.py@@ -2,8 +2,9 @@## Controller file for Predibase Integration - https://predibase.com/import json+from collections.abc import Callablefrom functools import partial-from typing import Callable, Optional, Union+from typing import Optional, Unionimport httpx # type: ignorediff --git a/litellm/llms/replicate/chat/handler.py b/litellm/llms/replicate/chat/handler.pyindex 57381e57dab..a9123d47007 100644--- a/litellm/llms/replicate/chat/handler.py+++ b/litellm/llms/replicate/chat/handler.py@@ -1,7 +1,8 @@import asyncioimport jsonimport time-from typing import Callable, List, Union+from collections.abc import Callable+from typing import List, Unionimport litellmfrom litellm.constants import REPLICATE_POLLING_DELAY_SECONDSdiff --git a/litellm/llms/runwayml/text_to_speech/transformation.py b/litellm/llms/runwayml/text_to_speech/transformation.pyindex 0f3da5f7ac5..d27e28c23e0 100644--- a/litellm/llms/runwayml/text_to_speech/transformation.py+++ b/litellm/llms/runwayml/text_to_speech/transformation.py@@ -6,7 +6,8 @@ Maps OpenAI TTS spec to RunwayML Text-to-Speech APIimport asyncioimport time-from typing import TYPE_CHECKING, Any, Coroutine, Dict, Optional, Tuple, Union+from collections.abc import Coroutine+from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Unionimport httpxdiff --git a/litellm/llms/sagemaker/chat/handler.py b/litellm/llms/sagemaker/chat/handler.pyindex c01e93c4bf4..4278ef34b31 100644--- a/litellm/llms/sagemaker/chat/handler.py+++ b/litellm/llms/sagemaker/chat/handler.py@@ -1,6 +1,7 @@import json+from collections.abc import Callablefrom copy import deepcopy-from typing import Callable, Optional, Union+from typing import Optional, Unionimport httpxdiff --git a/litellm/llms/sagemaker/common_utils.py b/litellm/llms/sagemaker/common_utils.pyindex 2fddde291f4..da9572267ac 100644--- a/litellm/llms/sagemaker/common_utils.py+++ b/litellm/llms/sagemaker/common_utils.py@@ -1,6 +1,7 @@import functoolsimport json-from typing import AsyncIterator, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import List, Optional, Unionimport httpxdiff --git a/litellm/llms/sagemaker/completion/handler.py b/litellm/llms/sagemaker/completion/handler.pyindex c27a3c3528c..216ce08678f 100644--- a/litellm/llms/sagemaker/completion/handler.py+++ b/litellm/llms/sagemaker/completion/handler.py@@ -1,6 +1,7 @@import json+from collections.abc import Callablefrom copy import deepcopy-from typing import Any, Callable, List, Optional, Union, cast+from typing import Any, List, Optional, Union, castimport httpx@@ -21,8 +22,8 @@ from litellm.utils import ()from ..common_utils import AWSEventStreamDecoder, SagemakerError-from .transformation import SagemakerConfigfrom ..embedding.transformation import SagemakerEmbeddingConfig+from .transformation import SagemakerConfigsagemaker_config = SagemakerConfig()diff --git a/litellm/llms/sambanova/chat.py b/litellm/llms/sambanova/chat.pyindex 2120256f918..be5f8b3dffb 100644--- a/litellm/llms/sambanova/chat.py+++ b/litellm/llms/sambanova/chat.py@@ -4,7 +4,8 @@ Sambanova Chat Completions APIthis is OpenAI compatible - no translation needed / occurs"""-from typing import Any, Coroutine, List, Literal, Optional, Union, overload+from collections.abc import Coroutine+from typing import Any, List, Literal, Optional, Union, overloadfrom litellm.litellm_core_utils.prompt_templates.common_utils import (handle_messages_with_content_list_to_str_conversion,diff --git a/litellm/llms/sap/chat/handler.py b/litellm/llms/sap/chat/handler.pyindex a679e4cf704..28aecaa38a0 100755--- a/litellm/llms/sap/chat/handler.py+++ b/litellm/llms/sap/chat/handler.py@@ -2,7 +2,8 @@ from __future__ import annotationsimport jsonimport time-from typing import AsyncIterator, Iterator, Optional+from collections.abc import AsyncIterator, Iterator+from typing import Optionalimport httpxdiff --git a/litellm/llms/sap/chat/transformation.py b/litellm/llms/sap/chat/transformation.pyindex 4bf8272a334..0ec95c15be0 100755--- a/litellm/llms/sap/chat/transformation.py+++ b/litellm/llms/sap/chat/transformation.py@@ -2,23 +2,22 @@Translate from OpenAI's `/v1/chat/completions` to SAP Generative AI Hub's Orchestration Service`v2/completion`"""+from collections.abc import AsyncIterator, Iterator+from functools import cached_propertyfrom typing import (+ TYPE_CHECKING,+ Any,+ Dict,+ FrozenSet,List,Optional,- Union,- Dict,Tuple,- Any,- TYPE_CHECKING,- Iterator,- AsyncIterator,- FrozenSet,+ Union,)-from functools import cached_property-import litellm-import httpx+import httpx+import litellmfrom litellm.types.llms.openai import AllMessageValuesfrom litellm.types.utils import ModelResponse@@ -32,6 +31,11 @@ else:LiteLLMLoggingObj = Anyfrom ..credentials import get_token_creator+from .handler import (+ AsyncSAPStreamIterator,+ GenAIHubOrchestrationError,+ SAPStreamIterator,+)from .models import (ChatCompletionTool,OrchestrationRequest,@@ -42,11 +46,6 @@ from .models import (SAPToolChatMessage,SAPUserMessage,)-from .handler import (- GenAIHubOrchestrationError,- AsyncSAPStreamIterator,- SAPStreamIterator,-)# Keys routed outside SAP orchestration `model.params` (prompt, stream, fallbacks, etc.)_SAP_MODEL_PARAMS_EXCLUDED_KEYS: FrozenSet[str] = frozenset(diff --git a/litellm/llms/sap/credentials.py b/litellm/llms/sap/credentials.pyindex 54e6b1af50e..34bd6eda2ff 100644--- a/litellm/llms/sap/credentials.py+++ b/litellm/llms/sap/credentials.py@@ -1,17 +1,20 @@from __future__ import annotations-from typing import Any, Callable, Dict, Final, List, Optional, Sequence, Tuple, Union-from datetime import datetime, timedelta, timezone-from threading import Lock-from pathlib import Path-from dataclasses import dataclass+import jsonimport osimport tempfile+from collections.abc import Callable, Sequence+from dataclasses import dataclass+from datetime import datetime, timedelta, timezone+from pathlib import Path+from threading import Lock+from typing import Any, Dict, Final, List, Optional, Tuple, Union+import httpx-from litellm.llms.custom_httpx.http_handler import _get_httpx_client, HTTPHandler-from litellm._logging import verbose_loggerimport litellm+from litellm._logging import verbose_logger+from litellm.llms.custom_httpx.http_handler import HTTPHandler, _get_httpx_clientAUTH_ENDPOINT_SUFFIX = "/oauth/token"diff --git a/litellm/llms/soniox/audio_transcription/handler.py b/litellm/llms/soniox/audio_transcription/handler.pyindex 88fa8f10580..d25b3022a1b 100644--- a/litellm/llms/soniox/audio_transcription/handler.py+++ b/litellm/llms/soniox/audio_transcription/handler.py@@ -18,10 +18,10 @@ handler (analogous to the OpenAI / Azure transcription handlers).import asyncioimport mathimport time+from collections.abc import Coroutinefrom typing import (TYPE_CHECKING,Any,- Coroutine,Dict,List,Optional,diff --git a/litellm/llms/topaz/image_variations/transformation.py b/litellm/llms/topaz/image_variations/transformation.pyindex 01239d600b6..d495f1c28ab 100644--- a/litellm/llms/topaz/image_variations/transformation.py+++ b/litellm/llms/topaz/image_variations/transformation.py@@ -1,7 +1,8 @@import base64import time+from collections.abc import Mappingfrom io import BytesIO-from typing import Any, List, Mapping, Optional, Tuple, Union+from typing import Any, List, Optional, Tuple, Unionfrom aiohttp import ClientResponsefrom httpx import Headers, Responsediff --git a/litellm/llms/triton/completion/transformation.py b/litellm/llms/triton/completion/transformation.pyindex 44fe32e2e5d..dc1ed427c2d 100644--- a/litellm/llms/triton/completion/transformation.py+++ b/litellm/llms/triton/completion/transformation.py@@ -3,7 +3,8 @@ Translates from OpenAI's `/v1/chat/completions` endpoint to Triton's `/generate`"""import json-from typing import Any, AsyncIterator, Dict, Iterator, List, Literal, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import Any, Dict, List, Literal, Optional, Unionfrom httpx import Headers, Responsediff --git a/litellm/llms/vertex_ai/aws_credentials_supplier.py b/litellm/llms/vertex_ai/aws_credentials_supplier.pyindex f358511311b..7c43c2524cd 100644--- a/litellm/llms/vertex_ai/aws_credentials_supplier.py+++ b/litellm/llms/vertex_ai/aws_credentials_supplier.py@@ -8,7 +8,7 @@ without hitting the EC2 instance metadata service.Requires google-auth >= 2.29.0."""-from typing import Callable+from collections.abc import Callablefrom google.auth import awsdiff --git a/litellm/llms/vertex_ai/batches/handler.py b/litellm/llms/vertex_ai/batches/handler.pyindex ada1356fb6b..c8c951e1d3b 100644--- a/litellm/llms/vertex_ai/batches/handler.py+++ b/litellm/llms/vertex_ai/batches/handler.py@@ -1,5 +1,6 @@import json-from typing import Any, Coroutine, Dict, Optional, Union+from collections.abc import Coroutine+from typing import Any, Dict, Optional, Unionimport httpxdiff --git a/litellm/llms/vertex_ai/context_caching/transformation.py b/litellm/llms/vertex_ai/context_caching/transformation.pyindex 36c78974aca..c60574ce934 100644--- a/litellm/llms/vertex_ai/context_caching/transformation.py+++ b/litellm/llms/vertex_ai/context_caching/transformation.py@@ -5,7 +5,8 @@ Why separate file? Make it easy to see how transformation works"""import re-from typing import List, Optional, Sequence, Tuple, Literal+from collections.abc import Sequence+from typing import List, Literal, Optional, Tuplefrom litellm.types.llms.openai import AllMessageValuesfrom litellm.types.llms.vertex_ai import CachedContentRequestBodydiff --git a/litellm/llms/vertex_ai/files/handler.py b/litellm/llms/vertex_ai/files/handler.pyindex 4d2a1e18eb5..aa8b446c6ff 100644--- a/litellm/llms/vertex_ai/files/handler.py+++ b/litellm/llms/vertex_ai/files/handler.py@@ -2,8 +2,9 @@ import asyncioimport jsonimport osimport time+from collections.abc import Coroutine, Mapping+from typing import Any, Optional, Tuple, Unionfrom urllib.parse import unquote-from typing import Any, Coroutine, Mapping, Optional, Tuple, Unionimport httpx@@ -12,19 +13,19 @@ from litellm.integrations.gcs_bucket.gcs_bucket_base import (GCSBucketBase,GCSLoggingConfig,)-from litellm.types.utils import StandardCallbackDynamicParamsfrom litellm.litellm_core_utils.cloud_storage_security import (VERTEX_AI_MANAGED_GCS_PREFIX,should_allow_legacy_cloud_file_ids,validate_managed_cloud_file_id,)+from litellm.litellm_core_utils.litellm_logging import Loggingfrom litellm.llms.custom_httpx.http_handler import get_async_httpx_clientfrom litellm.types.llms.openai import (FileContentRequest,HttpxBinaryResponseContent,)-from litellm.litellm_core_utils.litellm_logging import Loggingfrom litellm.types.llms.vertex_ai import VERTEX_CREDENTIALS_TYPES+from litellm.types.utils import StandardCallbackDynamicParamsfrom .transformation import VertexAIFilesConfigdiff --git a/litellm/llms/vertex_ai/files/transformation.py b/litellm/llms/vertex_ai/files/transformation.pyindex dd877b52eb8..17349fdc618 100644--- a/litellm/llms/vertex_ai/files/transformation.py+++ b/litellm/llms/vertex_ai/files/transformation.py@@ -5,12 +5,10 @@ import jsonimport osimport reimport time+from collections.abc import Callable, Iterable, Iteratorfrom typing import (Any,- Callable,Dict,- Iterable,- Iterator,List,Optional,Tuple,@@ -40,8 +38,8 @@ from litellm.litellm_core_utils.prompt_templates.common_utils import ()from litellm.llms.base_llm.chat.transformation import BaseLLMExceptionfrom litellm.llms.base_llm.files.transformation import (- BaseFileUploadStream,BaseFilesConfig,+ BaseFileUploadStream,LiteLLMLoggingObj,)from litellm.llms.vertex_ai.common_utils import (@@ -51,6 +49,7 @@ from litellm.llms.vertex_ai.gemini.transformation import _transform_request_bodyfrom litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import (VertexGeminiConfig,)+from litellm.types.files import StreamingMediaUploadConfigfrom litellm.types.llms.openai import (AllMessageValues,CreateFileRequest,@@ -60,7 +59,6 @@ from litellm.types.llms.openai import (OpenAIFileObject,PathLike,)-from litellm.types.files import StreamingMediaUploadConfigfrom litellm.types.llms.vertex_ai import GcsBucketResponsefrom litellm.types.utils import LlmProviders, ModelResponsediff --git a/litellm/llms/vertex_ai/fine_tuning/handler.py b/litellm/llms/vertex_ai/fine_tuning/handler.pyindex b220b1544b5..20f7b3905ab 100644--- a/litellm/llms/vertex_ai/fine_tuning/handler.py+++ b/litellm/llms/vertex_ai/fine_tuning/handler.py@@ -1,7 +1,8 @@import jsonimport traceback+from collections.abc import Coroutinefrom datetime import datetime-from typing import Any, Coroutine, Literal, Optional, Union+from typing import Any, Literal, Optional, Unionimport httpxdiff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.pyindex 126f82436e8..5ed57bee6c8 100644--- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py+++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py@@ -3,16 +3,15 @@## Initial implementation - covers gemini + image gen callsimport jsonimport time+from collections.abc import Callable, Mappingfrom copy import deepcopyfrom functools import partialfrom typing import (TYPE_CHECKING,Any,- Callable,Dict,List,Literal,- Mapping,Optional,Tuple,Type,diff --git a/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py b/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.pyindex fd08fdf4c8c..c205c40d707 100644--- a/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py+++ b/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py@@ -4,8 +4,8 @@ Transformation logic from OpenAI /v1/embeddings format to Google AI Studio /batcWhy separate file? Make it easy to see how transformation works"""-from collections.abc import Mapping-from typing import Dict, List, Optional, Sequence, Tuple+from collections.abc import Mapping, Sequence+from typing import Dict, List, Optional, Tuplefrom pydantic import TypeAdapter, ValidationErrordiff --git a/litellm/llms/vertex_ai/text_to_speech/transformation.py b/litellm/llms/vertex_ai/text_to_speech/transformation.pyindex a003409f7a6..aeb40b16c28 100644--- a/litellm/llms/vertex_ai/text_to_speech/transformation.py+++ b/litellm/llms/vertex_ai/text_to_speech/transformation.py@@ -6,7 +6,8 @@ Reference: https://cloud.google.com/text-to-speech/docs/reference/rest/v1/text/s"""import base64-from typing import TYPE_CHECKING, Any, Coroutine, Dict, Optional, Tuple, Union+from collections.abc import Coroutine+from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Unionimport httpxdiff --git a/litellm/llms/vertex_ai/vertex_ai_non_gemini.py b/litellm/llms/vertex_ai/vertex_ai_non_gemini.pyindex 33606013d5c..acf2ef1ccb4 100644--- a/litellm/llms/vertex_ai/vertex_ai_non_gemini.py+++ b/litellm/llms/vertex_ai/vertex_ai_non_gemini.py@@ -1,7 +1,8 @@import jsonimport osimport time-from typing import Any, Callable, Optional, cast+from collections.abc import Callable+from typing import Any, Optional, castimport httpxdiff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.pyindex 411a2a1cb0d..62172db79fd 100644--- a/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py+++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py@@ -1,5 +1,6 @@import types-from typing import Any, AsyncIterator, Iterator, List, Optional, Union+from collections.abc import AsyncIterator, Iterator+from typing import Any, List, Optional, Unionimport httpxdiff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/main.pyindex 097928508a5..b415e24f864 100644--- a/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py+++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py@@ -1,7 +1,8 @@# What is this?## API Handler for calling Vertex AI Partner Models+from collections.abc import Callablefrom enum import Enum-from typing import Callable, Optional, Union+from typing import Optional, Unionimport httpx # type: ignorediff --git a/litellm/llms/vertex_ai/vertex_gemma_models/main.py b/litellm/llms/vertex_ai/vertex_gemma_models/main.pyindex 9622a93c0d8..b66c8a4c4e5 100644--- a/litellm/llms/vertex_ai/vertex_gemma_models/main.py+++ b/litellm/llms/vertex_ai/vertex_gemma_models/main.py@@ -19,7 +19,8 @@ The API expects a custom endpoint URL format:https://{ENDPOINT_NUMBER}.{location}-{REGION_NUMBER}.prediction.vertexai.goog/v1/projects/{PROJECT_ID}/locations/{location}/endpoints/{ENDPOINT_ID}:predict"""-from typing import Callable, Optional, Union+from collections.abc import Callable+from typing import Optional, Unionimport httpx # type: ignorediff --git a/litellm/llms/vertex_ai/vertex_gemma_models/transformation.py b/litellm/llms/vertex_ai/vertex_gemma_models/transformation.pyindex 567c8c6a3ee..5313e420155 100644--- a/litellm/llms/vertex_ai/vertex_gemma_models/transformation.py+++ b/litellm/llms/vertex_ai/vertex_gemma_models/transformation.py@@ -8,7 +8,8 @@ Handles the custom request/response format:The actual message transformation reuses OpenAIGPTConfig since Gemma uses OpenAI-compatible format."""-from typing import Any, Callable, Dict, List, Optional, Union, cast+from collections.abc import Callable+from typing import Any, Dict, List, Optional, Union, castimport httpxdiff --git a/litellm/llms/vertex_ai/vertex_model_garden/main.py b/litellm/llms/vertex_ai/vertex_model_garden/main.pyindex bd9d95e6d04..e09106ea4f6 100644--- a/litellm/llms/vertex_ai/vertex_model_garden/main.py+++ b/litellm/llms/vertex_ai/vertex_model_garden/main.py@@ -16,7 +16,8 @@ Sent to this route when `model` is in the format `vertex_ai/openai/{MODEL_ID}`Vertex Documentation for using the OpenAI /chat/completions endpoint: https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_pytorch_llama3_deployment.ipynb"""-from typing import Callable, Optional, Union+from collections.abc import Callable+from typing import Optional, Unionimport httpx # type: ignorediff --git a/litellm/llms/vllm/completion/handler.py b/litellm/llms/vllm/completion/handler.pyindex cb352b599f9..673870bcfcb 100644--- a/litellm/llms/vllm/completion/handler.py+++ b/litellm/llms/vllm/completion/handler.py@@ -1,5 +1,5 @@import time # type: ignore-from typing import Callable+from collections.abc import Callableimport httpxdiff --git a/litellm/llms/watsonx/chat/handler.py b/litellm/llms/watsonx/chat/handler.pyindex 40ccc45497b..d7db2d12097 100644--- a/litellm/llms/watsonx/chat/handler.py+++ b/litellm/llms/watsonx/chat/handler.py@@ -1,4 +1,5 @@-from typing import Callable, Optional, Union+from collections.abc import Callable+from typing import Optional, Unionimport httpxdiff --git a/litellm/llms/watsonx/completion/transformation.py b/litellm/llms/watsonx/completion/transformation.pyindex 190e2f7e93d..397d6bde1c6 100644--- a/litellm/llms/watsonx/completion/transformation.py+++ b/litellm/llms/watsonx/completion/transformation.py@@ -1,11 +1,10 @@import time+from collections.abc import AsyncIterator, Iteratorfrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- AsyncIterator,Dict,- Iterator,List,Optional,Union,diff --git a/litellm/llms/xai/chat/transformation.py b/litellm/llms/xai/chat/transformation.pyindex 0e689549421..23ab64a286f 100644--- a/litellm/llms/xai/chat/transformation.py+++ b/litellm/llms/xai/chat/transformation.py@@ -1,4 +1,5 @@-from typing import Any, AsyncIterator, Dict, Iterator, List, Optional, Tuple, Union+from collections.abc import AsyncIterator, Iterator+from typing import Any, Dict, List, Optional, Tuple, Unionimport httpxdiff --git a/litellm/main.py b/litellm/main.pyindex acdec7385da..605ec2b066a 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -19,6 +19,7 @@ import randomimport sysimport timeimport traceback+from collections.abc import AsyncIterator, Coroutine, Iterable, Mappingfrom concurrent import futuresfrom concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, waitfrom copy import deepcopy@@ -26,13 +27,9 @@ from functools import partialfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Coroutine,Dict,- Iterable,List,Literal,- Mapping,Optional,Tuple,Type,diff --git a/litellm/passthrough/main.py b/litellm/passthrough/main.pyindex cdeedd7b522..b3fdb31997a 100644--- a/litellm/passthrough/main.py+++ b/litellm/passthrough/main.py@@ -4,13 +4,11 @@ This module is used to pass through requests to the LLM APIs.import asyncioimport contextvars+from collections.abc import AsyncGenerator, Coroutine, Generatorfrom functools import partialfrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,- Coroutine,- Generator,List,Optional,Union,diff --git a/litellm/passthrough/utils.py b/litellm/passthrough/utils.pyindex 706beb7dc5e..a5c03acb4f5 100644--- a/litellm/passthrough/utils.py+++ b/litellm/passthrough/utils.py@@ -1,4 +1,5 @@-from typing import Dict, List, Mapping, Optional, Union+from collections.abc import Mapping+from typing import Dict, List, Optional, Unionfrom urllib.parse import parse_qsimport httpxdiff --git a/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py b/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.pyindex 81983cc62fd..973544366de 100644--- a/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py+++ b/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py@@ -1,6 +1,7 @@import re+from collections.abc import Sequencefrom datetime import datetime, timezone-from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Set, Tuple, cast+from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, castfrom fastapi import HTTPExceptionfrom starlette.datastructures import Headersdiff --git a/litellm/proxy/_experimental/mcp_server/gateway_dcr_flow.py b/litellm/proxy/_experimental/mcp_server/gateway_dcr_flow.pyindex 7177b798c5f..582f395c064 100644--- a/litellm/proxy/_experimental/mcp_server/gateway_dcr_flow.py+++ b/litellm/proxy/_experimental/mcp_server/gateway_dcr_flow.py@@ -42,9 +42,9 @@ import hmacimport htmlimport secretsfrom base64 import urlsafe_b64encode-from collections.abc import Mapping+from collections.abc import Awaitable, Callable, Mappingfrom datetime import datetime, timezone-from typing import Awaitable, Callable, Literal, TypeVar+from typing import Literal, TypeVarfrom urllib.parse import parse_qsl, urlencode, urlparse, urlunparsefrom fastapi import HTTPException, Requestdiff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.pyindex 0a6d72881be..e609de71e7a 100644--- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py+++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py@@ -13,13 +13,11 @@ import jsonimport osimport reimport time-from collections.abc import Sequence+from collections.abc import AsyncIterator, Callable, Sequencefrom contextlib import asynccontextmanagerfrom typing import (TYPE_CHECKING,Any,- AsyncIterator,- Callable,Literal,Optional,TypeAlias,diff --git a/litellm/proxy/_experimental/mcp_server/tool_registry.py b/litellm/proxy/_experimental/mcp_server/tool_registry.pyindex 2da22671c91..27d313e33a8 100644--- a/litellm/proxy/_experimental/mcp_server/tool_registry.py+++ b/litellm/proxy/_experimental/mcp_server/tool_registry.py@@ -1,5 +1,6 @@import json-from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional+from collections.abc import Callable+from typing import TYPE_CHECKING, Any, Dict, List, Optionalfrom litellm._logging import verbose_loggerfrom litellm.proxy.types_utils.utils import get_instance_fndiff --git a/litellm/proxy/_experimental/mcp_server/utils.py b/litellm/proxy/_experimental/mcp_server/utils.pyindex 698df147247..06ff9034a44 100644--- a/litellm/proxy/_experimental/mcp_server/utils.py+++ b/litellm/proxy/_experimental/mcp_server/utils.py@@ -7,14 +7,11 @@ import importlibimport jsonimport osimport re-from collections.abc import MutableMapping, MutableSequence+from collections.abc import Iterable, Iterator, Mapping, MutableMapping, MutableSequencefrom typing import (Any,Dict,- Iterable,- Iterator,List,- Mapping,Optional,Set,Tuple,diff --git a/litellm/proxy/_lazy_features.py b/litellm/proxy/_lazy_features.pyindex 1dda1f29fb9..6571c3ec4b5 100644--- a/litellm/proxy/_lazy_features.py+++ b/litellm/proxy/_lazy_features.py@@ -9,8 +9,9 @@ omits each feature's routes until the feature is warmed.import asyncioimport importlibimport sys+from collections.abc import Callablefrom dataclasses import dataclass, field-from typing import TYPE_CHECKING, Callable, Dict, Tuple+from typing import TYPE_CHECKING, Dict, Tuplefrom starlette.types import Receive, Scope, Senddiff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex e8355f4941a..077c4a624f5 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -1,8 +1,9 @@import enumimport jsonimport os+from collections.abc import Callablefrom datetime import datetime-from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Union+from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Unionimport httpxfrom pydantic import (diff --git a/litellm/proxy/a2a/agent_card.py b/litellm/proxy/a2a/agent_card.pyindex 29a689a32de..7fb81057bc9 100644--- a/litellm/proxy/a2a/agent_card.py+++ b/litellm/proxy/a2a/agent_card.py@@ -8,8 +8,9 @@ and uses LiteLLM auth."""import re+from collections.abc import Mappingfrom copy import deepcopy-from typing import Any, Dict, List, Literal, Mapping+from typing import Any, Dict, List, LiteralSupportedA2AVersion = Literal["0.3", "1.0"]diff --git a/litellm/proxy/a2a/version_convert.py b/litellm/proxy/a2a/version_convert.pyindex 9de33a0966a..b0e56628290 100644--- a/litellm/proxy/a2a/version_convert.py+++ b/litellm/proxy/a2a/version_convert.py@@ -24,8 +24,9 @@ The two wire shapes:``Task`` result is a bare object without ``kind``."""+from collections.abc import Callablefrom types import ModuleType-from typing import Callable, Literal, Union+from typing import Literal, Unionfrom pydantic import BaseModeldiff --git a/litellm/proxy/agent_endpoints/a2a_endpoints.py b/litellm/proxy/agent_endpoints/a2a_endpoints.pyindex 76423fbebde..0f0f724ab67 100644--- a/litellm/proxy/agent_endpoints/a2a_endpoints.py+++ b/litellm/proxy/agent_endpoints/a2a_endpoints.py@@ -11,8 +11,9 @@ The A2A SDK can point to LiteLLM's URL and invoke agents registered with LiteLLM"""import json+from collections.abc import AsyncGeneratorfrom copy import deepcopy-from typing import TYPE_CHECKING, Any, AsyncGenerator, Dict, List+from typing import TYPE_CHECKING, Any, Dict, Listfrom urllib.parse import urlparsefrom fastapi import APIRouter, Depends, HTTPException, Request, Responsediff --git a/litellm/proxy/analytics_endpoints/cache_activity.py b/litellm/proxy/analytics_endpoints/cache_activity.pyindex 6e20382f56e..f0263d091ce 100644--- a/litellm/proxy/analytics_endpoints/cache_activity.py+++ b/litellm/proxy/analytics_endpoints/cache_activity.py@@ -1,7 +1,8 @@import asyncioimport json+from collections.abc import Sequencefrom datetime import datetime-from typing import TYPE_CHECKING, Sequence+from typing import TYPE_CHECKINGfrom pydantic import BaseModel, TypeAdapterdiff --git a/litellm/proxy/auth/auth_checks_organization.py b/litellm/proxy/auth/auth_checks_organization.pyindex 9b9e0661084..dc8f2ad758b 100644--- a/litellm/proxy/auth/auth_checks_organization.py+++ b/litellm/proxy/auth/auth_checks_organization.py@@ -2,7 +2,8 @@Auth Checks for Organizations"""-from typing import Awaitable, Callable, Dict, List, Optional, Tuple+from collections.abc import Awaitable, Callable+from typing import Dict, List, Optional, Tuplefrom fastapi import statusdiff --git a/litellm/proxy/auth/auth_utils.py b/litellm/proxy/auth/auth_utils.pyindex 644253ceac7..88b128f7c02 100644--- a/litellm/proxy/auth/auth_utils.py+++ b/litellm/proxy/auth/auth_utils.py@@ -1,9 +1,10 @@import osimport reimport sys+from collections.abc import Iterator, Mappingfrom functools import lru_cachefrom logging import Logger-from typing import Any, Dict, FrozenSet, Iterator, List, Mapping, Optional, Tuple, Union+from typing import Any, Dict, FrozenSet, List, Optional, Tuple, Unionfrom fastapi import HTTPException, Request, statusdiff --git a/litellm/proxy/auth/resolvers/store.py b/litellm/proxy/auth/resolvers/store.pyindex 7c2bd324064..0702f47fa99 100644--- a/litellm/proxy/auth/resolvers/store.py+++ b/litellm/proxy/auth/resolvers/store.py@@ -1,6 +1,7 @@from __future__ import annotations-from typing import TYPE_CHECKING, Sequence+from collections.abc import Sequence+from typing import TYPE_CHECKINGfrom pydantic import BaseModel@@ -12,14 +13,14 @@ from litellm.proxy.auth.auth_checks import (_fetch_key_object_from_db_with_reconnect,get_object_permission,)+from litellm.proxy.auth.auth_method import AuthMethod+from litellm.proxy.auth.network import NetworkContextfrom litellm.proxy.auth.resolvers.exceptions import (KeyNotFoundError,KeyNotInCacheError,NoDatabaseConnectionError,PrincipalMissingSourceKeyError,)-from litellm.proxy.auth.auth_method import AuthMethod-from litellm.proxy.auth.network import NetworkContextfrom litellm.proxy.auth.resolvers.models import (CredentialRef,EndUserIdentity,diff --git a/litellm/proxy/client/chat.py b/litellm/proxy/client/chat.pyindex 41015ffd341..0bc42685b88 100644--- a/litellm/proxy/client/chat.py+++ b/litellm/proxy/client/chat.py@@ -1,5 +1,6 @@import json-from typing import Any, Dict, Iterator, List, Optional, Union+from collections.abc import Iterator+from typing import Any, Dict, List, Optional, Unionimport requestsdiff --git a/litellm/proxy/client/cli/commands/agents.py b/litellm/proxy/client/cli/commands/agents.pyindex 6b6252d8ecb..e055b294855 100644--- a/litellm/proxy/client/cli/commands/agents.py+++ b/litellm/proxy/client/cli/commands/agents.py@@ -1,7 +1,8 @@import osimport shutilimport sys-from typing import Callable, Dict, FrozenSet, List, Mapping, Optional, Sequence, Tuple+from collections.abc import Callable, Mapping, Sequence+from typing import Dict, FrozenSet, List, Optional, Tupleimport clickimport requestsdiff --git a/litellm/proxy/client/cli/commands/up.py b/litellm/proxy/client/cli/commands/up.pyindex dc9157d7ca4..c31e0b39264 100644--- a/litellm/proxy/client/cli/commands/up.py+++ b/litellm/proxy/client/cli/commands/up.py@@ -7,10 +7,11 @@ import shutilimport signalimport sysimport threading+from collections.abc import Iterator, Mappingfrom dataclasses import dataclassfrom pathlib import Pathfrom types import FrameType-from typing import IO, Iterator, Mapping+from typing import IOimport clickfrom pydantic import JsonValue, TypeAdapter, ValidationErrordiff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.pyindex dc8bc961296..3f3da6dc258 100644--- a/litellm/proxy/common_request_processing.py+++ b/litellm/proxy/common_request_processing.py@@ -4,16 +4,14 @@ import loggingimport mathimport timeimport traceback+from collections.abc import AsyncGenerator, Callable, Mappingfrom datetime import datetimefrom functools import lru_cachefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,- Callable,Dict,Literal,- Mapping,Optional,Tuple,Union,diff --git a/litellm/proxy/common_utils/cache_coordinator.py b/litellm/proxy/common_utils/cache_coordinator.pyindex 2f09e92f1ba..60d9e273f62 100644--- a/litellm/proxy/common_utils/cache_coordinator.py+++ b/litellm/proxy/common_utils/cache_coordinator.py@@ -12,7 +12,8 @@ pattern: global spend, feature flags, config, or other shared read-through data.import asyncioimport time-from typing import Any, Awaitable, Callable, Optional, Protocol, TypeVar+from collections.abc import Awaitable, Callable+from typing import Any, Optional, Protocol, TypeVarfrom litellm._logging import verbose_proxy_loggerdiff --git a/litellm/proxy/common_utils/callback_utils.py b/litellm/proxy/common_utils/callback_utils.pyindex 8eb122f23af..4988edd2810 100644--- a/litellm/proxy/common_utils/callback_utils.py+++ b/litellm/proxy/common_utils/callback_utils.py@@ -1,6 +1,7 @@import copyimport os-from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional+from collections.abc import Callable, Iterable+from typing import TYPE_CHECKING, Any, Dict, List, Optionalimport litellmfrom litellm import get_secretdiff --git a/litellm/proxy/common_utils/http_parsing_utils.py b/litellm/proxy/common_utils/http_parsing_utils.pyindex 719c39642c6..9195f02bfbe 100644--- a/litellm/proxy/common_utils/http_parsing_utils.py+++ b/litellm/proxy/common_utils/http_parsing_utils.py@@ -1,6 +1,7 @@import jsonimport re-from typing import Any, Collection, Dict, List, Optional+from collections.abc import Collection+from typing import Any, Dict, List, Optionalimport orjsonfrom fastapi import Request, UploadFile, statusdiff --git a/litellm/proxy/common_utils/performance_utils.py b/litellm/proxy/common_utils/performance_utils.pyindex 6a67fbd93e8..38c866c86f7 100644--- a/litellm/proxy/common_utils/performance_utils.py+++ b/litellm/proxy/common_utils/performance_utils.py@@ -13,8 +13,9 @@ import cProfileimport functoolsimport inspectimport threading+from collections.abc import Callablefrom pathlib import Path as PathLib-from typing import Any, Callable, Optional+from typing import Any, Optionalfrom litellm._logging import verbose_proxy_loggerdiff --git a/litellm/proxy/common_utils/proxy_rate_limit_error.py b/litellm/proxy/common_utils/proxy_rate_limit_error.pyindex 8e7a568b14f..6b3a3856f52 100644--- a/litellm/proxy/common_utils/proxy_rate_limit_error.py+++ b/litellm/proxy/common_utils/proxy_rate_limit_error.py@@ -36,7 +36,8 @@ This module provides a single proxy-side error class that:"""import json-from typing import Any, Dict, Mapping, Optional, Union+from collections.abc import Mapping+from typing import Any, Dict, Optional, Unionfrom fastapi import HTTPExceptiondiff --git a/litellm/proxy/common_utils/reset_budget_job.py b/litellm/proxy/common_utils/reset_budget_job.pyindex 1210192416f..e77e112d120 100644--- a/litellm/proxy/common_utils/reset_budget_job.py+++ b/litellm/proxy/common_utils/reset_budget_job.py@@ -1,8 +1,9 @@import asyncioimport jsonimport time+from collections.abc import Callablefrom datetime import datetime, timezone-from typing import Any, Callable, List, Literal, Optional, Union+from typing import Any, List, Literal, Optional, Unionimport litellmfrom litellm._logging import verbose_proxy_loggerdiff --git a/litellm/proxy/db/exception_handler.py b/litellm/proxy/db/exception_handler.pyindex e4c565e4464..04256be50b3 100644--- a/litellm/proxy/db/exception_handler.py+++ b/litellm/proxy/db/exception_handler.py@@ -1,4 +1,5 @@-from typing import Any, Awaitable, Callable, Optional, Union+from collections.abc import Awaitable, Callable+from typing import Any, Optional, Unionfrom litellm._logging import verbose_proxy_loggerfrom litellm.proxy._types import (diff --git a/litellm/proxy/db/log_db_metrics.py b/litellm/proxy/db/log_db_metrics.pyindex ba7d6d6fbee..241f7db733f 100644--- a/litellm/proxy/db/log_db_metrics.py+++ b/litellm/proxy/db/log_db_metrics.py@@ -5,9 +5,10 @@ ServiceLogger() then sends DB logs to Prometheus, OTEL, Datadog etc"""import asyncio+from collections.abc import Callablefrom datetime import datetimefrom functools import wraps-from typing import Callable, Dict, Optional, Tuple+from typing import Dict, Optional, Tuplefrom litellm._service_logger import ServiceTypesfrom litellm.litellm_core_utils.core_helpers import _get_parent_otel_span_from_kwargsdiff --git a/litellm/proxy/db/prisma_client.py b/litellm/proxy/db/prisma_client.pyindex 1e0d8f5e010..f8a99d2c120 100644--- a/litellm/proxy/db/prisma_client.py+++ b/litellm/proxy/db/prisma_client.py@@ -10,9 +10,10 @@ import subprocessimport timeimport urllibimport urllib.parse+from collections.abc import Callablefrom dataclasses import dataclassfrom datetime import datetime, timedelta-from typing import Any, Callable, Protocol, Union+from typing import Any, Protocol, Unionfrom litellm._logging import verbose_proxy_loggerfrom litellm.secret_managers.main import str_to_booldiff --git a/litellm/proxy/db/routing_prisma_wrapper.py b/litellm/proxy/db/routing_prisma_wrapper.pyindex 703abc64d8c..bca36dcb712 100644--- a/litellm/proxy/db/routing_prisma_wrapper.py+++ b/litellm/proxy/db/routing_prisma_wrapper.py@@ -5,7 +5,8 @@ otherwise PrismaClient uses the writer-only PrismaWrapper directly."""import os-from typing import Any, Callable+from collections.abc import Callable+from typing import Anyfrom litellm._logging import verbose_proxy_loggerfrom litellm.proxy.db.prisma_client import PrismaWrapperdiff --git a/litellm/proxy/db/spend_log_tool_index.py b/litellm/proxy/db/spend_log_tool_index.pyindex 802e893d473..af0ea4fe13e 100644--- a/litellm/proxy/db/spend_log_tool_index.py+++ b/litellm/proxy/db/spend_log_tool_index.py@@ -13,10 +13,11 @@ from __future__ import annotationsimport asyncioimport random+from collections.abc import Sequencefrom dataclasses import dataclassfrom datetime import datetime, timezonefrom itertools import groupby-from typing import TYPE_CHECKING, Any, Sequence+from typing import TYPE_CHECKING, Anyfrom litellm.proxy._types import DB_RETRY_SAFE_ERROR_TYPESdiff --git a/litellm/proxy/guardrails/_content_utils.py b/litellm/proxy/guardrails/_content_utils.pyindex 8861a9e3bbc..8e09064562e 100644--- a/litellm/proxy/guardrails/_content_utils.py+++ b/litellm/proxy/guardrails/_content_utils.py@@ -8,7 +8,8 @@ skip the other shapes — these helpers normalise that so every hook seesevery text fragment."""-from typing import Any, Callable, Dict, FrozenSet, Iterator, List+from collections.abc import Callable, Iterator+from typing import Any, Dict, FrozenSet, List# Call types whose body carries free-form chat / prompt text that# text-content guardrails (banned keywords, content moderation, secretdiff --git a/litellm/proxy/guardrails/guardrail_hooks/aim/aim.py b/litellm/proxy/guardrails/guardrail_hooks/aim/aim.pyindex 01eb61dad08..601cc25e774 100644--- a/litellm/proxy/guardrails/guardrail_hooks/aim/aim.py+++ b/litellm/proxy/guardrails/guardrail_hooks/aim/aim.py@@ -7,7 +7,8 @@import asyncioimport jsonimport os-from typing import TYPE_CHECKING, Any, AsyncGenerator, List, Optional, Type, Union+from collections.abc import AsyncGenerator+from typing import TYPE_CHECKING, Any, List, Optional, Type, Unionfrom pydantic import BaseModelfrom websockets.asyncio.client import ClientConnection, connectdiff --git a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.pyindex bdbe3f193d4..cf9c5b859c0 100644--- a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py+++ b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py@@ -9,12 +9,14 @@ import osimport syssys.path.insert(0, os.path.abspath("../..")) # Adds the parent directory to the system path+import copyimport jsonimport sys+from collections.abc import AsyncGenerator, Mapping+from datetime import datetime, timezonefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,ClassVar,Dict,List,@@ -26,20 +28,16 @@ from typing import (cast,)-import copy-from collections.abc import Mapping-from datetime import datetime, timezone-import httpxfrom fastapi import HTTPExceptionfrom pydantic import TypeAdapter, ValidationErrorimport litellmfrom litellm._logging import verbose_proxy_logger-from litellm.litellm_core_utils.core_helpers import redact_nested_match_and_regex_keysfrom litellm.caching import DualCachefrom litellm.exceptions import ModifyResponseExceptionfrom litellm.integrations.custom_guardrail import CustomGuardrail+from litellm.litellm_core_utils.core_helpers import redact_nested_match_and_regex_keysfrom litellm.llms.bedrock.base_aws_llm import BaseAWSLLMfrom litellm.llms.custom_httpx.http_handler import (get_async_httpx_client,diff --git a/litellm/proxy/guardrails/guardrail_hooks/cato_networks/cato_networks.py b/litellm/proxy/guardrails/guardrail_hooks/cato_networks/cato_networks.pyindex 440618a2ffa..f1d08bfbd56 100644--- a/litellm/proxy/guardrails/guardrail_hooks/cato_networks/cato_networks.py+++ b/litellm/proxy/guardrails/guardrail_hooks/cato_networks/cato_networks.py@@ -9,7 +9,8 @@ import contextlibimport jsonimport osimport ssl-from typing import TYPE_CHECKING, Any, AsyncGenerator, List, Optional, Type, Union+from collections.abc import AsyncGenerator+from typing import TYPE_CHECKING, Any, List, Optional, Type, Unionfrom fastapi import HTTPExceptionfrom pydantic import BaseModeldiff --git a/litellm/proxy/guardrails/guardrail_hooks/cisco_ai_defense/cisco_ai_defense.py b/litellm/proxy/guardrails/guardrail_hooks/cisco_ai_defense/cisco_ai_defense.pyindex 4c31b038172..10f2def7d77 100644--- a/litellm/proxy/guardrails/guardrail_hooks/cisco_ai_defense/cisco_ai_defense.py+++ b/litellm/proxy/guardrails/guardrail_hooks/cisco_ai_defense/cisco_ai_defense.py@@ -19,12 +19,12 @@ request is sent with the ``X-Cisco-AI-Defense-API-Key`` header.import jsonimport os+from collections.abc import AsyncIteratorfrom dataclasses import dataclass, replacefrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- AsyncIterator,Dict,List,Literal,diff --git a/litellm/proxy/guardrails/guardrail_hooks/compresr/compresr.py b/litellm/proxy/guardrails/guardrail_hooks/compresr/compresr.pyindex 4627b298d09..21e59d8fe83 100644--- a/litellm/proxy/guardrails/guardrail_hooks/compresr/compresr.py+++ b/litellm/proxy/guardrails/guardrail_hooks/compresr/compresr.py@@ -22,13 +22,12 @@ import jsonimport timefrom collections import Counter, OrderedDictfrom dataclasses import dataclass, field-from typing import TYPE_CHECKING, Any, Literal+from typing import TYPE_CHECKING, Any, Literal, TypeGuardfrom urllib.parse import urlparseimport httpxfrom fastapi import HTTPExceptionfrom httpx import Response as HttpxResponse-from typing_extensions import TypeGuardimport litellmfrom litellm._logging import verbose_proxy_loggerdiff --git a/litellm/proxy/guardrails/guardrail_hooks/dynamoai/dynamoai.py b/litellm/proxy/guardrails/guardrail_hooks/dynamoai/dynamoai.pyindex 2db3c35866f..d684a9c58a9 100644--- a/litellm/proxy/guardrails/guardrail_hooks/dynamoai/dynamoai.py+++ b/litellm/proxy/guardrails/guardrail_hooks/dynamoai/dynamoai.py@@ -6,8 +6,9 @@# +-------------------------------------------------------------+import os+from collections.abc import AsyncGeneratorfrom datetime import datetime-from typing import Any, AsyncGenerator, Dict, List, Optional, Type, Union+from typing import Any, Dict, List, Optional, Type, Unionimport httpxdiff --git a/litellm/proxy/guardrails/guardrail_hooks/enkryptai/enkryptai.py b/litellm/proxy/guardrails/guardrail_hooks/enkryptai/enkryptai.pyindex dad8e7dd973..f3f19334473 100644--- a/litellm/proxy/guardrails/guardrail_hooks/enkryptai/enkryptai.py+++ b/litellm/proxy/guardrails/guardrail_hooks/enkryptai/enkryptai.py@@ -6,11 +6,11 @@# +-------------------------------------------------------------+import os+from collections.abc import AsyncGeneratorfrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,Dict,List,Literal,diff --git a/litellm/proxy/guardrails/guardrail_hooks/headroom/headroom.py b/litellm/proxy/guardrails/guardrail_hooks/headroom/headroom.pyindex 1667bb604ba..99b83e10a4f 100644--- a/litellm/proxy/guardrails/guardrail_hooks/headroom/headroom.py+++ b/litellm/proxy/guardrails/guardrail_hooks/headroom/headroom.py@@ -4,17 +4,14 @@ import jsonimport reimport timeimport uuid-from typing import TYPE_CHECKING, Any, ClassVar, List, Literal, Optional+from collections.abc import Mapping, Sequence+from typing import TYPE_CHECKING, Any, ClassVar, List, Literal, Optional, TypeGuardimport httpx-from collections.abc import Mapping, Sequencefrom fastapi import HTTPException--import litellmfrom httpx import Response as HttpxResponse-from litellm.proxy.spend_tracking.compression_savings import HEADROOM_GUARDRAIL_PROVIDER-from typing_extensions import TypeGuard+import litellmfrom litellm._logging import verbose_proxy_loggerfrom litellm.compression.compress import get_protected_indicesfrom litellm.integrations.custom_guardrail import (@@ -37,6 +34,7 @@ from litellm.proxy.guardrails.guardrail_hooks.content_text import (is_all_text_parts,merge_rewritten_text_parts,)+from litellm.proxy.spend_tracking.compression_savings import HEADROOM_GUARDRAIL_PROVIDERfrom litellm.secret_managers.main import get_secret_strfrom litellm.types.guardrails import GuardrailEventHooks, Modefrom litellm.types.integrations.custom_logger import AgenticLoopPlan, AgenticLoopRequestPatchdiff --git a/litellm/proxy/guardrails/guardrail_hooks/ibm_guardrails/ibm_detector.py b/litellm/proxy/guardrails/guardrail_hooks/ibm_guardrails/ibm_detector.pyindex 955ec0c0d35..622f21e531e 100644--- a/litellm/proxy/guardrails/guardrail_hooks/ibm_guardrails/ibm_detector.py+++ b/litellm/proxy/guardrails/guardrail_hooks/ibm_guardrails/ibm_detector.py@@ -6,8 +6,9 @@# +-------------------------------------------------------------+import os+from collections.abc import AsyncGeneratorfrom datetime import datetime-from typing import Any, AsyncGenerator, Dict, List, Optional, Union+from typing import Any, Dict, List, Optional, Unionimport httpxdiff --git a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/competitor_intent/base.py b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/competitor_intent/base.pyindex e41f69784c6..3e91afd2d6f 100644--- a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/competitor_intent/base.py+++ b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/competitor_intent/base.py@@ -4,7 +4,8 @@ Generic competitor intent checker: two entity sets and overridable disambiguatioimport reimport unicodedata-from typing import Any, Dict, List, Optional, Pattern, Set, Tuple, cast+from re import Pattern+from typing import Any, Dict, List, Optional, Set, Tuple, castfrom litellm.types.proxy.guardrails.guardrail_hooks.litellm_content_filter import (CompetitorActionHint,diff --git a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.pyindex dda4b0236eb..0b990719577 100644--- a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py+++ b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py@@ -9,16 +9,16 @@ import asyncioimport jsonimport osimport re+from collections.abc import AsyncGeneratorfrom datetime import datetime+from re import Patternfrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,Dict,List,Literal,Optional,- Pattern,Tuple,Union,cast,diff --git a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/patterns.py b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/patterns.pyindex 4879808d2eb..3a3431aa0ee 100644--- a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/patterns.py+++ b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/patterns.py@@ -9,7 +9,8 @@ import jsonimport osimport refrom enum import Enum-from typing import Any, Dict, List, Pattern+from re import Pattern+from typing import Any, Dict, Listdef _load_patterns_from_json() -> Dict:diff --git a/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py b/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.pyindex 5a72e6872ef..193793fc50a 100644--- a/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py+++ b/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py@@ -2,12 +2,13 @@import jsonimport re+from collections.abc import Callablefrom datetime import datetime-from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Union, cast+from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union, cast-import litellmfrom fastapi import HTTPException+import litellmfrom litellm._logging import verbose_loggerfrom litellm.integrations.custom_guardrail import CustomGuardrailfrom litellm.types.guardrails import GuardrailEventHooks, SupportedGuardrailIntegrations@@ -15,8 +16,8 @@ from litellm.types.utils import GenericGuardrailAPIInputs, GuardrailStatusif TYPE_CHECKING:from litellm import Router- from litellm.types.guardrails import Guardrail, LitellmParamsfrom litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj+ from litellm.types.guardrails import Guardrail, LitellmParamsfrom litellm.types.utils import StandardLoggingEvalInformationJUDGE_SYSTEM_PROMPT = """You are a quality judge. Evaluate the assistant's response against the criteria provided.diff --git a/litellm/proxy/guardrails/guardrail_hooks/microsoft_purview/purview_dlp.py b/litellm/proxy/guardrails/guardrail_hooks/microsoft_purview/purview_dlp.pyindex f0fdaff9c29..db07d00b37b 100644--- a/litellm/proxy/guardrails/guardrail_hooks/microsoft_purview/purview_dlp.py+++ b/litellm/proxy/guardrails/guardrail_hooks/microsoft_purview/purview_dlp.py@@ -10,11 +10,11 @@ Supports three modes:import asyncioimport threadingimport uuid+from collections.abc import AsyncGeneratorfrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,Dict,List,Optional,diff --git a/litellm/proxy/guardrails/guardrail_hooks/model_armor/file_scanning.py b/litellm/proxy/guardrails/guardrail_hooks/model_armor/file_scanning.pyindex b879f0d29c7..0c4b56b762c 100644--- a/litellm/proxy/guardrails/guardrail_hooks/model_armor/file_scanning.py+++ b/litellm/proxy/guardrails/guardrail_hooks/model_armor/file_scanning.py@@ -15,8 +15,9 @@ is false) rather than letting an unscanned document reach the model.import base64import binasciiimport mimetypes+from collections.abc import Sequencefrom dataclasses import dataclass-from typing import Annotated, Literal, Sequence+from typing import Annotated, Literalfrom pydantic import BaseModel, ConfigDict, Field, TypeAdapter, ValidationErrordiff --git a/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.py b/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.pyindex f2c5a95202b..13081e68e9a 100644--- a/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.py+++ b/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.py@@ -1,12 +1,10 @@+from collections.abc import AsyncGenerator, Mapping, Sequencefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,List,Literal,- Mapping,Optional,- Sequence,Type,Union,)@@ -22,25 +20,25 @@ import jsonimport litellmfrom litellm._logging import verbose_proxy_loggerfrom litellm.caching import DualCache+from litellm.constants import DEFAULT_MAX_RECURSE_DEPTHfrom litellm.integrations.custom_guardrail import (CustomGuardrail,log_guardrail_information,)-from litellm.llms.custom_httpx.http_handler import (- get_async_httpx_client,- httpxSpecialProvider,-)from litellm.litellm_core_utils.core_helpers import (get_metadata_variable_name_from_kwargs,get_or_create_metadata_bucket,)+from litellm.llms.custom_httpx.http_handler import (+ get_async_httpx_client,+ httpxSpecialProvider,+)from litellm.llms.vertex_ai.vertex_llm_base import VertexBasefrom litellm.proxy._types import UserAPIKeyAuthfrom litellm.proxy.guardrails.guardrail_hooks.model_armor.file_scanning import (MODEL_ARMOR_MAX_FILE_SIZE_BYTES,plan_file_scans,)-from litellm.constants import DEFAULT_MAX_RECURSE_DEPTHfrom litellm.types.guardrails import GuardrailEventHooks, LitellmParamsfrom litellm.types.llms.openai import AllMessageValuesfrom litellm.types.utils import (diff --git a/litellm/proxy/guardrails/guardrail_hooks/noma/noma.py b/litellm/proxy/guardrails/guardrail_hooks/noma/noma.pyindex a467bb14eb6..77c9f1cad65 100644--- a/litellm/proxy/guardrails/guardrail_hooks/noma/noma.py+++ b/litellm/proxy/guardrails/guardrail_hooks/noma/noma.py@@ -9,11 +9,11 @@ import asyncioimport jsonimport osimport warnings+from collections.abc import AsyncGeneratorfrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,Dict,Final,List,diff --git a/litellm/proxy/guardrails/guardrail_hooks/presidio.py b/litellm/proxy/guardrails/guardrail_hooks/presidio.pyindex 60e1947b752..86f5beeb3ee 100644--- a/litellm/proxy/guardrails/guardrail_hooks/presidio.py+++ b/litellm/proxy/guardrails/guardrail_hooks/presidio.py@@ -11,12 +11,12 @@import asyncioimport jsonimport threading+from collections.abc import AsyncGeneratorfrom contextlib import asynccontextmanagerfrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,Dict,List,Literal,diff --git a/litellm/proxy/guardrails/guardrail_hooks/repelloai/repelloai.py b/litellm/proxy/guardrails/guardrail_hooks/repelloai/repelloai.pyindex da1c74b37b6..7b648d4bf99 100644--- a/litellm/proxy/guardrails/guardrail_hooks/repelloai/repelloai.py+++ b/litellm/proxy/guardrails/guardrail_hooks/repelloai/repelloai.py@@ -1,14 +1,13 @@from __future__ import annotations+from collections.abc import AsyncGeneratorfrom datetime import datetime-from typing import AsyncGenerator, List, Literal--from pydantic import TypeAdapter, ValidationError-from pydantic import BaseModel-from typing_extensions import TypeGuard+from typing import List, Literal, TypeGuardfrom fastapi import HTTPException-from httpx import HTTPError, Response as HttpxResponse+from httpx import HTTPError+from httpx import Response as HttpxResponse+from pydantic import BaseModel, TypeAdapter, ValidationErrorimport litellmfrom litellm._logging import verbose_proxy_loggerdiff --git a/litellm/proxy/guardrails/guardrail_hooks/tool_permission.py b/litellm/proxy/guardrails/guardrail_hooks/tool_permission.pyindex 58c57dfdac1..9f61a0670f3 100644--- a/litellm/proxy/guardrails/guardrail_hooks/tool_permission.py+++ b/litellm/proxy/guardrails/guardrail_hooks/tool_permission.py@@ -1,6 +1,7 @@import jsonimport re-from typing import Any, AsyncGenerator, Dict, List, Literal, Optional, Union+from collections.abc import AsyncGenerator+from typing import Any, Dict, List, Literal, Optional, Unionfrom fastapi import HTTPExceptiondiff --git a/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py b/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.pyindex 5cbd05dedfc..8d94dd74180 100644--- a/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py+++ b/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py@@ -8,7 +8,8 @@ Unified Guardrail, leveraging LiteLLM's /applyGuardrail endpointimport copyimport json-from typing import TYPE_CHECKING, Any, AsyncGenerator, List, Union+from collections.abc import AsyncGenerator+from typing import TYPE_CHECKING, Any, List, Unionfrom fastapi import HTTPException@@ -210,15 +211,14 @@ class UnifiedLLMGuardrails(CustomLogger):Uses Enkrypt AI guardrails to check the response for policy violations, PII, and injection attacks"""global endpoint_guardrail_translation_mappings+ # Local import avoids a module-level cyclic import with+ # litellm.integrations.custom_guardrail.+ from litellm.integrations.custom_guardrail import ModifyResponseExceptionfrom litellm.proxy.common_utils.callback_utils import (add_guardrail_to_applied_guardrails_header,)from litellm.types.guardrails import GuardrailEventHooks- # Local import avoids a module-level cyclic import with- # litellm.integrations.custom_guardrail.- from litellm.integrations.custom_guardrail import ModifyResponseException-guardrail_to_apply: CustomGuardrail = data.pop("guardrail_to_apply", None)if guardrail_to_apply is None:diff --git a/litellm/proxy/guardrails/guardrail_hooks/vigil_guard/vigil_guard.py b/litellm/proxy/guardrails/guardrail_hooks/vigil_guard/vigil_guard.pyindex 9976a1c48b1..7d72a233d3d 100644--- a/litellm/proxy/guardrails/guardrail_hooks/vigil_guard/vigil_guard.py+++ b/litellm/proxy/guardrails/guardrail_hooks/vigil_guard/vigil_guard.py@@ -1,8 +1,8 @@+from collections.abc import Awaitablefrom json import JSONDecodeErrorfrom typing import (TYPE_CHECKING,Any,- Awaitable,Dict,List,Literal,diff --git a/litellm/proxy/health_endpoints/_health_endpoints.py b/litellm/proxy/health_endpoints/_health_endpoints.pyindex 4250b9668ff..34841d2e692 100644--- a/litellm/proxy/health_endpoints/_health_endpoints.py+++ b/litellm/proxy/health_endpoints/_health_endpoints.py@@ -5,8 +5,9 @@ import osimport secretsimport timeimport traceback+from collections.abc import Iterablefrom datetime import datetime, timedelta-from typing import Any, Dict, Iterable, Literal, Optional, TypedDict, Union, cast+from typing import Any, Dict, Literal, Optional, TypedDict, Union, castimport fastapifrom fastapi import APIRouter, Depends, HTTPException, Request, Response, statusdiff --git a/litellm/proxy/hooks/batch_rate_limiter.py b/litellm/proxy/hooks/batch_rate_limiter.pyindex 3477af36285..d631fa7ee0c 100644--- a/litellm/proxy/hooks/batch_rate_limiter.py+++ b/litellm/proxy/hooks/batch_rate_limiter.py@@ -17,11 +17,12 @@ Quick summary:- async_log_success_event() fires on GET /v1/batches/{id} (batch completion)"""+import json+from collections.abc import Iterablefrom typing import (TYPE_CHECKING,Any,Dict,- Iterable,List,Literal,NoReturn,@@ -33,8 +34,6 @@ from typing import (from fastapi import HTTPExceptionfrom pydantic import BaseModel-import json-import litellmfrom litellm._logging import verbose_proxy_loggerfrom litellm.batches.batch_utils import (@@ -631,10 +630,7 @@ class _PROXY_BatchRateLimiter(CustomLogger):can_team_access_model,get_team_object,)- from litellm.proxy.proxy_server import llm_router- from litellm.proxy.proxy_server import prisma_client- from litellm.proxy.proxy_server import proxy_logging_obj- from litellm.proxy.proxy_server import user_api_key_cache+ from litellm.proxy.proxy_server import llm_router, prisma_client, proxy_logging_obj, user_api_key_cacheif target_model_names:models = target_model_namesdiff --git a/litellm/proxy/hooks/dynamic_rate_limiter.py b/litellm/proxy/hooks/dynamic_rate_limiter.pyindex 83161fca5bb..766d02666be 100644--- a/litellm/proxy/hooks/dynamic_rate_limiter.py+++ b/litellm/proxy/hooks/dynamic_rate_limiter.py@@ -4,15 +4,16 @@import asyncioimport os+from collections.abc import Callablefrom datetime import datetime-from typing import Callable, List, Optional, Tuple, Union+from typing import List, Optional, Tuple, Unionimport litellmfrom litellm import ModelResponse, Routerfrom litellm._logging import verbose_proxy_loggerfrom litellm.caching.caching import DualCache-from litellm.integrations.custom_logger import CustomLoggerfrom litellm.exceptions import RateLimitType+from litellm.integrations.custom_logger import CustomLoggerfrom litellm.proxy._types import UserAPIKeyAuthfrom litellm.proxy.common_utils.proxy_rate_limit_error import ProxyRateLimitErrorfrom litellm.proxy.hooks.rate_limiter_utils import (diff --git a/litellm/proxy/hooks/dynamic_rate_limiter_v3.py b/litellm/proxy/hooks/dynamic_rate_limiter_v3.pyindex 932146800e2..441187d5d82 100644--- a/litellm/proxy/hooks/dynamic_rate_limiter_v3.py+++ b/litellm/proxy/hooks/dynamic_rate_limiter_v3.py@@ -3,8 +3,9 @@ Dynamic rate limiter v3 - Saturation-aware priority-based rate limiting"""import os+from collections.abc import Callablefrom datetime import datetime-from typing import TYPE_CHECKING, Callable, Dict, List, Literal, Optional, Union+from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Unionfrom fastapi import HTTPExceptiondiff --git a/litellm/proxy/hooks/parallel_request_limiter_v3.py b/litellm/proxy/hooks/parallel_request_limiter_v3.pyindex 3e7edd8cd06..40127007c16 100644--- a/litellm/proxy/hooks/parallel_request_limiter_v3.py+++ b/litellm/proxy/hooks/parallel_request_limiter_v3.py@@ -8,13 +8,13 @@ import asyncioimport binasciiimport osimport uuid+from collections.abc import Callablefrom contextvars import ContextVarfrom dataclasses import dataclass, fieldfrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,- Callable,Dict,FrozenSet,List,diff --git a/litellm/proxy/hooks/responses_id_security.py b/litellm/proxy/hooks/responses_id_security.pyindex cba58506a00..b78688aa593 100644--- a/litellm/proxy/hooks/responses_id_security.py+++ b/litellm/proxy/hooks/responses_id_security.py@@ -5,7 +5,8 @@ This hook uses the DBSpendUpdateWriter to batch-write response IDs to the databainstead of writing immediately on each request."""-from typing import TYPE_CHECKING, Any, AsyncGenerator, Optional, Tuple, Union, cast+from collections.abc import AsyncGenerator+from typing import TYPE_CHECKING, Any, Optional, Tuple, Union, castfrom fastapi import HTTPExceptiondiff --git a/litellm/proxy/management_endpoints/cache_settings_endpoints.py b/litellm/proxy/management_endpoints/cache_settings_endpoints.pyindex 7c0d8958a28..66a79baa8d7 100644--- a/litellm/proxy/management_endpoints/cache_settings_endpoints.py+++ b/litellm/proxy/management_endpoints/cache_settings_endpoints.py@@ -10,8 +10,9 @@ POST /cache/settings - Save cache settings to databaseimport asyncioimport json+from collections.abc import Mappingfrom datetime import datetime, timezone-from typing import Any, Dict, List, Mapping, Optional+from typing import Any, Dict, List, Optionalfrom fastapi import APIRouter, Depends, Header, HTTPExceptionfrom pydantic import BaseModel, Fielddiff --git a/litellm/proxy/management_endpoints/config_override_endpoints.py b/litellm/proxy/management_endpoints/config_override_endpoints.pyindex d13644c8ae5..66c5f75b771 100644--- a/litellm/proxy/management_endpoints/config_override_endpoints.py+++ b/litellm/proxy/management_endpoints/config_override_endpoints.py@@ -1,8 +1,9 @@import asyncioimport jsonimport os+from collections.abc import Mappingfrom datetime import datetime, timezone-from typing import Any, Dict, Mapping, Optional, Set+from typing import Any, Dict, Optional, Setfrom fastapi import APIRouter, Depends, Header, HTTPExceptionfrom pydantic import TypeAdapterdiff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.pyindex b910eee7130..3ec9e1303c4 100644--- a/litellm/proxy/management_endpoints/key_management_endpoints.py+++ b/litellm/proxy/management_endpoints/key_management_endpoints.py@@ -18,9 +18,9 @@ import osimport reimport secretsimport traceback-from collections.abc import Mapping, Sequence+from collections.abc import Callable, Mapping, Sequencefrom datetime import datetime, timedelta, timezone-from typing import Any, Callable, Dict, List, Literal, Optional, Protocol, Tuple, TypeVar, cast+from typing import Any, Dict, List, Literal, Optional, Protocol, Tuple, TypeVar, castimport fastapiimport yamldiff --git a/litellm/proxy/management_endpoints/policy_endpoints/endpoints.py b/litellm/proxy/management_endpoints/policy_endpoints/endpoints.pyindex f50dcb3054f..7d9a57fa02d 100644--- a/litellm/proxy/management_endpoints/policy_endpoints/endpoints.py+++ b/litellm/proxy/management_endpoints/policy_endpoints/endpoints.py@@ -12,7 +12,8 @@ All /policy management endpointsimport copyimport jsonimport os-from typing import TYPE_CHECKING, Any, AsyncIterator, List, Literal, Optional, cast+from collections.abc import AsyncIterator+from typing import TYPE_CHECKING, Any, List, Literal, Optional, castfrom fastapi import APIRouter, Depends, HTTPException, Requestfrom fastapi.responses import Response, StreamingResponsediff --git a/litellm/proxy/management_endpoints/scim/scim_transformations.py b/litellm/proxy/management_endpoints/scim/scim_transformations.pyindex d572255fd32..531716bb1c4 100644--- a/litellm/proxy/management_endpoints/scim/scim_transformations.py+++ b/litellm/proxy/management_endpoints/scim/scim_transformations.py@@ -1,4 +1,5 @@-from typing import Callable, List, TypeVar, Union+from collections.abc import Callable+from typing import List, TypeVar, Unionfrom pydantic import ValidationErrordiff --git a/litellm/proxy/management_endpoints/scim/scim_v2.py b/litellm/proxy/management_endpoints/scim/scim_v2.pyindex f1f71bf6458..9f0b12b6fea 100644--- a/litellm/proxy/management_endpoints/scim/scim_v2.py+++ b/litellm/proxy/management_endpoints/scim/scim_v2.py@@ -5,12 +5,11 @@ This is an enterprise feature and requires a premium license."""import re-from collections.abc import Mapping, Sequence+from collections.abc import Iterable, Mapping, Sequencefrom itertools import chainfrom typing import (TYPE_CHECKING,Dict,- Iterable,List,NamedTuple,Optional,diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.pyindex 1efd0a747df..a4c81a9d13e 100644--- a/litellm/proxy/management_endpoints/team_endpoints.py+++ b/litellm/proxy/management_endpoints/team_endpoints.py@@ -13,13 +13,12 @@ import asyncioimport jsonimport mathimport traceback-from collections.abc import Sequence+from collections.abc import Mapping, Sequencefrom datetime import datetime, timezonefrom typing import (Annotated,Dict,List,- Mapping,Optional,Protocol,Tuple,diff --git a/litellm/proxy/management_endpoints/usage_endpoints/ai_usage_chat.py b/litellm/proxy/management_endpoints/usage_endpoints/ai_usage_chat.pyindex efb714e4da0..9b8eb435803 100644--- a/litellm/proxy/management_endpoints/usage_endpoints/ai_usage_chat.py+++ b/litellm/proxy/management_endpoints/usage_endpoints/ai_usage_chat.py@@ -4,8 +4,9 @@ usage/spend data by querying the aggregated daily activity endpoints."""import json+from collections.abc import AsyncIterator, Callablefrom datetime import date-from typing import Any, AsyncIterator, Callable, Dict, List, Literal, Optional, cast+from typing import Any, Dict, List, Literal, Optional, castfrom typing_extensions import TypedDictdiff --git a/litellm/proxy/management_helpers/object_permission_utils.py b/litellm/proxy/management_helpers/object_permission_utils.pyindex 015ab1d6df6..72b1e38f406 100644--- a/litellm/proxy/management_helpers/object_permission_utils.py+++ b/litellm/proxy/management_helpers/object_permission_utils.py@@ -4,8 +4,9 @@ organizations, teams, and keys."""import json+from collections.abc import Mappingfrom dataclasses import dataclass-from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Set, Union+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Unionfrom fastapi import HTTPException, statusdiff --git a/litellm/proxy/management_helpers/utils.py b/litellm/proxy/management_helpers/utils.pyindex 14ba1dbfde1..15ebc4e6990 100644--- a/litellm/proxy/management_helpers/utils.py+++ b/litellm/proxy/management_helpers/utils.py@@ -1,8 +1,9 @@# What is this?## Helper utils for the management endpoints (keys/users/teams)+from collections.abc import Callablefrom datetime import datetimefrom functools import wraps-from typing import Any, Callable, List, Optional, Tuple+from typing import Any, List, Optional, Tuplefrom fastapi import HTTPException, Requestfrom pydantic import BaseModeldiff --git a/litellm/proxy/middleware/billable_request_metrics_middleware.py b/litellm/proxy/middleware/billable_request_metrics_middleware.pyindex 72bac1bcd6f..ac3d27cd849 100644--- a/litellm/proxy/middleware/billable_request_metrics_middleware.py+++ b/litellm/proxy/middleware/billable_request_metrics_middleware.py@@ -10,8 +10,9 @@ middleware is a transparent pass-through.import reimport threading+from collections.abc import Callable, Sequencefrom enum import Enum-from typing import Callable, Optional, Protocol, Sequence, runtime_checkable+from typing import Optional, Protocol, runtime_checkablefrom starlette.types import ASGIApp, Message, Receive, Scope, Senddiff --git a/litellm/proxy/middleware/prometheus_auth_middleware.py b/litellm/proxy/middleware/prometheus_auth_middleware.pyindex d9cf435235c..52be388c95e 100644--- a/litellm/proxy/middleware/prometheus_auth_middleware.py+++ b/litellm/proxy/middleware/prometheus_auth_middleware.py@@ -3,7 +3,8 @@ Prometheus Auth Middleware - Pure ASGI implementation"""import json-from typing import Any, List, MutableMapping+from collections.abc import MutableMapping+from typing import Any, Listfrom fastapi import Requestfrom starlette.types import ASGIApp, Receive, Scope, Senddiff --git a/litellm/proxy/middleware/request_size_limit_middleware.py b/litellm/proxy/middleware/request_size_limit_middleware.pyindex 0015224279a..75e2f9a523f 100644--- a/litellm/proxy/middleware/request_size_limit_middleware.py+++ b/litellm/proxy/middleware/request_size_limit_middleware.py@@ -1,5 +1,6 @@import json-from typing import Callable, Optional, Union+from collections.abc import Callable+from typing import Optional, Unionfrom starlette.types import ASGIApp, Message, Receive, Scope, Senddiff --git a/litellm/proxy/openai_files_endpoints/file_content_streaming_handler.py b/litellm/proxy/openai_files_endpoints/file_content_streaming_handler.pyindex 5546edba49f..5cbdc530f60 100644--- a/litellm/proxy/openai_files_endpoints/file_content_streaming_handler.py+++ b/litellm/proxy/openai_files_endpoints/file_content_streaming_handler.py@@ -1,4 +1,5 @@-from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, Optional, Tuple, cast+from collections.abc import AsyncIterator+from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, castfrom fastapi.responses import StreamingResponsediff --git a/litellm/proxy/openai_files_endpoints/storage_backend_service.py b/litellm/proxy/openai_files_endpoints/storage_backend_service.pyindex 5125931b28e..1f7df846e66 100644--- a/litellm/proxy/openai_files_endpoints/storage_backend_service.py+++ b/litellm/proxy/openai_files_endpoints/storage_backend_service.py@@ -7,7 +7,8 @@ storage backends (e.g., Azure Blob Storage) and managing associated metadata.import base64import time-from typing import Any, List, Mapping, cast+from collections.abc import Mapping+from typing import Any, List, castfrom litellm._logging import verbose_proxy_loggerfrom litellm._uuid import uuid as uuid_modulediff --git a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.pyindex 50e90699194..529a52daf9c 100644--- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.py+++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.py@@ -1,6 +1,7 @@import json+from collections.abc import Sequencefrom datetime import datetime-from typing import TYPE_CHECKING, Any, List, Optional, Sequence, Union, cast+from typing import TYPE_CHECKING, Any, List, Optional, Union, castimport httpxdiff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.pyindex 9c5c545fe76..e97a0f38975 100644--- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py+++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py@@ -5,9 +5,10 @@ import jsonimport posixpathimport tracebackfrom base64 import b64encode+from collections.abc import AsyncGenerator, Mappingfrom datetime import datetimefrom itertools import groupby-from typing import Any, AsyncGenerator, Dict, List, Mapping, Optional, Tuple, Union, cast+from typing import Any, Dict, List, Optional, Tuple, Union, castfrom urllib.parse import urlencode, urlparseimport httpxdiff --git a/litellm/proxy/prompts/prompt_registry.py b/litellm/proxy/prompts/prompt_registry.pyindex e4d6fb30a1d..8ec1225c5f2 100644--- a/litellm/proxy/prompts/prompt_registry.py+++ b/litellm/proxy/prompts/prompt_registry.py@@ -1,7 +1,8 @@import importlibimport os+from collections.abc import Callablefrom pathlib import Path-from typing import Callable, Dict, Optional+from typing import Dict, Optionalfrom litellm._logging import verbose_proxy_loggerfrom litellm.integrations.custom_prompt_management import CustomPromptManagementdiff --git a/litellm/proxy/proxy_cli.py b/litellm/proxy/proxy_cli.pyindex 8dc4a7b40c7..041e088ab9c 100644--- a/litellm/proxy/proxy_cli.py+++ b/litellm/proxy/proxy_cli.py@@ -6,8 +6,9 @@ import randomimport subprocessimport sysimport urllib.parse as urlparse+from collections.abc import Iterablefrom pathlib import Path-from typing import TYPE_CHECKING, Any, Iterable, Optional, Union+from typing import TYPE_CHECKING, Any, Optional, Unionimport clickimport httpxdiff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 26d5b386cdd..ec35f362f01 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -15,13 +15,11 @@ import threadingimport timeimport tracebackimport warnings-from collections.abc import Mapping+from collections.abc import AsyncGenerator, Callable, Mappingfrom datetime import datetime, timedelta, timezonefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,- Callable,Dict,List,Literal,@@ -308,11 +306,6 @@ from litellm.proxy.common_utils.encrypt_decrypt_utils import (encrypt_value_helper,)from litellm.proxy.common_utils.html_forms.ui_login import build_ui_login_form-from litellm.proxy.config_resolvers import resolve_fields-from litellm.proxy.config_resolvers.alerting import (- EMAIL_DESCRIPTORS,- SLACK_DESCRIPTORS,-)from litellm.proxy.common_utils.http_parsing_utils import (_read_request_body,_safe_get_request_headers,@@ -338,6 +331,11 @@ from litellm.proxy.common_utils.user_api_key_cache import (UserApiKeyCache,get_management_object_ttl,)+from litellm.proxy.config_resolvers import resolve_fields+from litellm.proxy.config_resolvers.alerting import (+ EMAIL_DESCRIPTORS,+ SLACK_DESCRIPTORS,+)from litellm.proxy.container_endpoints.endpoints import router as container_routerfrom litellm.proxy.credential_endpoints.endpoints import router as credential_routerfrom litellm.proxy.db.db_transaction_queue.spend_log_cleanup import SpendLogCleanup@@ -387,6 +385,8 @@ from litellm.proxy.management_endpoints.common_utils import ()from litellm.proxy.management_endpoints.coordination_redis_endpoints import (get_persisted_coordination_redis_settings,+)+from litellm.proxy.management_endpoints.coordination_redis_endpoints import (router as coordination_redis_settings_router,)from litellm.proxy.management_endpoints.cost_tracking_settings import (@@ -395,16 +395,6 @@ from litellm.proxy.management_endpoints.cost_tracking_settings import (from litellm.proxy.management_endpoints.customer_endpoints import (router as customer_router,)-from litellm.proxy.management_endpoints.management_v1 import (- router as management_v1_router,-)-from litellm.proxy.management_endpoints.management_v1.common import (- MANAGEMENT_V1_PREFIX,- PROBLEM_TYPE_BASE,- ManagementProblem,- problem_response,-)-from litellm.types.proxy.management_endpoints.management_v1 import ProblemDetailfrom litellm.proxy.management_endpoints.fallback_management_endpoints import (router as fallback_management_router,)@@ -422,6 +412,15 @@ from litellm.proxy.management_endpoints.key_management_endpoints import (from litellm.proxy.management_endpoints.key_management_endpoints import (router as key_management_router,)+from litellm.proxy.management_endpoints.management_v1 import (+ router as management_v1_router,+)+from litellm.proxy.management_endpoints.management_v1.common import (+ MANAGEMENT_V1_PREFIX,+ PROBLEM_TYPE_BASE,+ ManagementProblem,+ problem_response,+)from litellm.proxy.management_endpoints.model_access_group_management_endpoints import (router as model_access_group_management_router,)@@ -475,6 +474,7 @@ from litellm.proxy.plugin_routes import (from litellm.proxy.plugin_routes import (router as plugin_router,)+from litellm.types.proxy.management_endpoints.management_v1 import ProblemDetailtry:from litellm.proxy.enterprise_billing.billing_metrics import (diff --git a/litellm/proxy/response_api_endpoints/endpoints.py b/litellm/proxy/response_api_endpoints/endpoints.pyindex 05c36406f36..e594111f324 100644--- a/litellm/proxy/response_api_endpoints/endpoints.py+++ b/litellm/proxy/response_api_endpoints/endpoints.py@@ -1,7 +1,8 @@import asyncioimport jsonimport time-from typing import Any, AsyncIterator, Dict, Optional, cast+from collections.abc import AsyncIterator+from typing import Any, Dict, Optional, castfrom uuid import uuid4import fastapidiff --git a/litellm/proxy/route_llm_request.py b/litellm/proxy/route_llm_request.pyindex 12e9857219e..11525b98ecc 100644--- a/litellm/proxy/route_llm_request.py+++ b/litellm/proxy/route_llm_request.py@@ -1,5 +1,6 @@import asyncio-from typing import TYPE_CHECKING, Any, Literal, Mapping, Optional+from collections.abc import Mapping+from typing import TYPE_CHECKING, Any, Literal, Optionalimport httpxfrom fastapi import HTTPException, statusdiff --git a/litellm/proxy/shutdown/graceful_shutdown_manager.py b/litellm/proxy/shutdown/graceful_shutdown_manager.pyindex 20ffabdd7d8..3b5e07d6d69 100644--- a/litellm/proxy/shutdown/graceful_shutdown_manager.py+++ b/litellm/proxy/shutdown/graceful_shutdown_manager.py@@ -20,7 +20,8 @@ granularity of ``InFlightRequestsMiddleware``.import asyncioimport osimport time-from typing import Callable, Optional+from collections.abc import Callable+from typing import Optionalfrom litellm._logging import verbose_proxy_loggerfrom litellm.proxy.middleware.in_flight_requests_middleware import (diff --git a/litellm/proxy/spend_tracking/budget_reservation.py b/litellm/proxy/spend_tracking/budget_reservation.pyindex 12ecd2ec300..1623979ad8c 100644--- a/litellm/proxy/spend_tracking/budget_reservation.py+++ b/litellm/proxy/spend_tracking/budget_reservation.py@@ -2,9 +2,10 @@ from __future__ import annotationsimport asyncioimport json+from collections.abc import Mapping, Sequencefrom dataclasses import dataclassfrom datetime import datetime, timedelta, timezone-from typing import Any, Dict, List, Mapping, NoReturn, Optional, Sequence, cast+from typing import Any, Dict, List, NoReturn, Optional, castfrom fastapi import HTTPException, status@@ -471,8 +472,8 @@ async def _get_tag_budget_counters(user_api_key_cache: DualCache,proxy_logging_obj: ProxyLogging,) -> List[_BudgetCounter]:- from litellm.proxy.common_utils.http_parsing_utils import get_tags_from_request_bodyfrom litellm.proxy.auth.auth_checks import get_tag_objects_batch+ from litellm.proxy.common_utils.http_parsing_utils import get_tags_from_request_bodytag_names = _dedupe_tags(get_tags_from_request_body(request_body=request_body))if not tag_names:@@ -659,8 +660,8 @@ async def _reserve_counter(from litellm.proxy.proxy_server import (_ensure_spend_counter_initialized,_ensure_window_spend_counter_initialized,- _invalidate_spend_counter,_increment_spend_counter_cache,+ _invalidate_spend_counter,)attempted_increment = Falsediff --git a/litellm/proxy/spend_tracking/spend_management_endpoints.py b/litellm/proxy/spend_tracking/spend_management_endpoints.pyindex bc37058689e..cbaca95d688 100644--- a/litellm/proxy/spend_tracking/spend_management_endpoints.py+++ b/litellm/proxy/spend_tracking/spend_management_endpoints.py@@ -2,6 +2,7 @@import collectionsimport jsonimport os+from collections.abc import Mapping, Sequencefrom datetime import datetime, timedelta, timezonefrom typing import (TYPE_CHECKING,@@ -9,10 +10,8 @@ from typing import (Dict,List,Literal,- Mapping,NamedTuple,Protocol,- Sequence,TypedDict,TypeVar,Union,diff --git a/litellm/proxy/types_utils/utils.py b/litellm/proxy/types_utils/utils.pyindex 8d7aedce4d0..c879315d477 100644--- a/litellm/proxy/types_utils/utils.py+++ b/litellm/proxy/types_utils/utils.py@@ -2,7 +2,8 @@ import asyncioimport importlibimport importlib.utilimport os-from typing import Any, Callable, Literal, Optional, get_type_hints+from collections.abc import Callable+from typing import Any, Literal, Optional, get_type_hintsdef get_instance_fn(value: str, config_file_path: Optional[str] = None) -> Any:diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.pyindex 2ca251a3211..86eee5c8d7a 100644--- a/litellm/proxy/utils.py+++ b/litellm/proxy/utils.py@@ -10,6 +10,7 @@ import sysimport threadingimport timeimport traceback+from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping, Sequencefrom dataclasses import dataclass, fieldfrom datetime import date, datetime, timedelta, timezonefrom email.mime.multipart import MIMEMultipart@@ -17,16 +18,11 @@ from email.mime.text import MIMETextfrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,- Awaitable,- Callable,ClassVar,Dict,List,Literal,- Mapping,Optional,- Sequence,Tuple,Union,cast,@@ -98,9 +94,6 @@ from litellm.integrations.custom_guardrail import (CustomGuardrail,ModifyResponseException,)-from litellm.proxy.hooks.sensitive_data_routing import (- _PROXY_SensitiveDataRoutingHandler,-)from litellm.integrations.custom_logger import CustomLoggerfrom litellm.integrations.prometheus import PrometheusLoggerfrom litellm.integrations.SlackAlerting.slack_alerting import SlackAlerting@@ -147,6 +140,9 @@ from litellm.proxy.hooks.parallel_request_limiter import (from litellm.proxy.hooks.parallel_request_limiter_v3 import (_PROXY_MaxParallelRequestsHandler_v3,)+from litellm.proxy.hooks.sensitive_data_routing import (+ _PROXY_SensitiveDataRoutingHandler,+)from litellm.proxy.litellm_pre_call_utils import LiteLLMProxyRequestSetupfrom litellm.proxy.policy_engine.pipeline_executor import PipelineExecutorfrom litellm.repositories.budget_repository import BudgetRepositorydiff --git a/litellm/rag/main.py b/litellm/rag/main.pyindex 29891ccfd24..80d6efe9ddb 100644--- a/litellm/rag/main.py+++ b/litellm/rag/main.py@@ -11,14 +11,13 @@ __all__ = ["ingest", "aingest", "query", "aquery"]import asyncioimport contextvars+from collections.abc import Coroutine, Iteratorfrom contextlib import contextmanagerfrom functools import partialfrom typing import (TYPE_CHECKING,Any,- Coroutine,Dict,- Iterator,List,Optional,Tuple,diff --git a/litellm/repositories/user_repository.py b/litellm/repositories/user_repository.pyindex e93991463f8..14b49f05304 100644--- a/litellm/repositories/user_repository.py+++ b/litellm/repositories/user_repository.py@@ -3,7 +3,8 @@ User repository for database operations on LiteLLM_UserTable."""import json-from typing import Any, Dict, List, Mapping, Optional, Type+from collections.abc import Mapping+from typing import Any, Dict, List, Optional, Typefrom litellm.models.user import LiteLLM_UserTablefrom litellm.repositories.base_repository import BaseRepository, DbRecord, record_to_dictdiff --git a/litellm/rerank_api/main.py b/litellm/rerank_api/main.pyindex b6ebf5589b7..75a35f8341e 100644--- a/litellm/rerank_api/main.py+++ b/litellm/rerank_api/main.py@@ -1,7 +1,8 @@import asyncioimport contextvars+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, List, Literal, Union+from typing import Any, Dict, List, Literal, Unionimport litellmfrom litellm._logging import verbose_loggerdiff --git a/litellm/responses/file_search/emulated_handler.py b/litellm/responses/file_search/emulated_handler.pyindex 6e27ad66f54..0e01e7d977f 100644--- a/litellm/responses/file_search/emulated_handler.py+++ b/litellm/responses/file_search/emulated_handler.py@@ -14,7 +14,8 @@ Flow:import jsonimport timeimport uuid-from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, cast+from collections.abc import Iterable+from typing import Any, Dict, List, Optional, Tuple, Union, castfrom litellm._internal_context import is_internal_callfrom litellm._logging import verbose_loggerdiff --git a/litellm/responses/litellm_completion_transformation/handler.py b/litellm/responses/litellm_completion_transformation/handler.pyindex 8531cc55238..a11f38da150 100644--- a/litellm/responses/litellm_completion_transformation/handler.py+++ b/litellm/responses/litellm_completion_transformation/handler.py@@ -2,7 +2,8 @@Handler for transforming responses api requests to litellm.completion requests"""-from typing import Any, Coroutine, Dict, Optional, Union+from collections.abc import Coroutine+from typing import Any, Dict, Optional, Unionimport litellmfrom litellm.responses.litellm_completion_transformation.streaming_iterator import (diff --git a/litellm/responses/main.py b/litellm/responses/main.pyindex 944cf58df1c..baead17e58c 100644--- a/litellm/responses/main.py+++ b/litellm/responses/main.py@@ -1,12 +1,11 @@import asyncioimport contextvars+from collections.abc import Coroutine, Iterablefrom functools import partialfrom typing import (TYPE_CHECKING,Any,- Coroutine,Dict,- Iterable,List,Literal,Optional,diff --git a/litellm/responses/mcp/litellm_proxy_mcp_handler.py b/litellm/responses/mcp/litellm_proxy_mcp_handler.pyindex 02c4712828d..92cce711513 100644--- a/litellm/responses/mcp/litellm_proxy_mcp_handler.py+++ b/litellm/responses/mcp/litellm_proxy_mcp_handler.py@@ -1,12 +1,11 @@import reimport traceback-from collections.abc import Mapping, Sequence+from collections.abc import Iterable, Mapping, Sequencefrom datetime import datetimefrom typing import (TYPE_CHECKING,Any,Dict,- Iterable,List,Literal,Optional,diff --git a/litellm/responses/mcp/request_context.py b/litellm/responses/mcp/request_context.pyindex fa03e677b39..ce3e17dbd44 100644--- a/litellm/responses/mcp/request_context.py+++ b/litellm/responses/mcp/request_context.py@@ -8,8 +8,9 @@ surface from silently dropping a field: omitting the auth headers, for instance,still executes the tool, just with no credentials."""+from collections.abc import Iterable, Mapping, Sequencefrom dataclasses import dataclass-from typing import Any, Iterable, Mapping, Sequence, Union+from typing import Any, Union@dataclass(frozen=True, slots=True)diff --git a/litellm/responses/streaming_iterator.py b/litellm/responses/streaming_iterator.pyindex dab666ff0d9..d4356c80f19 100644--- a/litellm/responses/streaming_iterator.py+++ b/litellm/responses/streaming_iterator.py@@ -5,10 +5,11 @@ import jsonimport timeimport tracebackimport uuid+from collections.abc import Mappingfrom datetime import datetimefrom functools import lru_cachefrom types import MappingProxyType-from typing import Any, Dict, List, Literal, Mapping, Optional+from typing import Any, Dict, List, Literal, Optionalimport httpxfrom openai._streaming import SSEDecoderdiff --git a/litellm/responses/utils.py b/litellm/responses/utils.pyindex 429ddeef36a..e46670b39e4 100644--- a/litellm/responses/utils.py+++ b/litellm/responses/utils.py@@ -1,11 +1,10 @@import base64import re+from collections.abc import Iterable, Mappingfrom typing import (Any,Dict,- Iterable,List,- Mapping,Optional,Type,Union,diff --git a/litellm/router.py b/litellm/router.pyindex 399bfcdf3e1..396f792a3f5 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -19,16 +19,13 @@ import threadingimport timeimport tracebackfrom collections import defaultdict-from collections.abc import Mapping+from collections.abc import AsyncGenerator, Callable, Generator, Mappingfrom functools import lru_cachefrom typing import (TYPE_CHECKING,Any,- AsyncGenerator,- Callable,Dict,FrozenSet,- Generator,List,Literal,Optional,@@ -64,9 +61,6 @@ from litellm.constants import ()from litellm.integrations.custom_logger import CustomLoggerfrom litellm.litellm_core_utils.asyncify import run_async_function-from litellm.litellm_core_utils.request_timeout_resolver import (- get_configured_request_timeout,-)from litellm.litellm_core_utils.core_helpers import (_get_parent_otel_span_from_kwargs,coerce_token_limit,@@ -77,6 +71,9 @@ from litellm.litellm_core_utils.coroutine_checker import coroutine_checkerfrom litellm.litellm_core_utils.credential_accessor import CredentialAccessorfrom litellm.litellm_core_utils.dd_tracing import tracerfrom litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLogging+from litellm.litellm_core_utils.request_timeout_resolver import (+ get_configured_request_timeout,+)from litellm.litellm_core_utils.secret_redaction import redact_stringfrom litellm.litellm_core_utils.sensitive_data_masker import (SensitiveDataMasker,@@ -106,14 +103,14 @@ from litellm.router_utils.add_retry_fallback_headers import (prepare_response_for_header_attachment,response_in_flight_token_count,)+from litellm.router_utils.auto_router_model_naming import (+ classify_strategy_router_model,+)from litellm.router_utils.batch_utils import (_get_router_metadata_variable_name,replace_model_in_jsonl,should_replace_model_in_jsonl,)-from litellm.router_utils.auto_router_model_naming import (- classify_strategy_router_model,-)from litellm.router_utils.client_initalization_utils import InitalizeCachedClientfrom litellm.router_utils.clientside_credential_handler import (get_dynamic_litellm_params,@@ -149,15 +146,15 @@ from litellm.router_utils.health_state_cache import DeploymentHealthCachefrom litellm.router_utils.pre_call_checks.deployment_affinity_check import (DeploymentAffinityCheck,)-from litellm.router_utils.pre_call_checks.model_rate_limit_check import (- ModelRateLimitingCheck,-)from litellm.router_utils.pre_call_checks.io_token_rate_limit_check import (build_io_token_rate_limit_headers,deployment_has_io_token_limits,refund_stale_reservation_before_retry,set_io_token_rate_limit_request_kwargs,)+from litellm.router_utils.pre_call_checks.model_rate_limit_check import (+ ModelRateLimitingCheck,+)from litellm.router_utils.pre_call_checks.prompt_caching_deployment_check import (PromptCachingDeploymentCheck,)@@ -203,20 +200,18 @@ from litellm.types.router import ()from litellm.types.services import ServiceTypesfrom litellm.types.utils import (+ PROMPT_QUOTING_ROUTING_DECISION_FIELDS,CustomPricingLiteLLMParams,GenericBudgetConfigType,LiteLLMBatch,- shared_backend_model_info,-)-from litellm.types.utils import ModelInfo-from litellm.types.utils import ModelInfo as ModelMapInfo-from litellm.types.utils import (- PROMPT_QUOTING_ROUTING_DECISION_FIELDS,+ ModelInfo,ModelResponseStream,StandardLoggingPayload,StandardLoggingRoutingDecision,Usage,+ shared_backend_model_info,)+from litellm.types.utils import ModelInfo as ModelMapInfofrom litellm.utils import (CustomStreamWrapper,EmbeddingResponse,@@ -235,6 +230,12 @@ from .router_utils.pattern_match_deployments import PatternMatchRouterif TYPE_CHECKING:from opentelemetry.trace import Span as _Span+ from litellm.responses.streaming_iterator import (+ BaseResponsesAPIStreamingIterator,+ )+ from litellm.router_strategy.adaptive_router.adaptive_router import (+ AdaptiveRouter,+ )from litellm.router_strategy.auto_router.auto_router import (AutoRouter,PreRoutingHookResponse,@@ -242,15 +243,9 @@ if TYPE_CHECKING:from litellm.router_strategy.complexity_router.complexity_router import (ComplexityRouter,)- from litellm.router_strategy.adaptive_router.adaptive_router import (- AdaptiveRouter,- )from litellm.router_strategy.quality_router.quality_router import (QualityRouter,)- from litellm.responses.streaming_iterator import (- BaseResponsesAPIStreamingIterator,- )from litellm.types.llms.base import BaseLiteLLMOpenAIResponseObjectfrom litellm.types.llms.openai import (ResponseAPIUsage,@@ -4595,12 +4590,11 @@ class Router:_aresponses_streaming_iterator so MidStreamFallbackError raisedduring iteration triggers the Router's cross-provider fallback chain."""+ from litellm.litellm_core_utils.core_helpers import safe_deep_copyfrom litellm.responses.streaming_iterator import (BaseResponsesAPIStreamingIterator,)- from litellm.litellm_core_utils.core_helpers import safe_deep_copy-# Snapshot the request kwargs before _ageneric_api_call_with_fallbacks# mutates them. A shallow copy alone is not enough: the primary# attempt mutates nested dicts in place — notably `litellm_metadata`,diff --git a/litellm/router_strategy/adaptive_router/classifier.py b/litellm/router_strategy/adaptive_router/classifier.pyindex 1cd66fc7242..7164d8a794e 100644--- a/litellm/router_strategy/adaptive_router/classifier.py+++ b/litellm/router_strategy/adaptive_router/classifier.py@@ -8,7 +8,8 @@ Order matters: we check more specific types first, falling back to GENERAL."""import re-from typing import List, Pattern, Tuple+from re import Pattern+from typing import List, Tuplefrom litellm.types.router import RequestTypediff --git a/litellm/router_utils/auto_router_model_naming.py b/litellm/router_utils/auto_router_model_naming.pyindex 72865501030..b89e1c154f0 100644--- a/litellm/router_utils/auto_router_model_naming.py+++ b/litellm/router_utils/auto_router_model_naming.py@@ -10,7 +10,8 @@ the router silently dropping the deployment at load time under``ignore_invalid_deployments``."""-from typing import Literal, Mapping+from collections.abc import Mapping+from typing import LiteralAUTO_ROUTER_MODEL_PREFIX = "auto_router/"diff --git a/litellm/router_utils/search_api_router.py b/litellm/router_utils/search_api_router.pyindex 260bb4cc03a..f0bad959da4 100644--- a/litellm/router_utils/search_api_router.py+++ b/litellm/router_utils/search_api_router.py@@ -7,8 +7,9 @@ Handles search tool selection, load balancing, and fallback logic for search reqimport asyncioimport randomimport traceback+from collections.abc import Callablefrom functools import partial-from typing import Any, Callable, Dict, Optional, Tuple+from typing import Any, Dict, Optional, Tuplefrom litellm._logging import verbose_router_loggerdiff --git a/litellm/rust_bridge/messages.py b/litellm/rust_bridge/messages.pyindex 5abb21879d3..728a16edad3 100644--- a/litellm/rust_bridge/messages.py+++ b/litellm/rust_bridge/messages.py@@ -2,8 +2,9 @@from __future__ import annotations+from collections.abc import Awaitablefrom dataclasses import dataclass-from typing import Awaitable, Final, Protocol, Union, cast+from typing import Final, Protocol, Union, castimport httpxdiff --git a/litellm/rust_bridge/ocr.py b/litellm/rust_bridge/ocr.pyindex 91aac6c1232..388da00f7f0 100644--- a/litellm/rust_bridge/ocr.py+++ b/litellm/rust_bridge/ocr.py@@ -3,7 +3,8 @@from __future__ import annotationsimport os-from typing import TYPE_CHECKING, Any, Awaitable, Final, Protocol, Union, cast+from collections.abc import Awaitable+from typing import TYPE_CHECKING, Any, Final, Protocol, Union, castimport httpxdiff --git a/litellm/rust_bridge/transcription.py b/litellm/rust_bridge/transcription.pyindex 44bb42e4104..0ed50e5d1dd 100644--- a/litellm/rust_bridge/transcription.py+++ b/litellm/rust_bridge/transcription.py@@ -1,7 +1,8 @@from __future__ import annotations+from collections.abc import Awaitablefrom dataclasses import dataclass-from typing import Awaitable, Final, Protocol, Union, cast+from typing import Final, Protocol, Union, castimport httpxdiff --git a/litellm/search/main.py b/litellm/search/main.pyindex 4e1920f4599..8954b626151 100644--- a/litellm/search/main.py+++ b/litellm/search/main.py@@ -4,8 +4,9 @@ Main Search function for LiteLLM.import asyncioimport contextvars+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, List, Optional, Union+from typing import Any, Dict, List, Optional, Unionimport httpxdiff --git a/litellm/secret_managers/get_azure_ad_token_provider.py b/litellm/secret_managers/get_azure_ad_token_provider.pyindex 2c52054964d..4c54166a877 100644--- a/litellm/secret_managers/get_azure_ad_token_provider.py+++ b/litellm/secret_managers/get_azure_ad_token_provider.py@@ -1,5 +1,6 @@import os-from typing import Any, Callable, Optional, Union+from collections.abc import Callable+from typing import Any, Optional, Unionfrom litellm._logging import verbose_loggerfrom litellm.types.secret_managers.get_azure_ad_token_provider import (diff --git a/litellm/skills/main.py b/litellm/skills/main.pyindex 00ee89e5e77..382aceca3af 100644--- a/litellm/skills/main.py+++ b/litellm/skills/main.py@@ -5,8 +5,9 @@ Provides create, list, get, and delete operations for skillsimport asyncioimport contextvars+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, List, Optional, Union+from typing import Any, Dict, List, Optional, Unionimport httpxdiff --git a/litellm/utils.py b/litellm/utils.pyindex ad661fd3d16..9bcf0739361 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -60,24 +60,24 @@ from litellm._lazy_imports import (_get_token_counter_new,)from litellm._uuid import uuid-from litellm.litellm_core_utils.fallback_generalizations import (- match_capability_generalizations,-)from litellm.constants import (DEFAULT_CHAT_COMPLETION_PARAM_VALUES,DEFAULT_EMBEDDING_PARAM_VALUES,DEFAULT_MAX_LRU_CACHE_SIZE,+ DEFAULT_MINIMUM_PROMPT_CACHE_TOKEN_COUNT,DEFAULT_TRIM_RATIO,FUNCTION_DEFINITION_TOKEN_COUNT,INITIAL_RETRY_DELAY,JITTER,MAX_RETRY_DELAY,MAX_TOKEN_TRIMMING_ATTEMPTS,- DEFAULT_MINIMUM_PROMPT_CACHE_TOKEN_COUNT,MINIMUM_PROMPT_CACHE_TOKEN_COUNT_OVERRIDE,OPENAI_EMBEDDING_PARAMS,TOOL_CHOICE_OBJECT_TOKEN_COUNT,)+from litellm.litellm_core_utils.fallback_generalizations import (+ match_capability_generalizations,+)_CachingHandlerResponse = None_LLMCachingHandler = None@@ -170,7 +170,6 @@ from litellm.types.llms.openai import (OpenAITextCompletionUserMessage,OpenAIWebSearchOptions,)-from litellm.types.utils import FileTypes # type: ignorefrom litellm.types.utils import (OPENAI_RESPONSE_HEADERS,CallTypes,@@ -183,6 +182,7 @@ from litellm.types.utils import (Delta,Embedding,EmbeddingResponse,+ FileTypes, # type: ignoreFunction,ImageResponse,LlmProviders,@@ -234,15 +234,13 @@ except (ImportError, AttributeError, TypeError):# Convert to str (if necessary)claude_json_str = json.dumps(json_data)import importlib.metadata+from collections.abc import Callable, Iterable, Mappingfrom typing import (TYPE_CHECKING,Any,- Callable,Dict,- Iterable,List,Literal,- Mapping,Optional,Tuple,Type,@@ -265,53 +263,6 @@ if TYPE_CHECKING:LLMCachingHandler,)from litellm.integrations.custom_logger import CustomLogger- from litellm.llms.base_llm.files.transformation import BaseFilesConfig- from litellm.llms.base_llm.realtime.http_transformation import (- BaseRealtimeHTTPConfig,- )- from litellm.proxy._types import AllowedModelRegion-- # Type stubs for lazy-loaded functions to help mypy understand their types- # These imports allow mypy to understand the types when these are accessed via __getattr__- from litellm.litellm_core_utils.exception_mapping_utils import exception_type- from litellm.litellm_core_utils.get_llm_provider_logic import (- _is_non_openai_azure_model,- get_llm_provider,- )- from litellm.litellm_core_utils.get_supported_openai_params import (- get_supported_openai_params,- )- from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response import (- LiteLLMResponseObjectHandler,- _handle_invalid_parallel_tool_calls,- convert_to_model_response_object,- convert_to_streaming_response,- convert_to_streaming_response_async,- )- from litellm.litellm_core_utils.llm_response_utils.get_api_base import get_api_base- from litellm.litellm_core_utils.llm_response_utils.response_metadata import (- ResponseMetadata,- )- from litellm.litellm_core_utils.prompt_templates.common_utils import (- _parse_content_for_reasoning,- )- from litellm.litellm_core_utils.redact_messages import (- LiteLLMLoggingObject,- redact_message_input_output_from_logging,- )- from litellm.litellm_core_utils.streaming_handler import CustomStreamWrapper- from litellm.llms.base_llm.google_genai.transformation import (- BaseGoogleGenAIGenerateContentConfig,- )- from litellm.llms.base_llm.ocr.transformation import BaseOCRConfig- from litellm.llms.base_llm.sandbox.transformation import BaseSandboxConfig- from litellm.llms.base_llm.search.transformation import BaseSearchConfig- from litellm.llms.base_llm.text_to_speech.transformation import (- BaseTextToSpeechConfig,- )- from litellm.llms.bedrock.common_utils import BedrockModelInfo- from litellm.llms.cohere.common_utils import CohereModelInfo- from litellm.llms.mistral.ocr.transformation import MistralOCRConfig# Type stubs for lazy-loaded functions and classesfrom litellm.litellm_core_utils.cached_imports import (@@ -328,11 +279,30 @@ if TYPE_CHECKING:delete_nested_value,is_nested_path,)++ # Type stubs for lazy-loaded functions to help mypy understand their types+ # These imports allow mypy to understand the types when these are accessed via __getattr__+ from litellm.litellm_core_utils.exception_mapping_utils import exception_typefrom litellm.litellm_core_utils.get_litellm_params import (_get_base_model_from_litellm_call_metadata,get_litellm_params,)+ from litellm.litellm_core_utils.get_llm_provider_logic import (+ _is_non_openai_azure_model,+ get_llm_provider,+ )+ from litellm.litellm_core_utils.get_supported_openai_params import (+ get_supported_openai_params,+ )from litellm.litellm_core_utils.llm_request_utils import _ensure_extra_body_is_safe+ from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response import (+ LiteLLMResponseObjectHandler,+ _handle_invalid_parallel_tool_calls,+ convert_to_model_response_object,+ convert_to_streaming_response,+ convert_to_streaming_response_async,+ )+ from litellm.litellm_core_utils.llm_response_utils.get_api_base import get_api_basefrom litellm.litellm_core_utils.llm_response_utils.get_formatted_prompt import (get_formatted_prompt,)@@ -340,9 +310,18 @@ if TYPE_CHECKING:get_response_headers,)from litellm.litellm_core_utils.llm_response_utils.response_metadata import (+ ResponseMetadata,update_response_metadata,)+ from litellm.litellm_core_utils.prompt_templates.common_utils import (+ _parse_content_for_reasoning,+ )+ from litellm.litellm_core_utils.redact_messages import (+ LiteLLMLoggingObject,+ redact_message_input_output_from_logging,+ )from litellm.litellm_core_utils.rules import Rules+ from litellm.litellm_core_utils.streaming_handler import CustomStreamWrapperfrom litellm.litellm_core_utils.thread_pool_executor import executorfrom litellm.llms.base_llm.anthropic_messages.transformation import (BaseAnthropicMessagesConfig,@@ -350,16 +329,15 @@ if TYPE_CHECKING:from litellm.llms.base_llm.audio_transcription.transformation import (BaseAudioTranscriptionConfig,)- from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler- from litellm.router_utils.get_retry_from_policy import (- get_num_retries_from_retry_policy,- reset_retry_policy,- )# Type stubs for lazy-loaded config classes and typesfrom litellm.llms.base_llm.batches.transformation import BaseBatchesConfigfrom litellm.llms.base_llm.containers.transformation import BaseContainerConfigfrom litellm.llms.base_llm.embedding.transformation import BaseEmbeddingConfig+ from litellm.llms.base_llm.files.transformation import BaseFilesConfig+ from litellm.llms.base_llm.google_genai.transformation import (+ BaseGoogleGenAIGenerateContentConfig,+ )from litellm.llms.base_llm.image_edit.transformation import BaseImageEditConfigfrom litellm.llms.base_llm.image_generation.transformation import (BaseImageGenerationConfig,@@ -367,33 +345,50 @@ if TYPE_CHECKING:from litellm.llms.base_llm.image_variations.transformation import (BaseImageVariationConfig,)+ from litellm.llms.base_llm.ocr.transformation import BaseOCRConfigfrom litellm.llms.base_llm.passthrough.transformation import BasePassthroughConfig+ from litellm.llms.base_llm.realtime.http_transformation import (+ BaseRealtimeHTTPConfig,+ )from litellm.llms.base_llm.realtime.transformation import BaseRealtimeConfigfrom litellm.llms.base_llm.rerank.transformation import BaseRerankConfig+ from litellm.llms.base_llm.sandbox.transformation import BaseSandboxConfig+ from litellm.llms.base_llm.search.transformation import BaseSearchConfig+ from litellm.llms.base_llm.text_to_speech.transformation import (+ BaseTextToSpeechConfig,+ )from litellm.llms.base_llm.vector_store.transformation import BaseVectorStoreConfigfrom litellm.llms.base_llm.vector_store_files.transformation import (BaseVectorStoreFilesConfig,)from litellm.llms.base_llm.videos.transformation import BaseVideoConfig+ from litellm.llms.bedrock.common_utils import BedrockModelInfo+ from litellm.llms.cohere.common_utils import CohereModelInfo+ from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler+ from litellm.llms.mistral.ocr.transformation import MistralOCRConfig+ from litellm.proxy._types import AllowedModelRegion+ from litellm.router_utils.get_retry_from_policy import (+ get_num_retries_from_retry_policy,+ reset_retry_policy,+ )from litellm.types.llms.anthropic import (ANTHROPIC_API_ONLY_HEADERS,AnthropicThinkingParam,)- from litellm.types.rerank import RerankResponsefrom litellm.types.llms.openai import (ChatCompletionDeltaToolCallChunk,ChatCompletionToolCallChunk,ChatCompletionToolCallFunctionChunk,)+ from litellm.types.rerank import RerankResponsefrom litellm.types.router import LiteLLM_Params-from litellm.secret_managers.main import get_secret-from litellm.llms.base_llm.chat.transformation import BaseConfigfrom litellm.llms.base_llm.completion.transformation import BaseTextCompletionConfigfrom litellm.llms.base_llm.evals.transformation import BaseEvalsAPIConfigfrom litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfigfrom litellm.llms.base_llm.skills.transformation import BaseSkillsAPIConfig+from litellm.secret_managers.main import get_secretfrom ._logging import _is_debugging_on, verbose_loggerfrom .caching.caching import (diff --git a/litellm/vector_store_files/main.py b/litellm/vector_store_files/main.pyindex c7580625f82..41990de8ec2 100644--- a/litellm/vector_store_files/main.py+++ b/litellm/vector_store_files/main.py@@ -2,8 +2,9 @@import asyncioimport contextvars+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, Optional, Union+from typing import Any, Dict, Optional, Unionimport httpxdiff --git a/litellm/vector_stores/main.py b/litellm/vector_stores/main.pyindex f768ee75545..e7d930122b5 100644--- a/litellm/vector_stores/main.py+++ b/litellm/vector_stores/main.py@@ -5,8 +5,9 @@ LiteLLM SDK Functions for Creating and Searching Vector Storesimport asyncioimport builtinsimport contextvars+from collections.abc import Coroutinefrom functools import partial-from typing import Any, Coroutine, Dict, List, Optional, Union+from typing import Any, Dict, List, Optional, Unionimport httpxdiff --git a/litellm/videos/main.py b/litellm/videos/main.pyindex cc3a15f9cd2..1d17b566b5c 100644--- a/litellm/videos/main.py+++ b/litellm/videos/main.py@@ -1,8 +1,9 @@import asyncioimport contextvarsimport json+from collections.abc import Coroutinefrom functools import partial-from typing import Coroutine, Dict, List, Literal, Optional, Union, overload+from typing import Dict, List, Literal, Optional, Union, overloadimport litellmfrom litellm.constants import DEFAULT_VIDEO_ENDPOINT_MODELdiff --git a/ruff-strict-budget.json b/ruff-strict-budget.jsonindex 57f69dfffe7..537e019af1e 100644--- a/ruff-strict-budget.json+++ b/ruff-strict-budget.json@@ -123,7 +123,7 @@"limit": 52},"I001": {- "limit": 261+ "limit": 196},"LOG015": {"limit": 8@@ -306,7 +306,7 @@"limit": 9},"TID251": {- "limit": 2649+ "limit": 2648},"TRY002": {"limit": 547@@ -354,7 +354,7 @@"limit": 4},"UP035": {- "limit": 2232+ "limit": 1909},"UP036": {"limit": 4