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
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_/mongodb-vector-store-e4ff63
Yuneng Jiang431579dc1636
diff --cc .github/workflows/_test-unit-base.ymlindex 80d743c5ad7,d2cc0aa6d8d..6f6822a975b--- a/.github/workflows/_test-unit-base.yml+++ b/.github/workflows/_test-unit-base.yml@@@ -112,7 -116,8 +116,8 @@@ jobsif: steps.changes.outputs.decision != 'skip'timeout-minutes: 8run: |- .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra saml+ .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra saml --extra mongodb+ uv run --no-sync python -c 'import os, sys; print(sys.version); assert f"{sys.version_info.major}.{sys.version_info.minor}" == os.environ["UV_PYTHON"]'- name: Cache Prisma binariesif: steps.changes.outputs.decision != 'skip'diff --cc litellm/litellm_core_utils/sensitive_data_masker.pyindex fcce63e016b,15b2c879224..22dd4170963--- a/litellm/litellm_core_utils/sensitive_data_masker.py+++ b/litellm/litellm_core_utils/sensitive_data_masker.py@@@ -1,31 -1,11 +1,32 @@@- from collections.abc import Mapping+ from collections.abc import Mapping, Sequence+from collections.abc import Set as AbstractSetfrom typing import Any, Finalfrom pydantic import BaseModel- from litellm.constants import DEFAULT_MAX_RECURSE_DEPTH_SENSITIVE_DATA_MASKER+ from litellm.constants import DEFAULT_MAX_RECURSE_DEPTH, DEFAULT_MAX_RECURSE_DEPTH_SENSITIVE_DATA_MASKER+ from litellm.litellm_core_utils.secret_redaction import REDACTED+_DEFAULT_SENSITIVE_PATTERNS: Final = frozenset(+ (+ "password",+ "secret",+ "key",+ "token",+ "auth",+ "authorization",+ "credential",+ # Plural form: Vertex uses ``vertex_credentials``; segment-exact+ # matching otherwise misses it because "credential" != "credentials".+ "credentials",+ "access",+ "private",+ "certificate",+ "fingerprint",+ "tenancy",+ )+)+class SensitiveDataMasker:def __init__(diff --cc tests/test_litellm/litellm_core_utils/test_sensitive_data_masker.pyindex c2b4042bdba,fadc4ca49e9..c8b6772d965--- a/tests/test_litellm/litellm_core_utils/test_sensitive_data_masker.py+++ b/tests/test_litellm/litellm_core_utils/test_sensitive_data_masker.py@@@ -314,32 -314,119 +314,149 @@@ def test_mask_credentials_in_payload_maassert masked.endswith(plaintext[-4:])+def test_extra_sensitive_patterns_add_to_the_defaults():+ from litellm.litellm_core_utils.sensitive_data_masker import SensitiveDataMasker++ masker = SensitiveDataMasker(extra_sensitive_patterns={"connection"})++ assert masker.is_sensitive_key("mongodb_connection_string") is True+ assert masker.is_sensitive_key("api_key") is True+ assert masker.is_sensitive_key("aws_secret_access_key") is True+ assert masker.is_sensitive_key("mongodb_database") is False+++def test_extra_sensitive_patterns_do_not_leak_into_other_maskers():+ from litellm.litellm_core_utils.sensitive_data_masker import SensitiveDataMasker++ SensitiveDataMasker(extra_sensitive_patterns={"connection"})++ assert SensitiveDataMasker().is_sensitive_key("mongodb_connection_string") is False+++def test_the_second_positional_argument_is_still_the_override_set():+ """SensitiveDataMasker is public SDK surface, so adding a keyword must not shift what an+ existing positional call means. Putting extra_sensitive_patterns second would silently turn+ an override set into an extra sensitive set and start masking the caller's pricing fields."""+ from litellm.litellm_core_utils.sensitive_data_masker import SensitiveDataMasker++ masker = SensitiveDataMasker({"token"}, {"session"})++ assert masker.is_sensitive_key("session_token") is False+ assert masker.is_sensitive_key("auth_token") is True+++ def test_redact_credentials_in_payload_leaves_no_fragment_of_the_secret():+ """A payload rendered straight to stdout cannot afford the partial reveal+ mask_credentials_in_payload leaves, so every credential-named value is replaced+ whole, nested header dicts included, while ordinary params survive verbatim."""+ from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_payload++ fake_key = "sk-fake-lit6823-0000000000000000"+ fake_token = "fake-azure-ad-token-0000"+ result = redact_credentials_in_payload(+ {+ "api_key": fake_key,+ "azure_ad_token": fake_token,+ "aws_secret_access_key": "fake-aws-secret-0000",+ "vertex_credentials": {"private_key": "fake-pem"},+ "extra_headers": {"Authorization": "Bearer fake-bearer-0000", "x-request-id": "abc123"},+ "model": "gpt-4o-mini",+ "max_tokens": 17,+ "temperature": 0.25,+ "api_base": None,+ }+ )++ assert fake_key not in str(result)+ assert fake_token not in str(result)+ assert "fake-aws-secret-0000" not in str(result)+ assert "fake-pem" not in str(result)+ assert "fake-bearer-0000" not in str(result)+ assert result["api_key"] == "REDACTED"+ assert result["extra_headers"]["Authorization"] == "REDACTED"+ assert result["extra_headers"]["x-request-id"] == "abc123"+ assert result["model"] == "gpt-4o-mini"+ assert result["max_tokens"] == 17+ assert result["temperature"] == 0.25+ assert result["api_base"] is None+++ def test_redact_credentials_in_payload_reaches_credentials_nested_in_sequences():+ """Free-form kwargs like extra_body and metadata routinely carry lists of dicts, so a+ credential hiding one level inside a list or tuple must be replaced too, while the+ surrounding container keeps its type and every ordinary element stays verbatim."""+ from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_payload++ result = redact_credentials_in_payload(+ {+ "extra_body": {"providers": [{"name": "openai", "api_key": "sk-fake-lit6823-in-a-list"}]},+ "metadata": {"upstreams": ({"aws_secret_access_key": "fake-aws-in-a-tuple"},)},+ "messages": [{"role": "user", "content": "hello"}],+ }+ )++ assert "sk-fake-lit6823-in-a-list" not in str(result)+ assert "fake-aws-in-a-tuple" not in str(result)+ assert result["extra_body"]["providers"][0]["api_key"] == "REDACTED"+ assert result["extra_body"]["providers"][0]["name"] == "openai"+ assert isinstance(result["extra_body"]["providers"], list)+ assert result["metadata"]["upstreams"][0]["aws_secret_access_key"] == "REDACTED"+ assert isinstance(result["metadata"]["upstreams"], tuple)+ assert result["messages"] == [{"role": "user", "content": "hello"}]+++ @pytest.mark.parametrize("wrap", ["mapping", "sequence"])+ def test_redact_credentials_in_payload_hides_containers_at_the_recursion_limit(wrap):+ """The recursion limit exists to bound the walk, not to grant an exemption, so a caller who+ buries a credential deeper than the limit must get the container hidden rather than handed+ back verbatim. Nesting through lists costs depth twice as fast as nesting through mappings,+ so both shapes are pushed well past the limit here."""+ from litellm.constants import DEFAULT_MAX_RECURSE_DEPTH+ from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_payload++ fake_key = "sk-fake-lit6835-past-the-limit"+ node = {"api_key": fake_key}+ for _ in range(2 * DEFAULT_MAX_RECURSE_DEPTH + 1):+ node = {"extra_body": node} if wrap == "mapping" else {"providers": [node]}++ result = redact_credentials_in_payload({**node, "max_tokens": 17})++ assert fake_key not in str(result)+ assert "REDACTED" in str(result)+ assert result["max_tokens"] == 17+++ def test_redact_credentials_in_payload_leaves_a_realistic_tool_schema_intact():+ """The bound must not eat ordinary payloads: a tool whose JSON schema nests an array of+ objects inside a nested object is what agent traffic looks like, and the verbose line is+ useless if those leaves come back as REDACTED."""+ from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_payload++ tool = {+ "type": "function",+ "function": {+ "name": "search_orders",+ "parameters": {+ "type": "object",+ "properties": {+ "filters": {+ "type": "object",+ "properties": {+ "items": {+ "type": "array",+ "items": {+ "type": "object",+ "properties": {"sku": {"type": "string"}, "qty": {"type": "integer"}},+ },+ }+ },+ }+ },+ },+ },+ }++ result = redact_credentials_in_payload({"model": "gpt-4o-mini", "tools": [tool], "api_key": "sk-fake-lit6835"})++ assert "REDACTED" not in str(result["tools"])+ assert result["tools"][0] == tool+ assert result["api_key"] == "REDACTED"diff --cc uv.lockindex bb1927ce093,99d694848f5..9e6343ff375--- a/uv.lock+++ b/uv.lock@@@ -10,7 -10,7 +10,7 @@@ resolution-markers =][options]- exclude-newer = "2026-08-31T00:55:41.895302Z"-exclude-newer = "2026-08-31T17:52:45.782441Z"++exclude-newer = "2026-09-01T21:00:02.682921Z"exclude-newer-span = "P3D"[manifest]@@@ -4578,10 -4669,10 +4673,10 @@@ requires-dist ={ name = "tiktoken", specifier = ">=0.8.0,<1.0" },{ name = "tokenizers", specifier = ">=0.21.0,<1.0" },{ name = "uvicorn", marker = "extra == 'proxy'", specifier = ">=0.33.0,<1.0" },- { name = "uvloop", marker = "sys_platform != 'win32' and extra == 'proxy'", specifier = ">=0.21.0,<1.0" },+ { name = "uvloop", marker = "sys_platform != 'win32' and extra == 'proxy'", specifier = ">=0.22.1,<1.0" },{ name = "websockets", marker = "extra == 'proxy'", specifier = ">=15.0.1,<16.0" },]-provides-extras = ["proxy", "cli", "extra-proxy", "utils", "caching", "mcp", "saml", "semantic-router", "mlflow", "grpc", "stt-nvidia-riva", "google", "bedrock-realtime", "proxy-runtime"]+provides-extras = ["proxy", "cli", "extra-proxy", "utils", "caching", "mcp", "mongodb", "saml", "semantic-router", "mlflow", "grpc", "stt-nvidia-riva", "google", "bedrock-realtime", "proxy-runtime"][package.metadata.requires-dev]ci = [