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(types): replace Any with proven types in 24 files (#46663)
Mateo Wangd1a7fcde8ed6
diff --git a/litellm/caching/azure_blob_cache.py b/litellm/caching/azure_blob_cache.pyindex 742932731b3..bf0e15421bc 100644--- a/litellm/caching/azure_blob_cache.py+++ b/litellm/caching/azure_blob_cache.py@@ -65,7 +65,7 @@ class AzureBlobCache(BaseCache):print_verbose(f"Get Azure Blob Cache: key: {key}")as_bytes: Final = self.container_client.download_blob(key).readall()as_str: Final = as_bytes.decode("utf-8")- cached_response: Final = json.loads(as_str)+ cached_response: Final[object] = json.loads(as_str)verbose_logger.debug("Got Azure Blob Cache: key: %s, cached_response %s. Type Response %s",@@ -86,7 +86,7 @@ class AzureBlobCache(BaseCache):blob: Final = await self.async_container_client.download_blob(key)as_bytes: Final = await blob.readall()as_str: Final = as_bytes.decode("utf-8")- cached_response: Final = json.loads(as_str)+ cached_response: Final[object] = json.loads(as_str)verbose_logger.debug("Got Azure Blob Cache: key: %s, cached_response %s. Type Response %s",key,diff --git a/litellm/exceptions.py b/litellm/exceptions.pyindex ac461a2472e..65ea61c072c 100644--- a/litellm/exceptions.py+++ b/litellm/exceptions.py@@ -10,7 +10,7 @@## LiteLLM versions of the OpenAI Exception Typesimport enum-from collections.abc import Sequence+from collections.abc import Mapping, Sequencefrom typing import Any, Finalimport httpx@@ -468,7 +468,7 @@ class RateLimitError(openai.RateLimitError):category: str | RateLimitErrorCategory = (RateLimitErrorCategory.VENDOR_RATE_LIMIT),rate_limit_type: str | RateLimitType | None = None,headers: dict[str, str] | None = None,- detail: Any = None,+ detail: object = None,body: object | None = None,):self.status_code = 429@@ -1300,8 +1300,8 @@ class ModifyResponseException(Exception):model: str,request_data: dict[str, Any],guardrail_name: str | None = None,- detection_info: dict[str, Any] | None = None,- original_response: Any | None = None,+ detection_info: Mapping[str, object] | None = None,+ original_response: object = None,):self.message = messageself.model = model@@ -1334,7 +1334,7 @@ class SensitiveDataRouteException(Exception):route_to_model: str,session_id: str,guardrail_name: str | None = None,- detection_info: dict[str, Any] | None = None,+ detection_info: Mapping[str, object] | None = None,message: str | None = None,sticky_session_routing: bool = True,):diff --git a/litellm/files/main.py b/litellm/files/main.pyindex ecef3ebe1df..e259d4230de 100644--- a/litellm/files/main.py+++ b/litellm/files/main.py@@ -11,7 +11,7 @@ import timeimport uuid as uuid_modulefrom collections.abc import Coroutinefrom functools import partial-from typing import Any, Final, Literal, cast+from typing import Final, Literal, castimport httpxfrom openai import AsyncOpenAI, OpenAI@@ -163,7 +163,7 @@ def create_file(extra_headers: dict[str, str] | None = None,extra_body: dict[str, str] | None = None,**kwargs,-) -> OpenAIFileObject | Coroutine[Any, Any, OpenAIFileObject]:+) -> OpenAIFileObject | Coroutine[object, None, OpenAIFileObject]:"""Files are used to upload documents that can be used with features like Assistants, Fine-tuning, and Batch API.@@ -867,8 +867,8 @@ def file_content() -> (HttpxBinaryResponseContent| FileContentStreamingResult- | Coroutine[Any, Any, HttpxBinaryResponseContent]- | Coroutine[Any, Any, FileContentStreamingResult]+ | Coroutine[object, None, HttpxBinaryResponseContent]+ | Coroutine[object, None, FileContentStreamingResult]):"""Returns the contents of the specified file.diff --git a/litellm/integrations/opentelemetry_utils/gen_ai_semconv.py b/litellm/integrations/opentelemetry_utils/gen_ai_semconv.pyindex 81d9a947da7..06cdf413e76 100644--- a/litellm/integrations/opentelemetry_utils/gen_ai_semconv.py+++ b/litellm/integrations/opentelemetry_utils/gen_ai_semconv.py@@ -29,21 +29,25 @@ Events:included only when content capture is enabled)."""+from collections.abc import Callablefrom datetime import datetimefrom enum import Enum-from typing import TYPE_CHECKING, Any, Final+from typing import TYPE_CHECKING, Final, Protocolfrom litellm.integrations.otel.mappers.utils import drop_nonefrom litellm.litellm_core_utils.safe_json_dumps import safe_dumpsif TYPE_CHECKING:+ from opentelemetry._logs import SeverityNumber as _SeverityNumberfrom opentelemetry.trace import Span as _Spanfrom litellm.integrations.opentelemetry import OpenTelemetryConfig- Span = _Span | Any+ Span = _Spanelse:- Span = Any++ class Span(Protocol):+ def set_attribute(self, key: str, value: object) -> None: ...# OTEL_SEMCONV_STABILITY_OPT_IN is a comma-separated list of category-specific@@ -128,7 +132,7 @@ class OTELGenAISemconvMixin:def _to_ns(self, dt: datetime) -> int: ...- def _otel_log_types(self) -> tuple[Any, Any]: ...+ def _otel_log_types(self) -> tuple[Callable[..., object], type[_SeverityNumber]]: ...@propertydef _gen_ai_semconv_latest_experimental(self) -> bool:diff --git a/litellm/integrations/otel/logger.py b/litellm/integrations/otel/logger.pyindex 0844b043a6f..4f0a30cb494 100644--- a/litellm/integrations/otel/logger.py+++ b/litellm/integrations/otel/logger.py@@ -292,7 +292,7 @@ class OpenTelemetryV2(CustomLogger):# closed here. See ``log_pre_api_call``.# ====================================================================== #- def log_pre_api_call(self, model, messages, kwargs):+ def log_pre_api_call(self, model: str, messages: object, kwargs: Mapping[str, object]) -> None:"""Open the LLM-call span at the call boundary.Runs synchronously inside the request task, before the upstream call —@@ -354,7 +354,13 @@ class OpenTelemetryV2(CustomLogger):_LLMCallSpan(span=span, start_time_ns=start_time_ns, provider=route.provider),)- async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):+ async def async_log_success_event(+ self,+ kwargs: Mapping[str, object],+ response_obj: object,+ start_time: datetime | float | None,+ end_time: datetime | float | None,+ ) -> None:if self._emit_mcp_tool_call(kwargs, start_time, end_time):returnif self._emit_mcp_list_tools(kwargs, start_time, end_time):@@ -396,7 +402,13 @@ class OpenTelemetryV2(CustomLogger):except Exception as exc:verbose_logger.debug("OpenTelemetryV2: metric recording failed: %s", exc)- async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time):+ async def async_log_failure_event(+ self,+ kwargs: Mapping[str, object],+ response_obj: object,+ start_time: datetime | float | None,+ end_time: datetime | float | None,+ ) -> None:if self._emit_mcp_tool_call(kwargs, start_time, end_time):returnif self._emit_mcp_list_tools(kwargs, start_time, end_time):diff --git a/litellm/litellm_core_utils/logging_utils.py b/litellm/litellm_core_utils/logging_utils.pyindex 5ac6b5435dc..8f58e8b7051 100644--- a/litellm/litellm_core_utils/logging_utils.py+++ b/litellm/litellm_core_utils/logging_utils.py@@ -5,7 +5,7 @@ import reimport timefrom collections.abc import Iterator, Mapping, Sequencefrom datetime import datetime-from typing import TYPE_CHECKING, Any, Final, cast+from typing import TYPE_CHECKING, Any, Final, TypeAlias, castfrom litellm._logging import format_base64_size, verbose_loggerfrom litellm.constants import (@@ -28,7 +28,7 @@ if TYPE_CHECKING:)LiteLLMModelResponse = _ModelResponse- Span = _Span | Any+ Span: TypeAlias = _Spanelse:LiteLLMModelResponse = AnyLiteLLMLoggingObject = Anydiff --git a/litellm/llms/anthropic/pass_through/responses_adapters/streaming_iterator.py b/litellm/llms/anthropic/pass_through/responses_adapters/streaming_iterator.pyindex c36e65b9b46..85287f5433a 100644--- a/litellm/llms/anthropic/pass_through/responses_adapters/streaming_iterator.py+++ b/litellm/llms/anthropic/pass_through/responses_adapters/streaming_iterator.py@@ -198,7 +198,7 @@ class AnthropicResponsesStreamWrapper:item_id,{"type": "redacted_thinking", "data": signature},)- stop: Final = {"type": "content_block_stop", "index": redacted_idx}+ stop: Final[dict[str, object]] = {"type": "content_block_stop", "index": redacted_idx}self._chunk_queue.append(stop)returnif signature is not None:diff --git a/litellm/llms/base.py b/litellm/llms/base.pyindex 8f6f45f4d35..cc9f6a089ca 100644--- a/litellm/llms/base.py+++ b/litellm/llms/base.py@@ -1,5 +1,5 @@## This is a template base class to be used for adding new LLM providers via API calls-from typing import TYPE_CHECKING, Any, Union+from typing import TYPE_CHECKING, Unionimport httpx@@ -76,11 +76,17 @@ class BaseLLM:if hasattr(self, "_aclient_session"):await self._aclient_session.aclose()- def validate_environment(self, *args, **kwargs) -> Any | None: # set up the environment required to run the model+ def validate_environment(+ self, *args, **kwargs+ ) -> object | None: # set up the environment required to run the modelreturn None- def completion(self, *args, **kwargs) -> Any: # logic for parsing in - calling - parsing out model completion calls+ def completion(+ self, *args, **kwargs+ ) -> object | None: # logic for parsing in - calling - parsing out model completion callsreturn None- def embedding(self, *args, **kwargs) -> Any: # logic for parsing in - calling - parsing out model embedding calls+ def embedding(+ self, *args, **kwargs+ ) -> object | None: # logic for parsing in - calling - parsing out model embedding callsreturn Nonediff --git a/litellm/llms/base_llm/chat/transformation.py b/litellm/llms/base_llm/chat/transformation.pyindex b58fd089470..2b3c644f266 100644--- a/litellm/llms/base_llm/chat/transformation.py+++ b/litellm/llms/base_llm/chat/transformation.py@@ -488,7 +488,7 @@ class BaseConfig(ABC):"""return True- def post_stream_processing(self, stream: Any) -> Any:+ def post_stream_processing(self, stream: object) -> object:"""Hook for providers to post-process streaming responses. Default: pass-through."""return streamdiff --git a/litellm/llms/bedrock/chat/agentcore/transformation.py b/litellm/llms/bedrock/chat/agentcore/transformation.pyindex 0813ef58528..48b3795e274 100644--- a/litellm/llms/bedrock/chat/agentcore/transformation.py+++ b/litellm/llms/bedrock/chat/agentcore/transformation.py@@ -313,7 +313,7 @@ class AmazonAgentCoreConfig(BaseConfig, BaseAWSLLM):return Nonetry:- data: Final = json.loads(json_str)+ data: Final[object] = json.loads(json_str)# Skip non-dict data (some lines contain JSON strings)return data if isinstance(data, dict) else Noneexcept json.JSONDecodeError:@@ -391,7 +391,7 @@ class AmazonAgentCoreConfig(BaseConfig, BaseAWSLLM):verbose_logger.warning("Failed to calculate token usage: %s", e)return None- def _parse_json_response(self, response_json: dict) -> AgentCoreParsedResponse:+ def _parse_json_response(self, response_json: object) -> AgentCoreParsedResponse:"""Parse direct JSON response (non-streaming).@@ -481,7 +481,7 @@ class AmazonAgentCoreConfig(BaseConfig, BaseAWSLLM):if "application/json" in content_type:# Direct JSON responseverbose_logger.debug("Parsing JSON response")- response_json: Final = raw_response.json()+ response_json: Final[object] = raw_response.json()verbose_logger.debug("Response JSON: %s", response_json)return self._parse_json_response(response_json)else:@@ -705,7 +705,7 @@ class AmazonAgentCoreConfig(BaseConfig, BaseAWSLLM):)try:body: Final = response.read()- response_json: Final = json.loads(body)+ response_json: Final[object] = json.loads(body)except (json.JSONDecodeError, Exception) as e:raise BedrockError(status_code=response.status_code,@@ -927,7 +927,7 @@ class AmazonAgentCoreConfig(BaseConfig, BaseAWSLLM):)try:body: Final = await response.aread()- response_json: Final = json.loads(body)+ response_json: Final[object] = json.loads(body)except (json.JSONDecodeError, Exception) as e:raise BedrockError(status_code=response.status_code,diff --git a/litellm/llms/black_forest_labs/image_edit/transformation.py b/litellm/llms/black_forest_labs/image_edit/transformation.pyindex 1d52c89d8bd..66eacc97fba 100644--- a/litellm/llms/black_forest_labs/image_edit/transformation.py+++ b/litellm/llms/black_forest_labs/image_edit/transformation.py@@ -317,7 +317,7 @@ class BlackForestLabsImageEditConfig(BaseImageEditConfig):The response contains: {"status": "Ready", "result": {"sample": "https://..."}}"""try:- raw_response_data: Final = raw_response.json()+ raw_response_data: Final[object] = raw_response.json()except Exception as e:raise BlackForestLabsError(status_code=raw_response.status_code,diff --git a/litellm/llms/cohere/rerank/guardrail_translation/handler.py b/litellm/llms/cohere/rerank/guardrail_translation/handler.pyindex 84cb551190a..c8dd97401d0 100644--- a/litellm/llms/cohere/rerank/guardrail_translation/handler.py+++ b/litellm/llms/cohere/rerank/guardrail_translation/handler.py@@ -5,7 +5,8 @@ This module provides guardrail translation support for the rerank endpoint.The handler processes only the 'query' parameter for guardrails."""-from typing import TYPE_CHECKING, Any, Final+from collections.abc import Mapping+from typing import TYPE_CHECKING, Finalfrom litellm._logging import verbose_proxy_loggerfrom litellm.llms.base_llm.guardrail_translation.base_translation import BaseTranslation@@ -14,6 +15,7 @@ from litellm.types.utils import GenericGuardrailAPIInputsif TYPE_CHECKING:from litellm.integrations.custom_guardrail import CustomGuardrailfrom litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj+ from litellm.proxy._types import UserAPIKeyAuthfrom litellm.types.rerank import RerankResponse@@ -44,7 +46,7 @@ class CohereRerankHandler(BaseTranslation):data: dict,guardrail_to_apply: "CustomGuardrail",litellm_logging_obj: "LiteLLMLoggingObj | None" = None,- ) -> Any:+ ) -> Mapping[str, object]:"""Process input text fields ('query' and 'instruction') by applyingguardrails and writing the sanitized values back.@@ -96,9 +98,9 @@ class CohereRerankHandler(BaseTranslation):response: "RerankResponse",guardrail_to_apply: "CustomGuardrail",litellm_logging_obj: "LiteLLMLoggingObj | None" = None,- user_api_key_dict: Any | None = None,+ user_api_key_dict: "UserAPIKeyAuth | None" = None,request_data: dict | None = None,- ) -> Any:+ ) -> "RerankResponse":"""Process output response - not applicable for rerank.diff --git a/litellm/llms/custom_httpx/aiohttp_handler.py b/litellm/llms/custom_httpx/aiohttp_handler.pyindex c3b63e207d2..d690fd9ddde 100644--- a/litellm/llms/custom_httpx/aiohttp_handler.py+++ b/litellm/llms/custom_httpx/aiohttp_handler.py@@ -671,7 +671,7 @@ class BaseLLMAIOHTTPHandler:status_code: Final = getattr(e, "status_code", 500)error_headers = getattr(e, "headers", None)error_text = getattr(e, "text", str(e))- error_response: Final = getattr(e, "response", None)+ error_response: Final[object] = getattr(e, "response", None)if error_headers is None and error_response:error_headers = getattr(error_response, "headers", None)if error_response and hasattr(error_response, "text"):diff --git a/litellm/llms/custom_llm.py b/litellm/llms/custom_llm.pyindex c70b9b81b42..fd09d300ae2 100644--- a/litellm/llms/custom_llm.py+++ b/litellm/llms/custom_llm.py@@ -8,14 +8,14 @@- async_streaming"""-from collections.abc import AsyncIterator, Callable, Coroutine, Iterator+from collections.abc import AsyncIterator, Callable, Coroutine, Iterator, Sequencefrom typing import (TYPE_CHECKING,- Any,Union,)import httpx+from openai.types.audio.transcription_create_params import FileTypesfrom litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandlerfrom litellm.types.utils import GenericStreamingChunk@@ -103,7 +103,9 @@ class CustomLLM(BaseLLM):headers={},timeout: float | httpx.Timeout | None = None,client: AsyncHTTPHandler | None = None,- ) -> Coroutine[Any, Any, Union[ModelResponse, "CustomStreamWrapper"]] | Union[ModelResponse, "CustomStreamWrapper"]:+ ) -> (+ Coroutine[None, None, Union[ModelResponse, "CustomStreamWrapper"]] | Union[ModelResponse, "CustomStreamWrapper"]+ ):raise CustomLLMError(status_code=500, message="Not implemented yet!")async def astreaming(@@ -188,7 +190,7 @@ class CustomLLM(BaseLLM):def image_edit(self,model: str,- image: Any,+ image: Sequence[FileTypes],prompt: str | None,model_response: ImageResponse,api_key: str | None,@@ -203,7 +205,7 @@ class CustomLLM(BaseLLM):async def aimage_edit(self,model: str,- image: Any,+ image: Sequence[FileTypes],prompt: str | None,model_response: ImageResponse,api_key: str | None,diff --git a/litellm/llms/mistral/ocr/guardrail_translation/handler.py b/litellm/llms/mistral/ocr/guardrail_translation/handler.pyindex 2af8172c992..9f4931ee579 100644--- a/litellm/llms/mistral/ocr/guardrail_translation/handler.py+++ b/litellm/llms/mistral/ocr/guardrail_translation/handler.py@@ -89,9 +89,9 @@ class OCRHandler(BaseTranslation):response: "OCRResponse",guardrail_to_apply: "CustomGuardrail",litellm_logging_obj: "LiteLLMLoggingObj | None" = None,- user_api_key_dict: Any | None = None,+ user_api_key_dict: object | None = None,request_data: dict | None = None,- ) -> Any:+ ) -> "OCRResponse":"""Process OCR output by applying guardrails to extracted page text.diff --git a/litellm/llms/sap/chat/transformation.py b/litellm/llms/sap/chat/transformation.pyindex 34e8acd766a..704e81de16a 100755--- a/litellm/llms/sap/chat/transformation.py+++ b/litellm/llms/sap/chat/transformation.py@@ -2,7 +2,7 @@Translate from OpenAI's `/v1/chat/completions` to SAP Generative AI Hub's Orchestration Service`v2/completion`"""-from collections.abc import AsyncIterator, Iterator+from collections.abc import AsyncIterator, Iterator, Mappingfrom functools import cached_propertyfrom typing import TYPE_CHECKING, Any, Final, Union@@ -55,14 +55,14 @@ _SAP_MODEL_PARAMS_EXCLUDED_KEYS: Final[frozenset[str]] = frozenset(def validate_dict(- data: dict, model: type[BaseModel]+ data: Mapping[str, object], model: type[BaseModel]) -> dict: # mutable-ok: pydantic validation boundary; both input and output are untyped wire dictsreturn model(**data).model_dump(by_alias=True, exclude_unset=True)def _fold_message_cache_control(- message: dict[str, object],-) -> dict[str, object]:+ message: Mapping[str, object],+) -> Mapping[str, object]:"""Move a message-level cache_control marker onto the content block.litellm's cache_control_injection_points hook attaches cache_control to thediff --git a/litellm/proxy/guardrails/guardrail_endpoints.py b/litellm/proxy/guardrails/guardrail_endpoints.pyindex 94a9d7c2bdf..edb7e043ec5 100644--- a/litellm/proxy/guardrails/guardrail_endpoints.py+++ b/litellm/proxy/guardrails/guardrail_endpoints.py@@ -65,6 +65,7 @@ from litellm.types.guardrails import (LitellmParams,PatchGuardrailRequest,PiiAction,+ PiiEntityCategoryMap,PiiEntityType,PresidioPresidioConfigModelUserInterface,SupportedGuardrailIntegrations,@@ -1504,7 +1505,7 @@ async def get_guardrail_ui_settings() -> GuardrailUIAddGuardrailSettings:)from litellm.proxy.guardrails.guardrail_registry import guardrail_class_registry- category_maps: Final = [+ category_maps: Final[list[PiiEntityCategoryMap]] = [{"category": category.value,"entities": [entity.value for entity in entities],diff --git a/litellm/rag/ingestion/base_ingestion.py b/litellm/rag/ingestion/base_ingestion.pyindex fb799546b37..f9e39e042f1 100644--- a/litellm/rag/ingestion/base_ingestion.py+++ b/litellm/rag/ingestion/base_ingestion.py@@ -56,10 +56,7 @@ class BaseRAGIngestion(ABC):# Extract configs from optionsself.ocr_config = ingest_options.get("ocr")- self.chunking_strategy: dict[str, Any] = cast(- dict[str, Any],- ingest_options.get("chunking_strategy") or {"type": "auto"},- )+ self.chunking_strategy = ingest_options.get("chunking_strategy") or {"type": "auto"}self.embedding_config = ingest_options.get("embedding")self.vector_store_config: dict[str, Any] = cast(dict[str, Any], ingest_options.get("vector_store") or {})self.ingest_name = ingest_options.get("name")diff --git a/litellm/rerank_api/main.py b/litellm/rerank_api/main.pyindex 18ecc250b64..adbf0cdb72e 100644--- a/litellm/rerank_api/main.py+++ b/litellm/rerank_api/main.py@@ -1,6 +1,6 @@import asyncioimport contextvars-from collections.abc import Coroutine+from collections.abc import Awaitablefrom functools import partialfrom typing import Any, Final, Literal@@ -40,7 +40,7 @@ async def arerank(return_documents: bool | None = None,max_chunks_per_doc: int | None = None,**kwargs,-) -> RerankResponse | Coroutine[Any, Any, RerankResponse]:+) -> RerankResponse | Awaitable[RerankResponse]:"""Async: Reranks a list of documents based on their relevance to the query"""@@ -115,7 +115,7 @@ def rerank(max_chunks_per_doc: int | None = None,max_tokens_per_doc: int | None = None,**kwargs,-) -> RerankResponse | Coroutine[Any, Any, RerankResponse]:+) -> RerankResponse | Awaitable[RerankResponse]:"""Reranks a list of documents based on their relevance to the query"""diff --git a/litellm/router_utils/cooldown_cache.py b/litellm/router_utils/cooldown_cache.pyindex aeab916a8cb..dc21db6a601 100644--- a/litellm/router_utils/cooldown_cache.py+++ b/litellm/router_utils/cooldown_cache.py@@ -19,7 +19,7 @@ from litellm.litellm_core_utils.sensitive_data_masker import SensitiveDataMaskerif TYPE_CHECKING:from opentelemetry.trace import Span as _Span- Span = _Span | Any+ Span = _Spanelse:Span = Anydiff --git a/litellm/router_utils/fallback_event_handlers.py b/litellm/router_utils/fallback_event_handlers.pyindex 4a2ec6ed1f8..1f37c6c8cb1 100644--- a/litellm/router_utils/fallback_event_handlers.py+++ b/litellm/router_utils/fallback_event_handlers.py@@ -7,6 +7,8 @@ from enum import Enumfrom types import MappingProxyTypefrom typing import TYPE_CHECKING, Any, Final+import httpx+import litellmfrom litellm._logging import verbose_router_loggerfrom litellm.integrations.custom_logger import CustomLogger@@ -132,8 +134,8 @@ def _trigger_cooldown_for_failed_deployment(if deployment_dict is not Noneelse None)- exception_headers: Final = litellm.litellm_core_utils.exception_mapping_utils._get_response_headers(- original_exception=exception+ exception_headers: Final[httpx.Headers | None] = (+ litellm.litellm_core_utils.exception_mapping_utils._get_response_headers(original_exception=exception))_get_retry_after: Final = (litellm.utils._get_retry_after_from_exception_header # pyright: ignore[reportPrivateUsage] - as router.pydiff --git a/litellm/types/containers/main.py b/litellm/types/containers/main.pyindex 24a2418a5d0..04476a25fa3 100644--- a/litellm/types/containers/main.py+++ b/litellm/types/containers/main.py@@ -1,6 +1,6 @@import builtinsfrom collections.abc import Mapping-from typing import Any, Literal+from typing import Literalfrom pydantic import PrivateAttrfrom typing_extensions import ReadOnly, TypedDict@@ -25,7 +25,7 @@ class ContainerObject(LiteLLMBaseModel):expires_after: ExpiresAfter | None = Nonelast_active_at: int | None = Nonename: str | None = None- _hidden_params: dict[str, Any] = PrivateAttr(default={})+ _hidden_params: dict[str, builtins.object] = PrivateAttr(default={})@propertydef hidden_params(self) -> dict[str, builtins.object]: # mutable-ok: API requires mutationdiff --git a/litellm/types/llms/anthropic.py b/litellm/types/llms/anthropic.pyindex 40230dbd04b..07d85fa097d 100644--- a/litellm/types/llms/anthropic.py+++ b/litellm/types/llms/anthropic.py@@ -1,6 +1,6 @@from collections.abc import Iterable, Mapping, Sequencefrom enum import Enum-from typing import Any, Final, Literal, TypeAlias+from typing import Final, Literal, TypeAliasfrom pydantic import ConfigDictfrom typing_extensions import NotRequired, ReadOnly, Required, TypedDict@@ -57,7 +57,7 @@ class AnthropicMessagesTool(TypedDict, total=False):cache_control: dict | ChatCompletionCachedContent | Nonedefer_loading: boolallowed_callers: list[str] | None- input_examples: list[dict[str, Any]] | None+ input_examples: list[dict[str, object]] | Noneeager_input_streaming: ReadOnly[bool]@@ -86,7 +86,7 @@ class AnthropicWebSearchTool(TypedDict, total=False):user_location: AnthropicWebSearchUserLocation | Nonedefer_loading: bool | Noneallowed_callers: list[str] | None- input_examples: list[dict[str, Any]] | None+ input_examples: list[dict[str, object]] | Noneclass AnthropicHostedTools(TypedDict, total=False): # for bash_tool and text_editor@@ -95,7 +95,7 @@ class AnthropicHostedTools(TypedDict, total=False): # for bash_tool and text_edcache_control: dict | ChatCompletionCachedContent | Nonedefer_loading: bool | Noneallowed_callers: list[str] | None- input_examples: list[dict[str, Any]] | None+ input_examples: list[dict[str, object]] | Noneclass AnthropicCodeExecutionTool(TypedDict, total=False):@@ -104,7 +104,7 @@ class AnthropicCodeExecutionTool(TypedDict, total=False):cache_control: dict | ChatCompletionCachedContent | Nonedefer_loading: bool | Noneallowed_callers: list[str] | None- input_examples: list[dict[str, Any]] | None+ input_examples: list[dict[str, object]] | Noneclass AnthropicMemoryTool(TypedDict, total=False):@@ -113,7 +113,7 @@ class AnthropicMemoryTool(TypedDict, total=False):cache_control: dict | ChatCompletionCachedContent | Nonedefer_loading: bool | Noneallowed_callers: list[str] | None- input_examples: list[dict[str, Any]] | None+ input_examples: list[dict[str, object]] | Noneclass AnthropicToolSearchToolRegex(TypedDict, total=False):@@ -131,7 +131,7 @@ class AnthropicToolSearchToolBM25(TypedDict, total=False):cache_control: dict | ChatCompletionCachedContent | Nonedefer_loading: bool | Noneallowed_callers: list[str] | None- input_examples: list[dict[str, Any]] | None+ input_examples: list[dict[str, object]] | NoneANTHROPIC_ADVISOR_TOOL_TYPE: Final = "advisor_20260301"@@ -421,13 +421,13 @@ class AnthropicMessagesRequestOptionalParams(TypedDict, total=False):inference_geo: str | Nonetop_p: float | Nonemcp_servers: list[AnthropicMcpServerTool] | None- context_management: dict[str, Any] | None+ context_management: dict[str, object] | Nonecompaction: ReadOnly[AnthropicCompaction | None]- container: dict[str, Any] | None # Container config with skills for code execution+ container: dict[str, object] | None # Container config with skills for code executionoutput_format: AnthropicOutputSchema | None # Structured outputs supportspeed: str | None # Fast mode support for Opus modelsoutput_config: AnthropicOutputConfig | None # Configuration for Claude's output behavior- cache_control: dict[str, Any] | None # Automatic prompt caching+ cache_control: dict[str, object] | None # Automatic prompt cachingreasoning_effort: str | Nonesafeguards: ReadOnly[list[dict[str, object]] | None]service_tier: ReadOnly[str | None]@@ -680,7 +680,7 @@ class AnthropicResponseContentBlockToolUse(LiteLLMBaseModel):id: strname: strinput: dict- provider_specific_fields: dict[str, Any] | None = None+ provider_specific_fields: dict[str, object] | None = Nonemodel_config = ConfigDict(extra="allow") # Allow provider_specific_fieldsdiff --git a/litellm/types/proxy/policy_engine/resolver_types.py b/litellm/types/proxy/policy_engine/resolver_types.pyindex 248e669e83a..58037e5dc6a 100644--- a/litellm/types/proxy/policy_engine/resolver_types.py+++ b/litellm/types/proxy/policy_engine/resolver_types.py@@ -156,7 +156,7 @@ class PolicyCreateRequest(LiteLLMBaseModel):default=None,description="Condition for when this policy applies.",)- pipeline: dict[str, Any] | None = Field(+ pipeline: dict[str, object] | None = Field(default=None,description="Optional guardrail pipeline for ordered execution. Contains 'mode' and 'steps'.",)@@ -189,7 +189,7 @@ class PolicyUpdateRequest(LiteLLMBaseModel):default=None,description="Condition for when this policy applies.",)- pipeline: dict[str, Any] | None = Field(+ pipeline: dict[str, object] | None = Field(default=None,description="Optional guardrail pipeline for ordered execution. Contains 'mode' and 'steps'.",)@@ -216,8 +216,8 @@ class PolicyDBResponse(LiteLLMBaseModel):description: str | None = Field(default=None, description="Policy description.")guardrails_add: list[str] = Field(default_factory=list, description="Guardrails to add.")guardrails_remove: list[str] = Field(default_factory=list, description="Guardrails to remove.")- condition: dict[str, Any] | None = Field(default=None, description="Policy condition.")- pipeline: dict[str, Any] | None = Field(default=None, description="Optional guardrail pipeline.")+ condition: dict[str, object] | None = Field(default=None, description="Policy condition.")+ pipeline: dict[str, object] | None = Field(default=None, description="Optional guardrail pipeline.")created_at: datetime | None = Field(default=None, description="When the policy was created.")updated_at: datetime | None = Field(default=None, description="When the policy was last updated.")created_by: str | None = Field(default=None, description="Who created the policy.")@@ -272,7 +272,7 @@ class PolicyVersionCompareResponse(LiteLLMBaseModel):version_a: PolicyDBResponse = Field(description="First version.")version_b: PolicyDBResponse = Field(description="Second version.")- field_diffs: dict[str, dict[str, Any]] = Field(+ field_diffs: dict[str, dict[str, object]] = Field(default_factory=dict,description="Field name -> {version_a: val, version_b: val} for differing fields.",)