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
Adding tests + update pyproject
yuneng-jiang3504f05a5c86
diff --git a/poetry.lock b/poetry.lockindex 5e926509d54..9a7b9d9d5b2 100644--- a/poetry.lock+++ b/poetry.lock@@ -1,4 +1,4 @@-# This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand.+# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand.[[package]]name = "a2a-sdk"@@ -398,7 +398,6 @@ files = [{file = "azure_core-1.36.0-py3-none-any.whl", hash = "sha256:fee9923a3a753e94a259563429f3644aaf05c486d45b1215d098115102d91d3b"},{file = "azure_core-1.36.0.tar.gz", hash = "sha256:22e5605e6d0bf1d229726af56d9e92bc37b6e726b141a18be0b4d424131741b7"},]-markers = {main = "extra == \"proxy\" or extra == \"extra-proxy\""}[package.dependencies]requests = ">=2.21.0"@@ -419,7 +418,6 @@ files = [{file = "azure_identity-1.25.1-py3-none-any.whl", hash = "sha256:e9edd720af03dff020223cd269fa3a61e8f345ea75443858273bcb44844ab651"},{file = "azure_identity-1.25.1.tar.gz", hash = "sha256:87ca8328883de6036443e1c37b40e8dc8fb74898240f61071e09d2e369361456"},]-markers = {main = "extra == \"proxy\" or extra == \"extra-proxy\""}[package.dependencies]azure-core = ">=1.31.0"@@ -720,7 +718,7 @@ files = [{file = "cffi-2.0.0-cp39-cp39-win_amd64.whl", hash = "sha256:b882b3df248017dba09d6b16defe9b5c407fe32fc7c65a9c69798e6175601be9"},{file = "cffi-2.0.0.tar.gz", hash = "sha256:44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529"},]-markers = {main = "(platform_python_implementation != \"PyPy\" or extra == \"proxy\") and (python_version >= \"3.10\" or extra == \"proxy\" or extra == \"extra-proxy\") and (extra == \"proxy\" or extra == \"extra-proxy\" or extra == \"mlflow\")", dev = "platform_python_implementation != \"PyPy\"", proxy-dev = "platform_python_implementation != \"PyPy\""}+markers = {main = "platform_python_implementation != \"PyPy\" or extra == \"proxy\"", dev = "platform_python_implementation != \"PyPy\"", proxy-dev = "platform_python_implementation != \"PyPy\""}[package.dependencies]pycparser = {version = "*", markers = "implementation_name != \"PyPy\""}@@ -1151,6 +1149,7 @@ description = "cryptography is a package which provides cryptographic recipes anoptional = falsepython-versions = ">=3.7"groups = ["main", "dev", "proxy-dev"]+markers = "python_version == \"3.9\""files = [{file = "cryptography-43.0.3-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:bf7a1932ac4176486eab36a19ed4c0492da5d97123f1406cf15e41b05e787d2e"},{file = "cryptography-43.0.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63efa177ff54aec6e1c0aefaa1a241232dcd37413835a9b674b6e3f0ae2bfd3e"},@@ -1180,7 +1179,6 @@ files = [{file = "cryptography-43.0.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2ce6fae5bdad59577b44e4dfed356944fbf1d925269114c28be377692643b4ff"},{file = "cryptography-43.0.3.tar.gz", hash = "sha256:315b9001266a492a6ff443b61238f956b214dbec9910a081ba5b6646a055a805"},]-markers = {main = "python_version == \"3.9\" and (extra == \"proxy\" or extra == \"extra-proxy\")", dev = "python_version == \"3.9\"", proxy-dev = "python_version == \"3.9\""}[package.dependencies]cffi = {version = ">=1.12", markers = "platform_python_implementation != \"PyPy\""}@@ -1202,6 +1200,7 @@ description = "cryptography is a package which provides cryptographic recipes anoptional = falsepython-versions = "!=3.9.0,!=3.9.1,>=3.8"groups = ["main", "dev", "proxy-dev"]+markers = "python_version >= \"3.10\""files = [{file = "cryptography-46.0.3-cp311-abi3-macosx_10_9_universal2.whl", hash = "sha256:109d4ddfadf17e8e7779c39f9b18111a09efb969a301a31e987416a0191ed93a"},{file = "cryptography-46.0.3-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:09859af8466b69bc3c27bdf4f5d84a665e0f7ab5088412e9e2ec49758eca5cbc"},@@ -1258,7 +1257,6 @@ files = [{file = "cryptography-46.0.3-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:6b5063083824e5509fdba180721d55909ffacccc8adbec85268b48439423d78c"},{file = "cryptography-46.0.3.tar.gz", hash = "sha256:a8b17438104fed022ce745b362294d9ce35b4c2e45c1d958ad4a4b019285f4a1"},]-markers = {main = "python_version >= \"3.10\" and (extra == \"proxy\" or extra == \"extra-proxy\" or extra == \"mlflow\")", dev = "python_version >= \"3.10\"", proxy-dev = "python_version >= \"3.10\""}[package.dependencies]cffi = {version = ">=2.0.0", markers = "python_full_version >= \"3.9.0\" and platform_python_implementation != \"PyPy\""}@@ -2277,11 +2275,11 @@ files = [][package.dependencies]-google-api-core = {version = ">=1.34.1,<2.0.dev0 || >=2.11.dev0,<3.0.0.dev0", extras = ["grpc"]}-google-auth = ">=2.14.1,<2.24.0 || >2.24.0,<2.25.0 || >2.25.0,<3.0.0.dev0"-grpc-google-iam-v1 = ">=0.12.4,<1.0.0.dev0"-proto-plus = ">=1.22.3,<2.0.0.dev0"-protobuf = ">=3.20.2,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<6.0.0.dev0"+google-api-core = {version = ">=1.34.1,<2.0.dev0 || >=2.11.dev0,<3.0.0dev", extras = ["grpc"]}+google-auth = ">=2.14.1,<2.24.0 || >2.24.0,<2.25.0 || >2.25.0,<3.0.0dev"+grpc-google-iam-v1 = ">=0.12.4,<1.0.0dev"+proto-plus = ">=1.22.3,<2.0.0dev"+protobuf = ">=3.20.2,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<6.0.0dev"[[package]]name = "google-cloud-resource-manager"@@ -3284,7 +3282,7 @@ files = [[package.dependencies]attrs = ">=22.2.0"-jsonschema-specifications = ">=2023.3.6"+jsonschema-specifications = ">=2023.03.6"referencing = ">=0.28.4"rpds-py = ">=0.7.1"@@ -3448,28 +3446,28 @@ openai = ["openai (>=0.27.8)"][[package]]name = "litellm-enterprise"-version = "0.1.27"+version = "0.1.30"description = "Package for LiteLLM Enterprise features"optional = truepython-versions = "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8"groups = ["main"]markers = "extra == \"proxy\""files = [- {file = "litellm_enterprise-0.1.27-py3-none-any.whl", hash = "sha256:41b9d41d04123f492060a742091006dc1d182b54ce3a1c0e18ee75d623c63e91"},- {file = "litellm_enterprise-0.1.27.tar.gz", hash = "sha256:aa40c87f7c8df64beb79e75f71e1b5c0a458350efa68527e3491e6f27f2cbd57"},+ {file = "litellm_enterprise-0.1.30-py3-none-any.whl", hash = "sha256:9715e0b99ae431fcc9621cc515b329b55d7dd291c611c3a0842e94869de219dc"},+ {file = "litellm_enterprise-0.1.30.tar.gz", hash = "sha256:5ffbf25720b75e59c157dca5edff5db61b85e85072c340b1aa02f04e3924fe3e"},][[package]]name = "litellm-proxy-extras"-version = "0.4.30"+version = "0.4.31"description = "Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package."optional = truepython-versions = "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8"groups = ["main"]markers = "extra == \"proxy\""files = [- {file = "litellm_proxy_extras-0.4.30-py3-none-any.whl", hash = "sha256:0b7df68f0968eb817462b847eaee81bba23d935adb2e84d2e342a77711887051"},- {file = "litellm_proxy_extras-0.4.30.tar.gz", hash = "sha256:5d32f8dc3d37d36fb15ab6995fea706dd8a453ff7f12e70b47cba35e5368da10"},+ {file = "litellm_proxy_extras-0.4.31-py3-none-any.whl", hash = "sha256:f50bee4b21dbe0b1c47ed88dc90cf7a2024b221ff8f6da9343197a1df8ea3ecd"},+ {file = "litellm_proxy_extras-0.4.31.tar.gz", hash = "sha256:0b99a522ca31f2da835bb49037d787257e90269f90c2b5b81a4e8d575edd0778"},][[package]]@@ -3948,7 +3946,6 @@ files = [{file = "msal-1.34.0-py3-none-any.whl", hash = "sha256:f669b1644e4950115da7a176441b0e13ec2975c29528d8b9e81316023676d6e1"},{file = "msal-1.34.0.tar.gz", hash = "sha256:76ba83b716ea5a6d75b0279c0ac353a0e05b820ca1f6682c0eb7f45190c43c2f"},]-markers = {main = "extra == \"proxy\" or extra == \"extra-proxy\""}[package.dependencies]cryptography = ">=2.5,<49"@@ -3969,7 +3966,6 @@ files = [{file = "msal_extensions-1.3.1-py3-none-any.whl", hash = "sha256:96d3de4d034504e969ac5e85bae8106c8373b5c6568e4c8fa7af2eca9dbe6bca"},{file = "msal_extensions-1.3.1.tar.gz", hash = "sha256:c5b0fd10f65ef62b5f1d62f4251d51cbcaf003fcedae8c91b040a488614be1a4"},]-markers = {main = "extra == \"proxy\" or extra == \"extra-proxy\""}[package.dependencies]msal = ">=1.29,<2"@@ -4220,7 +4216,6 @@ files = [{file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"},{file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"},]-markers = {main = "extra == \"extra-proxy\""}[[package]]name = "numpy"@@ -4428,7 +4423,7 @@ files = [{file = "opentelemetry_api-1.39.1-py3-none-any.whl", hash = "sha256:2edd8463432a7f8443edce90972169b195e7d6a05500cd29e6d13898187c9950"},{file = "opentelemetry_api-1.39.1.tar.gz", hash = "sha256:fbde8c80e1b937a2c61f20347e91c0c18a1940cecf012d62e65a7caf08967c9c"},]-markers = {main = "python_version >= \"3.10\" and extra == \"mlflow\""}+markers = {main = "python_version >= \"3.10\""}[package.dependencies]importlib-metadata = ">=6.0,<8.8.0"@@ -4543,7 +4538,7 @@ files = [{file = "opentelemetry_sdk-1.39.1-py3-none-any.whl", hash = "sha256:4d5482c478513ecb0a5d938dcc61394e647066e0cc2676bee9f3af3f3f45f01c"},{file = "opentelemetry_sdk-1.39.1.tar.gz", hash = "sha256:cf4d4563caf7bff906c9f7967e2be22d0d6b349b908be0d90fb21c8e9c995cc6"},]-markers = {main = "python_version >= \"3.10\" and extra == \"mlflow\""}+markers = {main = "python_version >= \"3.10\""}[package.dependencies]opentelemetry-api = "1.39.1"@@ -4561,7 +4556,7 @@ files = [{file = "opentelemetry_semantic_conventions-0.60b1-py3-none-any.whl", hash = "sha256:9fa8c8b0c110da289809292b0591220d3a7b53c1526a23021e977d68597893fb"},{file = "opentelemetry_semantic_conventions-0.60b1.tar.gz", hash = "sha256:87c228b5a0669b748c76d76df6c364c369c28f1c465e50f661e39737e84bc953"},]-markers = {main = "python_version >= \"3.10\" and extra == \"mlflow\""}+markers = {main = "python_version >= \"3.10\""}[package.dependencies]opentelemetry-api = "1.39.1"@@ -5038,7 +5033,6 @@ files = [{file = "prisma-0.11.0-py3-none-any.whl", hash = "sha256:22bb869e59a2968b99f3483bb417717273ffbc569fd1e9ceed95e5614cbaf53a"},{file = "prisma-0.11.0.tar.gz", hash = "sha256:3f2f2fd2361e1ec5ff655f2a04c7860c2f2a5bc4c91f78ca9c5c6349735bf693"},]-markers = {main = "extra == \"extra-proxy\""}[package.dependencies]click = ">=7.1.2"@@ -5355,7 +5349,7 @@ files = [{file = "pycparser-2.23-py3-none-any.whl", hash = "sha256:e5c6e8d3fbad53479cab09ac03729e0a9faf2bee3db8208a550daf5af81a5934"},{file = "pycparser-2.23.tar.gz", hash = "sha256:78816d4f24add8f10a06d6f05b4d424ad9e96cfebf68a4ddc99c65c0720d00c2"},]-markers = {main = "implementation_name != \"PyPy\" and (platform_python_implementation != \"PyPy\" or extra == \"proxy\") and (python_version >= \"3.10\" or extra == \"proxy\" or extra == \"extra-proxy\") and (extra == \"proxy\" or extra == \"extra-proxy\" or extra == \"mlflow\")", dev = "implementation_name != \"PyPy\" and platform_python_implementation != \"PyPy\"", proxy-dev = "implementation_name != \"PyPy\" and platform_python_implementation != \"PyPy\""}+markers = {main = "implementation_name != \"PyPy\" and (platform_python_implementation != \"PyPy\" or extra == \"proxy\")", dev = "implementation_name != \"PyPy\" and platform_python_implementation != \"PyPy\"", proxy-dev = "implementation_name != \"PyPy\" and platform_python_implementation != \"PyPy\""}[[package]]name = "pydantic"@@ -5578,7 +5572,6 @@ files = [{file = "PyJWT-2.10.1-py3-none-any.whl", hash = "sha256:dcdd193e30abefd5debf142f9adfcdd2b58004e644f25406ffaebd50bd98dacb"},{file = "pyjwt-2.10.1.tar.gz", hash = "sha256:3cc5772eb20009233caf06e9d8a0577824723b44e6648ee0a2aedb6cf9381953"},]-markers = {main = "extra == \"extra-proxy\" or extra == \"proxy\""}[package.dependencies]cryptography = {version = ">=3.4.0", optional = true, markers = "extra == \"crypto\""}@@ -6680,10 +6673,10 @@ files = [][package.dependencies]-botocore = ">=1.37.4,<2.0a0"+botocore = ">=1.37.4,<2.0a.0"[package.extras]-crt = ["botocore[crt] (>=1.37.4,<2.0a0)"]+crt = ["botocore[crt] (>=1.37.4,<2.0a.0)"][[package]]name = "scikit-learn"@@ -6916,9 +6909,9 @@ tornado = ">=6.4.2,<7"urllib3 = ">=1.26,<3"[package.extras]-all = ["boto3 (>=1.34.98,<2)", "botocore (>=1.34.110,<2)", "cohere (>=5.9.4,<6.0)", "dagger-io (>=0.1.1) ; python_version >= \"3.11\"", "fastembed (>=0.3.0,<0.4) ; python_version < \"3.13\"", "google-cloud-aiplatform (>=1.45.0,<2)", "ipykernel (>=6.25.0,<7)", "llama-cpp-python (>=0.2.28,<0.2.86) ; python_version < \"3.13\"", "mistralai (>=0.0.12,<0.1.0)", "mypy (>=1.7.1,<2)", "ollama (>=0.1.7)", "pillow (>=10.2.0,<11.0.0) ; python_version < \"3.13\"", "pinecone[asyncio] (>=7.0.0,<8.0.0)", "psycopg[binary] (>=3.1.0,<4)", "pytest (>=8.2,<9.0)", "pytest-asyncio (>=0.24.0,<0.25)", "pytest-cov (>=4.1.0,<5)", "pytest-mock (>=3.12.0,<4)", "pytest-timeout", "pytest-xdist (>=3.5.0,<4)", "python-dotenv (>=1.0.0,<2)", "qdrant-client (>=1.11.1,<2)", "requests-mock (>=1.12.1,<2)", "ruff (>=0.11.2,<0.12)", "sentence-transformers (>=5.0.0) ; python_version < \"3.13\"", "tokenizers (>=0.19) ; python_version < \"3.13\"", "torch (>=2.6.0) ; python_version < \"3.13\"", "torchvision (>=0.17.0) ; python_version < \"3.13\"", "transformers (>=4.36.2) ; python_version < \"3.13\"", "types-pyyaml (>=6.0.12.12,<7)", "types-requests (>=2.31.0,<3)"]+all = ["boto3 (>=1.34.98,<2)", "botocore (>=1.34.110,<2)", "cohere (>=5.9.4,<6.00)", "dagger-io (>=0.1.1) ; python_version >= \"3.11\"", "fastembed (>=0.3.0,<0.4) ; python_version < \"3.13\"", "google-cloud-aiplatform (>=1.45.0,<2)", "ipykernel (>=6.25.0,<7)", "llama-cpp-python (>=0.2.28,<0.2.86) ; python_version < \"3.13\"", "mistralai (>=0.0.12,<0.1.0)", "mypy (>=1.7.1,<2)", "ollama (>=0.1.7)", "pillow (>=10.2.0,<11.0.0) ; python_version < \"3.13\"", "pinecone[asyncio] (>=7.0.0,<8.0.0)", "psycopg[binary] (>=3.1.0,<4)", "pytest (>=8.2,<9.0)", "pytest-asyncio (>=0.24.0,<0.25)", "pytest-cov (>=4.1.0,<5)", "pytest-mock (>=3.12.0,<4)", "pytest-timeout", "pytest-xdist (>=3.5.0,<4)", "python-dotenv (>=1.0.0,<2)", "qdrant-client (>=1.11.1,<2)", "requests-mock (>=1.12.1,<2)", "ruff (>=0.11.2,<0.12)", "sentence-transformers (>=5.0.0) ; python_version < \"3.13\"", "tokenizers (>=0.19) ; python_version < \"3.13\"", "torch (>=2.6.0) ; python_version < \"3.13\"", "torchvision (>=0.17.0) ; python_version < \"3.13\"", "transformers (>=4.36.2) ; python_version < \"3.13\"", "types-pyyaml (>=6.0.12.12,<7)", "types-requests (>=2.31.0,<3)"]bedrock = ["boto3 (>=1.34.98,<2)", "botocore (>=1.34.110,<2)"]-cohere = ["cohere (>=5.9.4,<6.0)"]+cohere = ["cohere (>=5.9.4,<6.00)"]dev = ["dagger-io (>=0.1.1) ; python_version >= \"3.11\"", "ipykernel (>=6.25.0,<7)", "mypy (>=1.7.1,<2)", "pytest (>=8.2,<9.0)", "pytest-asyncio (>=0.24.0,<0.25)", "pytest-cov (>=4.1.0,<5)", "pytest-mock (>=3.12.0,<4)", "pytest-timeout", "pytest-xdist (>=3.5.0,<4)", "python-dotenv (>=1.0.0,<2)", "requests-mock (>=1.12.1,<2)", "ruff (>=0.11.2,<0.12)", "types-pyyaml (>=6.0.12.12,<7)", "types-requests (>=2.31.0,<3)"]docs = ["pydoc-markdown (>=4.8.2) ; python_version < \"3.12\""]fastembed = ["fastembed (>=0.3.0,<0.4) ; python_version < \"3.13\""]@@ -7762,7 +7755,6 @@ files = [{file = "tomlkit-0.13.3-py3-none-any.whl", hash = "sha256:c89c649d79ee40629a9fda55f8ace8c6a1b42deb912b2a8fd8d942ddadb606b0"},{file = "tomlkit-0.13.3.tar.gz", hash = "sha256:430cf247ee57df2b94ee3fbe588e71d362a941ebb545dec29b53961d61add2a1"},]-markers = {main = "extra == \"extra-proxy\""}[[package]]name = "tornado"@@ -8531,8 +8523,4 @@ utils = ["numpydoc"][metadata]lock-version = "2.1"python-versions = ">=3.9,<4.0"-<<<<<<< litellm_oss_staging_02_04_2026-content-hash = "797603dcfef0a79781c7d3cba5dfe18f6aea4aa792220f47487ebc7bd04ae2e3"-=======-content-hash = "e5447e14dd37e324ac07a8fc6286d27e9a0d355ed93ebb24fc11e3f5df12fd3e"->>>>>>> main+content-hash = "16433b6ceb3c56276021223166394591cfd5a18da40c2244799d56ee3167c366"diff --git a/pyproject.toml b/pyproject.tomlindex 768a41d2e8b..c4ff0aac209 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -63,7 +63,7 @@ mcp = {version = ">=1.25.0,<2.0.0", optional = true, python = ">=3.10"}a2a-sdk = {version = "^0.3.22", optional = true, python = ">=3.10"}litellm-proxy-extras = {version = "0.4.31", optional = true}rich = {version = "13.7.1", optional = true}-litellm-enterprise = {version = "0.1.27", optional = true}+litellm-enterprise = {version = "0.1.30", optional = true}diskcache = {version = "^5.6.1", optional = true}polars = {version = "^1.31.0", optional = true, python = ">=3.10"}semantic-router = {version = ">=0.1.12", optional = true, python = ">=3.9,<3.14"}diff --git a/tests/proxy_unit_tests/test_auth_checks.py b/tests/proxy_unit_tests/test_auth_checks.pyindex 05c6e4984af..ee595092995 100644--- a/tests/proxy_unit_tests/test_auth_checks.py+++ b/tests/proxy_unit_tests/test_auth_checks.py@@ -21,11 +21,13 @@ from litellm.proxy._types import (LiteLLM_BudgetTable,LiteLLM_UserTable,LiteLLM_TeamTable,+ Litellm_EntityType,)from litellm.proxy.utils import PrismaClientfrom litellm.proxy.auth.auth_checks import (can_team_access_model,_virtual_key_soft_budget_check,+ _team_soft_budget_check,)from litellm.proxy.utils import ProxyLoggingfrom litellm.proxy.utils import CallInfo@@ -478,6 +480,84 @@ async def test_virtual_key_soft_budget_check(spend, soft_budget, expect_alert):), f"Expected alert_triggered to be {expect_alert} for spend={spend}, soft_budget={soft_budget}"+ "spend, soft_budget, expect_alert, metadata, expected_alert_emails",+ [+ (100, 50, True, None, None), # Over soft budget, no metadata+ (50, 50, True, None, None), # At soft budget, no metadata+ (25, 50, False, None, None), # Under soft budget+ (100, None, False, None, None), # No soft budget set+ (100, 50, True, {"soft_budget_alerting_emails": ["[email protected]", "[email protected]"]}, ["[email protected]", "[email protected]"]), # Over soft budget with list of emails+ (100, 50, True, {"soft_budget_alerting_emails": "[email protected],[email protected]"}, ["[email protected]", "[email protected]"]), # Over soft budget with comma-separated emails+ (100, 50, True, {"soft_budget_alerting_emails": ["[email protected]", "", " ", "[email protected]"]}, ["[email protected]", "[email protected]"]), # Over soft budget with empty strings filtered+ ],+)+async def test_team_soft_budget_check(spend, soft_budget, expect_alert, metadata, expected_alert_emails):+ """+ Test cases for _team_soft_budget_check:+ 1. Spend over soft budget - should trigger alert+ 2. Spend at soft budget - should trigger alert+ 3. Spend under soft budget - should not trigger alert+ 4. No soft budget set - should not trigger alert+ 5. Team with alert emails in metadata (list) - should include alert_emails in CallInfo+ 6. Team with alert emails in metadata (comma-separated string) - should parse and include alert_emails+ 7. Team with alert emails containing empty strings - should filter them out+ """+ alert_triggered = False+ captured_call_info = None++ class MockProxyLogging:+ async def budget_alerts(self, type, user_info):+ nonlocal alert_triggered, captured_call_info+ alert_triggered = True+ captured_call_info = user_info+ assert type == "soft_budget"+ assert isinstance(user_info, CallInfo)++ valid_token = UserAPIKeyAuth(+ token="test-token",+ user_id="test-user",+ team_id="test-team",+ team_alias="test-team-alias",+ key_alias="test-key",+ )++ team_object = LiteLLM_TeamTable(+ team_id="test-team",+ spend=spend,+ soft_budget=soft_budget,+ max_budget=100.0,+ metadata=metadata,+ )++ proxy_logging_obj = MockProxyLogging()++ await _team_soft_budget_check(+ team_object=team_object,+ valid_token=valid_token,+ proxy_logging_obj=proxy_logging_obj,+ )++ await asyncio.sleep(0.1) # Allow time for the alert task to complete++ assert (+ alert_triggered == expect_alert+ ), f"Expected alert_triggered to be {expect_alert} for spend={spend}, soft_budget={soft_budget}"++ if expect_alert:+ assert captured_call_info is not None+ assert captured_call_info.team_id == "test-team"+ assert captured_call_info.spend == spend+ assert captured_call_info.soft_budget == soft_budget+ assert captured_call_info.event_group == Litellm_EntityType.TEAM+ # Verify alert_emails if expected+ if expected_alert_emails is not None:+ assert captured_call_info.alert_emails == expected_alert_emails+ else:+ assert captured_call_info.alert_emails is None or captured_call_info.alert_emails == []++@pytest.mark.asyncioasync def test_can_user_call_model():from litellm.proxy.auth.auth_checks import can_user_call_modeldiff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.pyindex c7803445eb4..ee23811d5ac 100644--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@ -2870,6 +2870,111 @@ class TestProxyLoggingBudgetAlerts:type=alert_type, user_info=user_info)+ async def test_budget_alerts_soft_budget_with_alert_emails_bypasses_alerting_none(self):+ """+ Test that soft_budget alerts with alert_emails bypass the alerting=None check+ and send emails even when alerting is None.++ This tests the new logic that allows team-specific soft budget email alerts+ via metadata.soft_budget_alerting_emails to work even when global alerting is disabled.+ """+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging+ from litellm.proxy._types import CallInfo, Litellm_EntityType++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = None # Global alerting is disabled+ proxy_logging.slack_alerting_instance = AsyncMock()+ proxy_logging.email_logging_instance = AsyncMock()++ # Create CallInfo with alert_emails set (simulating team metadata extraction)+ user_info = CallInfo(+ token="test-token",+ spend=100.0,+ soft_budget=50.0,+ user_id="test-user",+ team_id="test-team",+ team_alias="test-team-alias",+ event_group=Litellm_EntityType.TEAM,+ alert_emails=["[email protected]", "[email protected]"],+ )++ # Should send email even though alerting is None (because of alert_emails)+ await proxy_logging.budget_alerts(type="soft_budget", user_info=user_info)++ # Verify slack was NOT called (alerting is None)+ proxy_logging.slack_alerting_instance.budget_alerts.assert_not_called()++ # Verify email WAS called (bypasses alerting=None check)+ proxy_logging.email_logging_instance.budget_alerts.assert_called_once_with(+ type="soft_budget", user_info=user_info+ )++ async def test_budget_alerts_soft_budget_without_alert_emails_respects_alerting_none(self):+ """+ Test that soft_budget alerts WITHOUT alert_emails still respect alerting=None+ and do not send emails when alerting is None.+ """+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging+ from litellm.proxy._types import CallInfo, Litellm_EntityType++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = None+ proxy_logging.slack_alerting_instance = AsyncMock()+ proxy_logging.email_logging_instance = AsyncMock()++ # Create CallInfo WITHOUT alert_emails+ user_info = CallInfo(+ token="test-token",+ spend=100.0,+ soft_budget=50.0,+ user_id="test-user",+ team_id="test-team",+ team_alias="test-team-alias",+ event_group=Litellm_EntityType.TEAM,+ alert_emails=None, # No alert emails+ )++ # Should NOT send email (alerting is None and no alert_emails)+ await proxy_logging.budget_alerts(type="soft_budget", user_info=user_info)++ # Verify no calls were made+ proxy_logging.slack_alerting_instance.budget_alerts.assert_not_called()+ proxy_logging.email_logging_instance.budget_alerts.assert_not_called()++ async def test_budget_alerts_soft_budget_with_empty_alert_emails_respects_alerting_none(self):+ """+ Test that soft_budget alerts with empty alert_emails list still respect alerting=None.+ """+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging+ from litellm.proxy._types import CallInfo, Litellm_EntityType++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = None+ proxy_logging.slack_alerting_instance = AsyncMock()+ proxy_logging.email_logging_instance = AsyncMock()++ # Create CallInfo with empty alert_emails list+ user_info = CallInfo(+ token="test-token",+ spend=100.0,+ soft_budget=50.0,+ user_id="test-user",+ team_id="test-team",+ team_alias="test-team-alias",+ event_group=Litellm_EntityType.TEAM,+ alert_emails=[], # Empty list+ )++ # Should NOT send email (alert_emails is empty)+ await proxy_logging.budget_alerts(type="soft_budget", user_info=user_info)++ # Verify no calls were made+ proxy_logging.slack_alerting_instance.budget_alerts.assert_not_called()+ proxy_logging.email_logging_instance.budget_alerts.assert_not_called()+def test_azure_ai_claude_provider_config():"""Test that Azure AI Claude models return AzureAnthropicConfig for proper tool transformation."""