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
litellm_fix(mypy): fix remaining type errors (#20164)
shin-bot-litellm5434b66b9ca9
diff --git a/enterprise/litellm_enterprise/proxy/vector_stores/endpoints.py b/enterprise/litellm_enterprise/proxy/vector_stores/endpoints.pyindex 21933165217..5e799599862 100644--- a/enterprise/litellm_enterprise/proxy/vector_stores/endpoints.py+++ b/enterprise/litellm_enterprise/proxy/vector_stores/endpoints.py@@ -282,6 +282,8 @@ async def get_vector_store_info(updated_at=vector_store.get("updated_at") or None,litellm_credential_name=vector_store.get("litellm_credential_name"),litellm_params=vector_store.get("litellm_params") or None,+ team_id=vector_store.get("team_id"),+ user_id=vector_store.get("user_id"),)return {"vector_store": vector_store_pydantic_obj}diff --git a/litellm/llms/gemini/files/transformation.py b/litellm/llms/gemini/files/transformation.pyindex ab2b770cc3a..deb3eeb2481 100644--- a/litellm/llms/gemini/files/transformation.py+++ b/litellm/llms/gemini/files/transformation.py@@ -4,7 +4,7 @@ Supports writing files to Google AI Studio Files API.For vertex ai, check out the vertex_ai/files/handler.py file."""import time-from typing import List, Optional+from typing import Any, List, Optionalimport httpxfrom openai.types.file_deleted import FileDeleted@@ -17,6 +17,7 @@ from litellm.llms.base_llm.files.transformation import ()from litellm.types.llms.gemini import GeminiCreateFilesResponseObjectfrom litellm.types.llms.openai import (+ AllMessageValues,CreateFileRequest,HttpxBinaryResponseContent,OpenAICreateFileRequestOptionalParams,@@ -37,22 +38,23 @@ class GoogleAIStudioFilesHandler(GeminiModelInfo, BaseFilesConfig):def validate_environment(self,- api_key: Optional[str],- headers: dict,+ headers: dict[Any, Any],model: str,- messages: list,- optional_params: dict,- litellm_params: dict,- ) -> dict:+ messages: List[AllMessageValues],+ optional_params: dict[Any, Any],+ litellm_params: dict[Any, Any],+ api_key: Optional[str] = None,+ api_base: Optional[str] = None,+ ) -> dict[Any, Any]:"""Validate environment and add Gemini API key to headers.Google AI Studio uses x-goog-api-key header for authentication."""- api_key = self.get_api_key(api_key)- if not api_key:+ resolved_api_key = self.get_api_key(api_key)+ if not resolved_api_key:raise ValueError("GEMINI_API_KEY is required for Google AI Studio file operations")- headers["x-goog-api-key"] = api_key+ headers["x-goog-api-key"] = resolved_api_keyreturn headersdef get_complete_url(diff --git a/litellm/proxy/route_llm_request.py b/litellm/proxy/route_llm_request.pyindex af441ee43e4..c6a93164d49 100644--- a/litellm/proxy/route_llm_request.py+++ b/litellm/proxy/route_llm_request.py@@ -160,6 +160,8 @@ async def route_request("aget_interaction","adelete_interaction","acancel_interaction",+ "acancel_batch",+ "afile_delete",],):"""diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.pyindex 41abbca755c..74cc87713da 100644--- a/litellm/responses/litellm_completion_transformation/transformation.py+++ b/litellm/responses/litellm_completion_transformation/transformation.py@@ -1743,7 +1743,7 @@ class LiteLLMCompletionResponsesConfig:and usage.prompt_tokens_details is not None):prompt_details = usage.prompt_tokens_details- input_details_dict: Dict[str, Optional[int]] = {}+ input_details_dict: Dict[str, int] = {}if (hasattr(prompt_details, "cached_tokens")@@ -1776,7 +1776,7 @@ class LiteLLMCompletionResponsesConfig:and usage.completion_tokens_details is not None):completion_details = usage.completion_tokens_details- output_details_dict: Dict[str, Optional[int]] = {}+ output_details_dict: Dict[str, int] = {}if (hasattr(completion_details, "reasoning_tokens")and completion_details.reasoning_tokens is not Nonediff --git a/litellm/types/router.py b/litellm/types/router.pyindex 43943d9e07e..f31c6df3005 100644--- a/litellm/types/router.py+++ b/litellm/types/router.py@@ -623,7 +623,13 @@ class SearchToolLiteLLMParams(TypedDict, total=False):max_retries: Optional[int]-class SearchToolTypedDict(TypedDict):+class SearchToolInfoTypedDict(TypedDict, total=False):+ """Optional metadata about a search tool."""++ description: str+++class SearchToolTypedDict(TypedDict, total=False):"""Configuration for a search tool in the router.@@ -639,6 +645,7 @@ class SearchToolTypedDict(TypedDict):search_tool_name: Required[str]litellm_params: Required[SearchToolLiteLLMParams]+ search_tool_info: SearchToolInfoTypedDictclass GuardrailLiteLLMParams(TypedDict, total=False):