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): match image URL schemes case-insensitively when counting relayed prompt tokens
mateo-berri02b18b4fc638
diff --git a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.pyindex 206002d13f7..93fe3c5b31b 100644--- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py+++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py@@ -105,7 +105,9 @@ def _is_remote_high_detail_image(part: object) -> bool:if not isinstance(image_url, Mapping):return Falseurl: Final = image_url.get("url")- return isinstance(url, str) and url.startswith(("http://", "https://")) and image_url.get("detail") == "high"+ return (+ isinstance(url, str) and url.lower().startswith(("http://", "https://")) and image_url.get("detail") == "high"+ )def _content_parts(message: Mapping[str, object]) -> Sequence[object]:diff --git a/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_passthrough_logging_handler.py b/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_passthrough_logging_handler.pyindex 0ddafd20e68..a3d3ae32169 100644--- a/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_passthrough_logging_handler.py+++ b/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_passthrough_logging_handler.py@@ -2083,3 +2083,12 @@ def test_count_relayed_prompt_tokens_charges_only_the_remote_high_detail_image_aassert count_relayed_prompt_tokens("gpt-4.1-mini", messages) == (litellm.token_counter(model="gpt-4.1-mini", messages=TEXT_ONLY_MESSAGES) + high_detail_image_token_upper_bound())++[email protected]("scheme", ["HTTPS://", "Http://"])+def test_count_relayed_prompt_tokens_charges_an_uppercase_scheme_remote_high_detail_image_at_the_upper_bound(scheme):+ messages = _image_messages(scheme + UNREACHABLE_IMAGE_URL.split("://", 1)[1], "high")++ assert count_relayed_prompt_tokens("gpt-4.1-mini", messages) == (+ litellm.token_counter(model="gpt-4.1-mini", messages=TEXT_ONLY_MESSAGES) + high_detail_image_token_upper_bound()+ )