Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Merge origin/litellm_internal_staging into litellm_python_version_ci

mateo-berri748075be4fc3
diff --cc basedpyright-code-budget.json
index 45dbb836552,3f96531cf6f..5add3d5539a
--- a/basedpyright-code-budget.json
+++ b/basedpyright-code-budget.json
@@@ -105,13 -105,13 +105,13 @@@
"limit": 109
},
"reportUnknownMemberType": {
- "limit": 38348
- "limit": 38332
++ "limit": 38330
},
"reportUnknownParameterType": {
- "limit": 19624
- "limit": 19625
++ "limit": 19623
},
"reportUnknownVariableType": {
- "limit": 29889
- "limit": 29861
++ "limit": 29860
},
"reportUnnecessaryCast": {
"limit": 111
diff --cc litellm/proxy/_experimental/mcp_server/tool_search.py
index f59c7c2f45f,4f6305d88cf..af02c11ad86
--- a/litellm/proxy/_experimental/mcp_server/tool_search.py
+++ b/litellm/proxy/_experimental/mcp_server/tool_search.py
@@@ -2,10 -2,13 +2,13 @@@ from __future__ import annotation
import json
from collections.abc import Mapping, Sequence
+ from dataclasses import dataclass
from datetime import datetime
+ from types import MappingProxyType
-from typing import TYPE_CHECKING, Any, Final, TypedDict, assert_never
+from typing import TYPE_CHECKING, Any, Final, TypedDict
+ from pydantic import ValidationError
-from typing_extensions import ReadOnly, Required
+from typing_extensions import ReadOnly, Required, assert_never
import litellm
from litellm.proxy.agent_endpoints.agent_search import DEFAULT_AGENT_SEARCH_TOP_K
diff --cc litellm/utils.py
index c894f441687,ba456fc353b..fa89c4db1a5
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@@ -5106,51 -5106,14 +5106,8 @@@ def get_response_string(response_obj: M
return "".join(response_parts)
- def get_api_key(llm_provider: str, dynamic_api_key: str | None):
- api_key = dynamic_api_key or litellm.api_key
- # openai
- if llm_provider == "openai" or llm_provider == "text-completion-openai":
- api_key = api_key or litellm.openai_key or get_secret("OPENAI_API_KEY")
- # anthropic
- elif llm_provider == "anthropic" or llm_provider == "anthropic_text":
- api_key = api_key or litellm.anthropic_key or get_secret("ANTHROPIC_API_KEY")
- # ai21
- elif llm_provider == "ai21":
- api_key = api_key or litellm.ai21_key or get_secret("AI21_API_KEY")
- # aleph_alpha
- elif llm_provider == "aleph_alpha":
- api_key = api_key or litellm.aleph_alpha_key or get_secret("ALEPH_ALPHA_API_KEY")
- # baseten
- elif llm_provider == "baseten":
- api_key = api_key or litellm.baseten_key or get_secret("BASETEN_API_KEY")
- # cohere
- elif llm_provider == "cohere" or llm_provider == "cohere_chat":
- api_key = api_key or litellm.cohere_key or get_secret("COHERE_API_KEY")
- # huggingface
- elif llm_provider == "huggingface":
- api_key = api_key or litellm.huggingface_key or get_secret("HUGGINGFACE_API_KEY")
- # nlp_cloud
- elif llm_provider == "nlp_cloud":
- api_key = api_key or litellm.nlp_cloud_key or get_secret("NLP_CLOUD_API_KEY")
- # replicate
- elif llm_provider == "replicate":
- api_key = api_key or litellm.replicate_key or get_secret("REPLICATE_API_KEY")
- # together_ai
- elif llm_provider == "together_ai":
- api_key = (
- api_key or litellm.togetherai_api_key or get_secret("TOGETHERAI_API_KEY") or get_secret("TOGETHER_AI_TOKEN")
- )
- # nebius
- elif llm_provider == "nebius":
- api_key = api_key or litellm.nebius_key or get_secret("NEBIUS_API_KEY")
- # wandb
- elif llm_provider == "wandb":
- api_key = api_key or litellm.wandb_key or get_secret("WANDB_API_KEY")
- return api_key
-
-def get_utc_datetime():
- import datetime as dt
- from datetime import datetime
--
- if hasattr(dt, "UTC"):
- return datetime.now(dt.UTC)
- else:
- return datetime.utcnow()
+def get_utc_datetime() -> datetime.datetime:
+ return datetime.datetime.now(datetime.timezone.utc)
def get_max_tokens(model: str) -> int | None:
diff --cc litellm/vector_stores/main.py
index 662b4981304,636bdd4b52e..13aa0434e34
--- a/litellm/vector_stores/main.py
+++ b/litellm/vector_stores/main.py
@@@ -38,8 -43,18 +43,18 @@@ base_llm_http_handler = BaseLLMHTTPHand
#################################################
+ def _direct_vector_store_embedding_executor(
+ value: object, router: "Router | None", request_kwargs: Mapping[str, object]
+ ) -> VectorStoreEmbeddingExecutor:
+ if value is not None and not isinstance(value, VectorStoreEmbeddingExecutor):
+ raise TypeError("Invalid direct vector store embedding executor")
+ return BaseQueryEmbeddingVectorStoreConfig.query_embedding_executor(
+ value, router, vector_store_request_metadata(request_kwargs)
+ )
+
+
def mock_vector_store_search_response(
- mock_results: list[VectorStoreSearchResult] | None = None,
+ mock_results: builtins.list[VectorStoreSearchResult] | None = None,
):
"""Mock response for vector store search"""
if mock_results is None:
diff --cc tests/test_litellm/router_strategy/test_complexity_router.py
index c25b7f92270,941d78085e4..5fc14ebe49e
--- a/tests/test_litellm/router_strategy/test_complexity_router.py
+++ b/tests/test_litellm/router_strategy/test_complexity_router.py
@@@ -47,11 -49,16 +50,21 @@@ from litellm.types.router import
)
+requires_semantic_router = pytest.mark.skipif(
+ sys.version_info >= (3, 14), reason="The semantic-router extra excludes Python 3.14"
+)
+
+
+ def _heuristic_v2_artifact() -> TrainedTierArtifact:
+ return TrainedTierArtifact(
+ global_statistics=tuple(
+ TierGlobalStatistic(tier=tier, successes=successes, observations=100)
+ for tier, successes in enumerate((10, 20, 90, 99), start=1)
+ ),
+ routing_threshold=0.8,
+ )
+
+
@pytest.fixture
def mock_router_instance():
"""Create a mock LiteLLM Router instance."""
diff --cc type-discipline-budget.json
index 5b43c0f6778,f3c4c7760c6..59659f3d6a1
--- a/type-discipline-budget.json
+++ b/type-discipline-budget.json
@@@ -27,12 -27,12 +27,12 @@@
"limit": 0
},
"LIT010": {
- "limit": 16507
+ "limit": 16480
},
"LIT011": {
- "limit": 5535
+ "limit": 5520
},
"LIT012": {
- "limit": 4494
- "limit": 4489
++ "limit": 4488
}
}