refactor(types): replace Any with proven types in 50 files (#47818)

* refactor(types): replace Any with proven types in 100 files

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(types): keep untyped parsing where strict validation changed accepted shapes

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(types): keep the OpenAI-compatible response parse untyped

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(types): keep only annotation changes, drop new runtime validation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Mateo Wang 2026-10-21 11:58:31 +00:00 • committed by GitHub
parent a31c5230de
commit 9d8fe1ddb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 120 additions and 124 deletions

View file

@ -1,6 +1,6 @@
# Duplicate -> https://github.com/confident-ai/deepeval/blob/main/deepeval/tracing/api.py
from enum import Enum
from typing import Any, ClassVar, Literal
from typing import ClassVar, Literal
from pydantic import ConfigDict, Field
@ -55,7 +55,7 @@ class TraceApi(LiteLLMBaseModel):
tool_spans: list[BaseApiSpan] = Field(alias="toolSpans")
start_time: str = Field(alias="startTime")
end_time: str = Field(alias="endTime")
metadata: dict[str, Any] | None = Field(None)
metadata: dict[str, object] | None = Field(None)
tags: list[str] | None = Field(None)
environment: str | None = Field(None)

View file

@ -3,8 +3,8 @@ Streaming iterator for transforming Responses API stream to Interactions API str
"""
from collections import deque
from collections.abc import AsyncIterator, Iterator
from typing import Any, Final, cast
from collections.abc import AsyncIterator, Iterator, Mapping
from typing import Final, cast
from litellm.responses.streaming_iterator import (
BaseResponsesAPIStreamingIterator,
@ -44,7 +44,7 @@ class LiteLLMResponsesInteractionsStreamingIterator:
request_input: InteractionInput | None,
optional_params: InteractionsAPIOptionalRequestParams,
custom_llm_provider: str | None = None,
litellm_metadata: dict[str, Any] | None = None,
litellm_metadata: Mapping[str, object] | None = None,
):
self.model = model
self.responses_stream_iterator = litellm_custom_stream_wrapper

View file

@ -4,7 +4,7 @@ Base OCR types shared by the Rust OCR route and Python consumers.
import builtins
from collections.abc import Mapping
from typing import Any, Final, Literal
from typing import Final, Literal
from pydantic import PrivateAttr
@ -45,7 +45,7 @@ class OCRPageImage(LiteLLMPydanticObjectBase):
"""Image extracted from OCR page."""
image_base64: str | None = None
bbox: dict[str, Any] | None = None
bbox: dict[str, builtins.object] | None = None
model_config = {"extra": "allow"}
@ -80,7 +80,7 @@ class OCRResponse(LiteLLMPydanticObjectBase):
pages: list[OCRPage]
model: str
document_annotation: Any | None = None
document_annotation: builtins.object | None = None
usage_info: OCRUsageInfo | None = None
content: str | None = None
tables: list[dict[str, builtins.object]] | None = None

View file

@ -7,7 +7,7 @@ run code -> delete container; `code_interpreter_tool` combines all three.
"""
import builtins
from typing import Any, Final
from typing import Final
import httpx
from pydantic import Field, PrivateAttr
@ -42,8 +42,8 @@ class CodeExecutionResult(LiteLLMPydanticObjectBase):
stdout: str = ""
stderr: str = ""
results: list[dict[str, Any]] = Field(default_factory=list)
error: dict[str, Any] | None = None
results: list[dict[str, object]] = Field(default_factory=list)
error: dict[str, object] | None = None
execution_count: int | None = None
object: str = "code_execution"

View file

@ -202,7 +202,9 @@ class GithubCopilotEmbeddingConfig(BaseEmbeddingConfig):
optional_params[param] = value
return optional_params
def get_error_class(self, error_message: str, status_code: int, headers: Any) -> BaseLLMException:
def get_error_class(
self, error_message: str, status_code: int, headers: dict[str, str] | httpx.Headers
) -> BaseLLMException:
from litellm.llms.openai.openai import OpenAIConfig
return OpenAIConfig().get_error_class(error_message=error_message, status_code=status_code, headers=headers)

View file

@ -87,7 +87,7 @@ async def ollama_aembeddings(
model: str,
prompts: list[str],
model_response: EmbeddingResponse,
optional_params: dict,
optional_params: Mapping[str, object],
logging_obj: object,
encoding: TokenEncoder | None,
):
@ -110,7 +110,7 @@ def ollama_embeddings(
api_base: str,
model: str,
prompts: list[str],
optional_params: dict,
optional_params: Mapping[str, object],
model_response: EmbeddingResponse,
logging_obj: object,
encoding: TokenEncoder | None = None,

View file

@ -6,7 +6,7 @@ Canonical definitions for the ``litellm_managed*`` tables. Re-exported from
"""
from datetime import datetime
from typing import Any, Literal
from typing import Literal
from litellm.types.llms.base import LiteLLMPydanticObjectBase
from litellm.types.llms.openai import OpenAIFileObject, ResponsesAPIResponse
@ -39,7 +39,7 @@ class LiteLLM_ManagedVectorStoreTable(LiteLLMPydanticObjectBase):
"""Table for managing vector stores with target_model_names support."""
unified_resource_id: str
resource_object: Any | None = None
resource_object: object | None = None
model_mappings: dict[str, str]
flat_model_resource_ids: list[str]
created_by: str | None = None
@ -54,11 +54,11 @@ class LiteLLM_ManagedVectorStoresTable(LiteLLMPydanticObjectBase):
custom_llm_provider: str
vector_store_name: str | None = None
vector_store_description: str | None = None
vector_store_metadata: dict[str, Any] | None = None
vector_store_metadata: dict[str, object] | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
litellm_credential_name: str | None = None
litellm_params: dict[str, Any] | None = None
litellm_params: dict[str, object] | None = None
team_id: str | None = None
user_id: str | None = None
is_config: bool = False

View file

@ -9,7 +9,7 @@ admin pick which ones to expose through the proxy. The actual merge into a
LiteLLM-fronted card happens when the agent is saved via ``POST /v1/agents``.
"""
from typing import Any, Final
from typing import Final
from fastapi import APIRouter, Depends, HTTPException
from fastapi.responses import JSONResponse
@ -50,7 +50,7 @@ class DiscoverAgentRequest(LiteLLMBaseModel):
"query parameter."
),
)
params: dict[str, Any] | None = Field(
params: dict[str, object] | None = Field(
default=None,
description=(
"Mode-specific parameters. ``langgraph_platform`` requires "
@ -61,7 +61,7 @@ class DiscoverAgentRequest(LiteLLMBaseModel):
class DiscoverAgentResponse(LiteLLMBaseModel):
url: str
agent_card: dict[str, Any]
agent_card: dict[str, object]
@router.post(

View file

@ -41,7 +41,7 @@ DB_UNAVAILABLE_FALLBACK_USER_ID: Final = "__db_unavailable_fallback__"
if TYPE_CHECKING:
from opentelemetry.trace import Span as _Span
Span = _Span | Any
Span = _Span
else:
Span = Any

View file

@ -5,7 +5,7 @@ Might include fastapi/proxy requirements.txt related imports
"""
from collections.abc import Iterable, Sequence
from typing import Any, Final, cast
from typing import Final, cast
from fastapi_sso.sso.base import OpenID
@ -94,4 +94,4 @@ def get_litellm_user_role(role_str: object) -> LitellmUserRoles | None:
class CustomOpenID(OpenID):
team_ids: list[str]
user_role: LitellmUserRoles | None = None
extra_fields: dict[str, Any] | None = None
extra_fields: dict[str, object] | None = None

View file

@ -122,7 +122,9 @@ async def _get_vantage_settings():
encrypted_api_key: Final = settings.get("api_key")
if encrypted_api_key:
decrypted_api_key = decrypt_value_helper(encrypted_api_key, key="vantage_api_key", exception_type="error")
decrypted_api_key: Final = decrypt_value_helper(
encrypted_api_key, key="vantage_api_key", exception_type="error"
)
if decrypted_api_key is None:
raise HTTPException(
status_code=500,

View file

@ -128,7 +128,7 @@ def _custom_loggers(callbacks: Iterable[object]) -> tuple[CustomLogger, ...]:
def overridden(method: str, callbacks: Iterable[object]) -> bool:
base: Final = getattr(CustomLogger, method)
base: Final[object] = getattr(CustomLogger, method)
return any(getattr(type(callback), method, base) is not base for callback in _custom_loggers(callbacks))

View file

@ -75,7 +75,7 @@ class RedisPipelineSetOperation(TypedDict):
"""
key: str
value: Any
value: object
ttl: int | None
@ -133,7 +133,7 @@ class HealthCheckCacheParams(LiteLLMBaseModel):
host: str | None = None
port: str | int | None = None
redis_kwargs: dict[str, Any] | None = None
redis_kwargs: dict[str, object] | None = None
namespace: str | None = None
redis_version: str | int | float | None = None

View file

@ -246,7 +246,7 @@ _CompletionDispatchContext = CompletionDispatchContext
_CompletionDispatchResult = Union[
Coroutine[Any, Any, Union["ModelResponse", "CustomStreamWrapper"]],
Coroutine[object, object, Union["ModelResponse", "CustomStreamWrapper"]],
"ModelResponse",
"CustomStreamWrapper",
]

View file

@ -13,6 +13,7 @@ from pydantic import (
model_validator,
with_config,
)
from pydantic.fields import FieldInfo
from typing_extensions import ReadOnly, Required, Self, TypedDict
from litellm.types.llms.base import LiteLLMPydanticObjectBase
@ -30,7 +31,7 @@ def _is_none(value: object) -> bool:
return value is None
_OMITTED_WHEN_NONE: Final = Field(exclude_if=_is_none)
_OMITTED_WHEN_NONE: Final = FieldInfo.from_field(exclude_if=_is_none)
OptionalJson: TypeAlias = Annotated[JsonValue, _OMITTED_WHEN_NONE]
OptionalFloat: TypeAlias = Annotated[float | None, _OMITTED_WHEN_NONE]
OptionalInt: TypeAlias = Annotated[int | None, _OMITTED_WHEN_NONE]

View file

@ -17,7 +17,7 @@ if TYPE_CHECKING:
ToolConfigDict = _genai_types.ToolConfigDict
class GenerateContentRequestDict(GenerateContentRequestParametersDict):
generationConfig: Any | None
generationConfig: object | None
tools: ToolConfigDict | None
class GenerateContentResponse(GoogleGenAIGenerateContentResponse, BaseLiteLLMOpenAIResponseObject):

View file

@ -1,4 +1,4 @@
from typing import Any, Literal
from typing import Literal
from typing_extensions import TypedDict
@ -20,7 +20,7 @@ class ImageEditOptionalRequestParams(TypedDict, total=False):
response_format: Literal["url", "b64_json"] | None
size: str | None
user: str | None
imageConfig: dict[str, Any] | None
imageConfig: dict[str, object] | None
class ImageEditRequestParams(ImageEditOptionalRequestParams, total=False):

View file

@ -1,10 +1,10 @@
from typing import Any, Final
from typing import Final
from typing_extensions import TypedDict
class ArgillaItem(TypedDict):
fields: dict[str, Any]
fields: dict[str, object]
class ArgillaPayload(TypedDict):

View file

@ -1,7 +1,4 @@
from typing import Any
class CBFRecord(dict[str, Any]):
class CBFRecord(dict[str, object]):
"""CloudZero Billing Format (CBF) record structure.
This class represents a CBF record that is created from LiteLLM usage data
@ -31,4 +28,4 @@ class CBFRecord(dict[str, Any]):
# Type alias for better readability in function signatures
CBFRecordDict = dict[str, Any]
CBFRecordDict = dict[str, object]

View file

@ -2,7 +2,7 @@
Type definitions for Compression Interception integration.
"""
from typing import Any, Literal, TypedDict
from typing import Literal, TypedDict
class CompressionInterceptionConfig(TypedDict, total=False):
@ -24,7 +24,7 @@ class CompressionInterceptionConfig(TypedDict, total=False):
compression_trigger: int
compression_target: int | None
embedding_model: str | None
embedding_model_params: dict[str, Any] | None
embedding_model_params: dict[str, object] | None
class CompressionSavingsMetadata(TypedDict):

View file

@ -31,5 +31,5 @@ class GCSLogQueueItem(TypedDict):
"""
payload: StandardLoggingPayload
kwargs: dict[str, Any]
response_obj: Any | None
kwargs: dict[str, object]
response_obj: object | None

View file

@ -1,6 +1,6 @@
from dataclasses import dataclass
from datetime import datetime
from typing import Any, NamedTuple
from typing import NamedTuple
from typing_extensions import TypedDict
@ -9,7 +9,7 @@ from litellm.types.llms.base import LiteLLMBaseModel
class LangsmithInputs(LiteLLMBaseModel):
model: str | None = None
messages: list[Any] | None = None
messages: list[object] | None = None
stream: bool | None = None
call_type: str | None = None
litellm_call_id: str | None = None
@ -17,9 +17,9 @@ class LangsmithInputs(LiteLLMBaseModel):
temperature: float | None = None
max_tokens: int | None = None
custom_llm_provider: str | None = None
input: list[Any] | None = None
input: list[object] | None = None
log_event_type: str | None = None
original_response: Any | None = None
original_response: object | None = None
response_cost: float | None = None
# LiteLLM Virtual Key specific fields

View file

@ -1,4 +1,4 @@
from typing import Any, Final, TypedDict
from typing import Final, TypedDict
POSTHOG_MAX_BATCH_SIZE: Final = 100
@ -7,7 +7,7 @@ class PostHogEventPayload(TypedDict):
"""PostHog event payload structure"""
event: str # "$ai_generation" or "$ai_embedding"
properties: dict[str, Any]
properties: dict[str, object]
distinct_id: str

View file

@ -1,5 +1,5 @@
from collections.abc import Sequence
from typing import Any, Literal, TypeAlias
from typing import Literal, TypeAlias
from typing_extensions import NotRequired, ReadOnly, TypedDict
@ -20,7 +20,7 @@ class AnthropicResponseTextBlock(TypedDict, total=False):
Anthropic Response Text Block: https://docs.anthropic.com/en/api/messages
"""
citations: list[dict[str, Any]] | None
citations: list[dict[str, object]] | None
text: str
type: Literal["text"]

View file

@ -1,4 +1,4 @@
from typing import Any, Final
from typing import Final
from openai._models import BaseModel as OpenAIObject
from pydantic import ConfigDict
@ -45,7 +45,7 @@ class BaseLiteLLMOpenAIResponseObject(LiteLLMBaseModel):
class HiddenParams(OpenAIObject):
original_response: str | Any | None = None
original_response: str | object | None = None
model_id: str | None = None # used in Router for individual deployments
api_base: str | None = None # returns api base used for making completion call
_response_ms: float | None = None

View file

@ -1,4 +1,4 @@
from typing import Any, Literal
from typing import Literal
from pydantic import BaseModel
from typing_extensions import (
@ -23,7 +23,7 @@ class GenericStreamingChunk(TypedDict, total=False):
class DatabricksTextContent(TypedDict, total=False):
type: Literal["text"]
text: Required[str]
citations: list[dict[str, Any]] | None
citations: list[dict[str, object]] | None
class DatabricksReasoningSummary(TypedDict):
@ -35,7 +35,7 @@ class DatabricksReasoningSummary(TypedDict):
class DatabricksReasoningContent(TypedDict, total=False):
type: Literal["reasoning"]
summary: Required[list[DatabricksReasoningSummary]]
citations: list[dict[str, Any]] | None
citations: list[dict[str, object]] | None
AllDatabricksContentListValues = DatabricksTextContent | DatabricksReasoningContent

View file

@ -2,7 +2,7 @@
Types and field definitions for cache settings management endpoints
"""
from typing import Any, Final
from typing import Final
from litellm.types.llms.base import LiteLLMBaseModel
@ -10,9 +10,9 @@ from litellm.types.llms.base import LiteLLMBaseModel
class CacheSettingsField(LiteLLMBaseModel):
field_name: str
field_type: str
field_value: Any
field_value: object
field_description: str
field_default: Any = None
field_default: object = None
options: list[str] | None = None # For fields with predefined options/enum values
ui_field_name: str # User-friendly display name
link: str | None = None # Documentation link for the field

View file

@ -2,7 +2,7 @@
Types and field definitions for router settings management endpoints
"""
from typing import Any, Final, Literal
from typing import Final, Literal
from pydantic import Field, field_validator
@ -72,9 +72,9 @@ class FallbackDeleteResponse(LiteLLMBaseModel):
class RouterSettingsField(LiteLLMBaseModel):
field_name: str
field_type: str
field_value: Any
field_value: object
field_description: str
field_default: Any = None
field_default: object = None
options: list[str] | None = None # For fields with predefined options/enum values
ui_field_name: str # User-friendly display name
link: str | None = None # Documentation link for the field

View file

@ -113,7 +113,7 @@ class MCPPublicServer(LiteLLMBaseModel):
transport: MCPTransportType
spec_path: str | None = None
auth_type: MCPAuthType | None = None
mcp_info: dict[str, Any] | None = None
mcp_info: dict[str, object] | None = None
class MCPAllowedClient(LiteLLMBaseModel):
@ -448,11 +448,11 @@ class MCPPreCallRequestObject(LiteLLMBaseModel):
"""
tool_name: str
arguments: dict[str, Any]
arguments: dict[str, object]
server_name: str | None = None
tool_description: str | None = None
tool_input_schema: Mapping[str, object] | None = None
user_api_key_auth: dict[str, Any] | None = None
user_api_key_auth: dict[str, object] | None = None
hidden_params: HiddenParams = HiddenParams()
@ -462,7 +462,7 @@ class MCPPreCallResponseObject(LiteLLMBaseModel):
"""
should_proceed: bool = True
modified_arguments: dict[str, Any] | None = None
modified_arguments: dict[str, object] | None = None
error_message: str | None = None
hidden_params: HiddenParams = HiddenParams()
@ -473,7 +473,7 @@ class MCPDuringCallRequestObject(LiteLLMBaseModel):
"""
tool_name: str
arguments: dict[str, Any]
arguments: dict[str, object]
server_name: str | None = None
tool_description: str | None = None
tool_input_schema: Mapping[str, object] | None = None

View file

@ -117,7 +117,7 @@ class MCPServer(LiteLLMBaseModel):
# Admin-configured env vars. Each entry is {name, value, scope, description}.
# scope=="global" values are interpolated into static_headers using ${NAME}.
# scope=="user" values must be supplied per-user.
env_vars: list[dict[str, Any]] | None = None
env_vars: list[dict[str, object]] | None = None
# OAuth-specific fields
authorization_server_metadata: Mapping[str, object] | None = Field(default=None, exclude=True)
client_id: str | None = None
@ -240,7 +240,7 @@ class MCPServer(LiteLLMBaseModel):
# token_validation: key-value pairs that must match fields in the OAuth token
# response (supports dot-notation for nested fields, e.g. "team.enterprise_id").
# Tokens that fail validation are rejected before storage.
token_validation: dict[str, Any] | None = None
token_validation: dict[str, object] | None = None
oauth_identity_binding: MCPOAuthIdentityBinding | None = None
# Optional TTL override (seconds) for the Redis per-user token cache, capped
# at the token's expires_in minus the expiry buffer so a cached entry never

View file

@ -1,6 +1,6 @@
from datetime import datetime
from enum import Enum
from typing import Any, Literal
from typing import Literal
from pydantic import ConfigDict
@ -31,7 +31,7 @@ class PromptLiteLLMParams(LiteLLMBaseModel):
api_base: str | None = None
api_key: str | None = None
provider_specific_query_params: dict[str, Any] | None = None
provider_specific_query_params: dict[str, object] | None = None
ignore_prompt_manager_model: bool | None = False
ignore_prompt_manager_optional_params: bool | None = False
@ -66,7 +66,7 @@ class PromptSpec(LiteLLMBaseModel):
class PromptTemplateBase(LiteLLMBaseModel):
litellm_prompt_id: str
content: str
metadata: dict[str, Any] | None = None
metadata: dict[str, object] | None = None
class PromptInfoResponse(LiteLLMBaseModel):

View file

@ -5,7 +5,7 @@ External producers (e.g. the litellm-rust gateway) POST finished logging
payloads here; the proxy replays them through the standard callback fan-out.
"""
from typing import Any, Literal
from typing import Literal
from pydantic import Field
@ -17,7 +17,7 @@ class CallbackLogRecord(LiteLLMBaseModel):
"""A single finished logging event to replay through the callbacks."""
status: Literal["success", "failure"]
standard_logging_payload: dict[str, Any]
standard_logging_payload: dict[str, object]
error: str | None = None

View file

@ -46,7 +46,7 @@ class CloudZeroExportResponse(LiteLLMBaseModel):
dry_run_data: dict[str, Any] | None = Field(
None, description="Dry run data including usage data and CBF transformed data"
)
summary: dict[str, Any] | None = Field(None, description="Summary statistics for dry run")
summary: dict[str, object] | None = Field(None, description="Summary statistics for dry run")
class CloudZeroSettingsView(LiteLLMBaseModel):

View file

@ -1,5 +1,3 @@
from typing import Any
from pydantic import Field
from typing_extensions import TypedDict
@ -23,7 +21,7 @@ class AzurePromptShieldGuardrailResponse(TypedDict):
"""Configuration parameters for the Azure Prompt Shield guardrail"""
userPromptAnalysis: UserPromptAnalysis
documentsAnalysis: list[dict[str, Any]]
documentsAnalysis: list[dict[str, object]]
class AzurePromptShieldGuardrailConfigModel(

View file

@ -1,4 +1,4 @@
from typing import Any, Final, Literal
from typing import Final, Literal
from pydantic import Field
from typing_extensions import Required, TypedDict
@ -37,7 +37,7 @@ class AzureTextModerationGuardrailResponseCategoriesAnalysis(TypedDict):
class AzureTextModerationGuardrailResponse(TypedDict):
"""Response from the Azure Text Moderation guardrail"""
blocklistsMatch: list[dict[str, Any]]
blocklistsMatch: list[dict[str, object]]
categoriesAnalysis: list[AzureTextModerationGuardrailResponseCategoriesAnalysis]

View file

@ -1,4 +1,4 @@
from typing import Any, Literal
from typing import Literal
from pydantic import Field
@ -93,7 +93,7 @@ class CompresrGuardrailOptionalParams(LiteLLMBaseModel):
"Unset lets the server default apply (~10.0)."
),
)
compression_params: dict[str, Any] | None = Field(
compression_params: dict[str, object] | None = Field(
default=None,
description=(
"Passthrough of extra parameters forwarded verbatim in the Compresr "

View file

@ -1,5 +1,5 @@
from enum import Enum
from typing import Any, Literal, TypedDict
from typing import Literal, TypedDict
from pydantic import Field
@ -77,7 +77,7 @@ class CompetitorIntentDetection(TypedDict):
action_hint: str
entities: dict[str, list[str]]
signals: list[str]
evidence: list[dict[str, Any]]
evidence: list[dict[str, object]]
ContentFilterDetection = PatternDetection | BlockedWordDetection | CategoryKeywordDetection | CompetitorIntentDetection
@ -157,7 +157,7 @@ class LitellmContentFilterGuardrailConfigModel(GuardrailConfigModel):
)
# Competitor intent blocker (generic; industry presets add domain_words, etc.)
competitor_intent_config: dict[str, Any] | None = Field(
competitor_intent_config: dict[str, object] | None = Field(
default=None,
description="Optional config for intent-based competitor comparison detection. "
"Keys: brand_self (list), competitors (list), competitor_aliases (dict), "

View file

@ -1,6 +1,6 @@
from typing import Any
from collections.abc import Mapping
from typing_extensions import TypedDict
from typing_extensions import ReadOnly, TypedDict
from litellm.types.guardrails import PiiEntityType
@ -17,5 +17,5 @@ class PresidioAnalyzeResponseItem(TypedDict, total=False):
start: int | None
end: int | None
score: float | None
analysis_explanation: dict[str, Any] | None
recognition_metadata: dict[str, Any] | None
analysis_explanation: ReadOnly[Mapping[str, object] | None]
recognition_metadata: ReadOnly[Mapping[str, object] | None]

View file

@ -1,7 +1,6 @@
from collections.abc import Sequence
from collections.abc import Mapping, Sequence
from datetime import date
from enum import Enum
from typing import Any
from pydantic import ConfigDict, Field
from typing_extensions import TypedDict
@ -61,7 +60,7 @@ class KeyMetricWithMetadata(MetricBase):
class MetricWithMetadata(MetricBase):
metadata: dict[str, Any] = Field(default_factory=dict)
metadata: Mapping[str, object] = Field(default_factory=dict)
# API key breakdown for this metric (e.g., which API keys are using this MCP server)
api_key_breakdown: dict[str, KeyMetricWithMetadata] = Field(default_factory=dict) # api_key -> {metrics, metadata}

View file

@ -1,5 +1,3 @@
from typing import Any
from pydantic import Field
from litellm.types.llms.base import LiteLLMBaseModel
@ -103,5 +101,5 @@ class ConfigOverrideSettingsResponse(LiteLLMBaseModel):
"""Response model for config override settings GET endpoints."""
config_type: str = Field(description="The type of config override")
values: dict[str, Any] = Field(description="Current configuration values (sensitive fields decrypted)")
field_schema: dict[str, Any] = Field(description="Schema information for UI rendering")
values: dict[str, object] = Field(description="Current configuration values (sensitive fields decrypted)")
field_schema: dict[str, object] = Field(description="Schema information for UI rendering")

View file

@ -1,5 +1,5 @@
from collections.abc import Mapping, Sequence
from typing import Any, Final, Literal
from typing import Final, Literal
from pydantic import ConfigDict, Field, field_validator
from typing_extensions import ReadOnly, TypedDict
@ -80,7 +80,7 @@ class UserUpdateResult(LiteLLMBaseModel):
user_email: str | None = None
success: bool
error: str | None = None
updated_user: dict[str, Any] | None = None
updated_user: dict[str, object] | None = None
class BulkUpdateUserResponse(LiteLLMBaseModel):

View file

@ -1,6 +1,5 @@
from collections.abc import Mapping
from datetime import datetime
from typing import Any
from pydantic import ConfigDict, Field
@ -22,7 +21,7 @@ class UpdateUsefulLinksRequest(LiteLLMBaseModel):
# Supports both old format (Dict[str, str]) and new format (Dict[str, Dict[str, Any]])
# New format: { "displayName": { "url": "...", "index": 0 } }
# Old format: { "displayName": "url" } (for backward compatibility)
useful_links: dict[str, str | dict[str, Any]]
useful_links: dict[str, str | dict[str, object]]
class AutoRouterClassifierDefaultPromptResponse(LiteLLMBaseModel):

View file

@ -1,5 +1,5 @@
from collections.abc import Mapping
from typing import Any, Final, Literal
from typing import Final, Literal
from pydantic import ConfigDict, Field, field_validator, model_validator
@ -121,8 +121,8 @@ class TeamMemberAddResult(LiteLLMBaseModel):
user_email: str | None = None
success: bool
error: str | None = None
updated_user: dict[str, Any] | None = None
updated_team_membership: dict[str, Any] | None = None
updated_user: dict[str, object] | None = None
updated_team_membership: dict[str, object] | None = None
class BulkTeamMemberAddResponse(LiteLLMBaseModel):
@ -133,7 +133,7 @@ class BulkTeamMemberAddResponse(LiteLLMBaseModel):
total_requested: int
successful_additions: int
failed_additions: int
updated_team: dict[str, Any] | None = None
updated_team: dict[str, object] | None = None
class TeamMemberRef(MemberDeleteRequest):

View file

@ -1,9 +1,7 @@
from typing import Any
from litellm.types.llms.base import LiteLLMBaseModel
class TestPromptRequest(LiteLLMBaseModel):
dotprompt_content: str
prompt_variables: dict[str, Any] | None = None
prompt_variables: dict[str, object] | None = None
conversation_history: list[dict[str, str]] | None = None

View file

@ -1,5 +1,5 @@
from collections.abc import Mapping, Sequence
from typing import Any, Literal
from typing import Literal
from pydantic import ConfigDict
@ -13,7 +13,7 @@ class PublicModelHubInfo(LiteLLMBaseModel):
# Supports both old format (Dict[str, str]) and new format (Dict[str, Dict[str, Any]])
# New format: { "displayName": { "url": "...", "index": 0 } }
# Old format: { "displayName": "url" } (for backward compatibility)
useful_links: dict[str, str | dict[str, Any]] | None
useful_links: dict[str, str | dict[str, object]] | None
class ProviderCredentialField(LiteLLMBaseModel):

View file

@ -2,8 +2,8 @@
Vantage endpoint types for LiteLLM Proxy
"""
from collections.abc import Mapping
from datetime import datetime
from typing import Any
from pydantic import Field, field_validator
@ -57,10 +57,10 @@ class VantageExportResponse(LiteLLMBaseModel):
message: str
status: str
dry_run_data: dict[str, Any] | None = Field(
dry_run_data: Mapping[str, object] | None = Field(
None, description="Dry run data including usage data and FOCUS transformed data"
)
summary: dict[str, Any] | None = Field(None, description="Summary statistics for dry run")
summary: Mapping[str, object] | None = Field(None, description="Summary statistics for dry run")
class VantageSettingsView(LiteLLMBaseModel):

View file

@ -3,7 +3,7 @@ Type definitions for RAG (Retrieval Augmented Generation) Ingest API.
"""
from collections.abc import Mapping
from typing import Any, Literal
from typing import Literal
from pydantic import ConfigDict
from typing_extensions import ReadOnly, TypedDict
@ -232,7 +232,7 @@ class RAGIngestRequest(LiteLLMBaseModel):
file_url: str | None = None # URL to fetch file from
file_id: str | None = None # Existing file ID
ingest_options: dict[str, Any] # RAGIngestOptions as dict for flexibility
ingest_options: dict[str, object] # RAGIngestOptions as dict for flexibility
model_config = ConfigDict(extra="allow") # Allow additional fields
@ -260,7 +260,7 @@ class RAGQueryRequest(LiteLLMBaseModel):
"""Request body for RAG query API."""
model: str
messages: list[Any]
messages: list[object]
retrieval_config: RAGRetrievalConfig
rerank: RAGRerankConfig | None = None
stream: bool | None = False

View file

@ -5,7 +5,7 @@ from typing import Final, Literal, Optional, Union
from openai.types.responses.response_function_tool_call import ResponseFunctionToolCall
from openai.types.responses.response_function_web_search import ActionSearchSource, ResponseFunctionWebSearch
from pydantic import ConfigDict, PrivateAttr
from typing_extensions import Any, TypedDict
from typing_extensions import TypedDict
from litellm.types.llms.base import BaseLiteLLMOpenAIResponseObject
@ -100,7 +100,7 @@ class OutputCodeInterpreterCall(BaseLiteLLMOpenAIResponseObject):
def build_code_interpreter_log_outputs(
content: Any,
content: object,
) -> list[OutputCodeInterpreterCallLog] | None:
"""Convert Anthropic bash_code_execution stdout/stderr to log outputs.

View file

@ -1,7 +1,9 @@
import builtins
from collections.abc import Mapping
from enum import Enum
from typing import Any, Literal
from typing import Literal
from typing_extensions import TypedDict
from typing_extensions import ReadOnly, TypedDict
class VectorStoreFileStatus(str, Enum):
@ -33,7 +35,7 @@ class VectorStoreFileObject(TypedDict, total=False):
usage_bytes: int | None
vector_store_id: str
status: VectorStoreFileStatus
last_error: dict[str, Any] | None
last_error: ReadOnly[Mapping[str, builtins.object] | None]
chunking_strategy: VectorStoreFileChunkingStrategy | None
attributes: dict[str, str | int | float | bool] | None
@ -83,5 +85,5 @@ class VectorStoreFileContentResponse(TypedDict, total=False):
class VectorStoreFileAuthCredentials(TypedDict, total=False):
headers: dict[str, Any]
query_params: dict[str, Any]
headers: ReadOnly[Mapping[str, object]]
query_params: ReadOnly[Mapping[str, object]]

View file

@ -31,7 +31,7 @@ class LiteLLM_ManagedVectorStore(TypedDict, total=False):
vector_store_name: str | None
vector_store_description: str | None
vector_store_metadata: dict[str, Any] | str | None
vector_store_metadata: dict[str, object] | str | None
created_at: datetime | None
updated_at: datetime | None