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
fix(passthrough): dispatch Comprehend Medical logging on the provider tag only
mateo-berri7f42c84f57e2
diff --git a/helm/litellm/templates/ingress.yaml b/helm/litellm/templates/ingress.yamlindex b7c78d3fdad..ab609354d7b 100644--- a/helm/litellm/templates/ingress.yaml+++ b/helm/litellm/templates/ingress.yaml@@ -24,7 +24,7 @@"/v1/video" "/v1/videos" "/video" "/videos" "/v1/search" "/search""/v1/containers" "/containers" "/v1/evals" "/v1/memory" "/queue/chat""/v1beta" "/interactions"- "/anthropic" "/azure" "/azure_ai" "/aws" "/bedrock" "/cohere" "/gemini" "/google"+ "/anthropic" "/azure" "/azure_ai" "/aws" "/bedrock" "/comprehendmedical" "/cohere" "/gemini" "/google""/vertex_ai" "/vertex-ai" "/assemblyai" "/eu.assemblyai" "/langfuse" "/vllm""/mistral" "/groq" "/voyage" "/cursor" "/milvus" "/openai_passthrough""/toolset"diff --git a/litellm/proxy/pass_through_endpoints/success_handler.py b/litellm/proxy/pass_through_endpoints/success_handler.pyindex 749784c1bf5..c38566375f4 100644--- a/litellm/proxy/pass_through_endpoints/success_handler.py+++ b/litellm/proxy/pass_through_endpoints/success_handler.py@@ -236,7 +236,7 @@ class PassThroughEndpointLogging:)standard_logging_response_object = cursor_passthrough_logging_handler_result["result"]kwargs = cursor_passthrough_logging_handler_result["kwargs"]- elif self.is_comprehend_medical_route(url_route, custom_llm_provider):+ elif self.is_comprehend_medical_route(custom_llm_provider):from .llm_provider_handlers.comprehend_medical_passthrough_logging_handler import (ComprehendMedicalPassthroughLoggingHandler,)@@ -384,13 +384,8 @@ class PassThroughEndpointLogging:return Truereturn False- def is_comprehend_medical_route(self, url_route: str, custom_llm_provider: str | None = None) -> bool:- if custom_llm_provider == "comprehendmedical":- return True- hostname: Final = urlparse(url_route).hostname- if hostname is None:- return False- return hostname.startswith("comprehendmedical.") and hostname.endswith(".amazonaws.com")+ def is_comprehend_medical_route(self, custom_llm_provider: str | None) -> bool:+ return custom_llm_provider == "comprehendmedical"def is_langfuse_route(self, url_route: str):parsed_url: Final = urlparse(url_route)diff --git a/terraform/litellm/aws/locals.tf b/terraform/litellm/aws/locals.tfindex 33f63fc4205..bd5b97b0f50 100644--- a/terraform/litellm/aws/locals.tf+++ b/terraform/litellm/aws/locals.tf@@ -86,7 +86,7 @@ locals {"/queue/chat/*","/v1beta/*","/interactions/*",- "/anthropic/*", "/azure/*", "/azure_ai/*", "/aws/*", "/bedrock/*",+ "/anthropic/*", "/azure/*", "/azure_ai/*", "/aws/*", "/bedrock/*", "/comprehendmedical*","/cohere/*", "/gemini/*", "/google/*","/vertex_ai/*", "/vertex-ai/*","/assemblyai/*", "/eu.assemblyai/*",diff --git a/terraform/litellm/gcp/locals.tf b/terraform/litellm/gcp/locals.tfindex 732b4ce7d6b..9a817eba605 100644--- a/terraform/litellm/gcp/locals.tf+++ b/terraform/litellm/gcp/locals.tf@@ -52,7 +52,7 @@ locals {"/queue/chat/*","/v1beta/*","/interactions/*",- "/anthropic/*", "/azure/*", "/azure_ai/*", "/aws/*", "/bedrock/*",+ "/anthropic/*", "/azure/*", "/azure_ai/*", "/aws/*", "/bedrock/*", "/comprehendmedical*","/cohere/*", "/gemini/*", "/google/*","/vertex_ai/*", "/vertex-ai/*","/assemblyai/*", "/eu.assemblyai/*",diff --git a/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_comprehend_medical_passthrough_logging_handler.py b/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_comprehend_medical_passthrough_logging_handler.pyindex 0bc45c046bd..1804877e688 100644--- a/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_comprehend_medical_passthrough_logging_handler.py+++ b/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_comprehend_medical_passthrough_logging_handler.py@@ -95,21 +95,30 @@ class TestComprehendMedicalPassthroughHandler:class TestIsComprehendMedicalRoute:- def test_matches_by_hostname(self):- assert PassThroughEndpointLogging().is_comprehend_medical_route(- "https://comprehendmedical.us-east-1.amazonaws.com/", None- )-def test_matches_by_provider_tag(self):- assert PassThroughEndpointLogging().is_comprehend_medical_route("https://example.com/", "comprehendmedical")+ assert PassThroughEndpointLogging().is_comprehend_medical_route("comprehendmedical")++ def test_does_not_match_other_providers(self):+ assert not PassThroughEndpointLogging().is_comprehend_medical_route("bedrock")++ def test_config_driven_passthrough_to_comprehend_host_is_not_claimed(self):+ logging_obj = _make_logging_obj()- def test_does_not_match_other_aws_hosts(self):- assert not PassThroughEndpointLogging().is_comprehend_medical_route(- "https://bedrock-runtime.us-east-1.amazonaws.com/model/x/converse", None+ normalized = PassThroughEndpointLogging().normalize_llm_passthrough_logging_payload(+ httpx_response=_make_response("DetectEntitiesV2"),+ response_body={"Entities": []},+ request_body={"Text": "John Smith"},+ logging_obj=logging_obj,+ url_route="https://comprehendmedical.us-east-1.amazonaws.com/",+ result='{"Entities": []}',+ start_time=datetime.now(),+ end_time=datetime.now(),+ cache_hit=False,+ custom_llm_provider=None,)- def test_does_not_match_lookalike_hosts_outside_aws(self):- assert not PassThroughEndpointLogging().is_comprehend_medical_route("https://comprehendmedical.evil.com/", None)+ assert normalized["kwargs"].get("model") != "comprehendmedical/DetectEntitiesV2"+ assert "response_cost" not in normalized["kwargs"]class TestNormalizeDispatch: