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 remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_scim_virtual_key_deactivation

mateo-berri456cb495de0e
diff --cc litellm/proxy/auth/user_api_key_auth.py
index 996bb7f4c22,9159a8ff9da..0ad2fb22ff3
--- a/litellm/proxy/auth/user_api_key_auth.py
+++ b/litellm/proxy/auth/user_api_key_auth.py
@@@ -1266,21 -1307,12 +1307,25 @@@ async def _user_api_key_auth_builder(
)
user_obj = None
+ # Defense in depth for SCIM-deprovisioned users: even if a
+ # cached key snuck past the blocked-flag check, refuse the
+ # request when the owning user has been marked inactive by
+ # the SCIM provider.
+ if (
+ user_obj is not None
+ and isinstance(user_obj.metadata, dict)
+ and user_obj.metadata.get("scim_active") is False
+ ):
+ raise Exception(
+ f"User={valid_token.user_id} has been deactivated via SCIM. Keys owned by this user cannot be used."
+ )
+
# Check 2a. Check if model has zero cost - if so, skip all budget checks
- model = get_model_from_request(request_data, route)
+ model = _get_model_from_request_context(
+ request_data=request_data,
+ route=route,
+ request=request,
+ )
skip_budget_checks = False
if model is not None and llm_router is not None:
from litellm.proxy.auth.auth_checks import _is_model_cost_zero
diff --cc tests/batches_tests/test_openai_batches_and_files.py
index 3f69aa01f9c,a64f208b3f1..2e89381cba9
--- a/tests/batches_tests/test_openai_batches_and_files.py
+++ b/tests/batches_tests/test_openai_batches_and_files.py
@@@ -557,8 -557,8 +557,9 @@@ async def test_avertex_batch_prediction
mock_get_response = MagicMock()
mock_get_response.json.return_value = mock_vertex_batch_response
mock_get_response.status_code = 200
+ mock_get_response.is_redirect = False
mock_get_response.raise_for_status.return_value = None
+ mock_get_response.is_redirect = False
mock_get.return_value = mock_get_response
retrieved_batch = await litellm.aretrieve_batch(