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]

fix: correct image size limit enforcement and vertex_location None passthrough

Yuneng Jiang994e35135dc5
diff --git a/litellm/litellm_core_utils/token_counter.py b/litellm/litellm_core_utils/token_counter.py
index d893b980789..e6a68de07e9 100644
--- a/litellm/litellm_core_utils/token_counter.py
+++ b/litellm/litellm_core_utils/token_counter.py
@@ -219,10 +219,11 @@ def get_image_dimensions(
max_bytes = int(MAX_IMAGE_URL_DOWNLOAD_SIZE_MB * 1024 * 1024)
content_length = response.headers.get("Content-Length")
if content_length is not None and int(content_length) > max_bytes:
- raise ValueError("Image response exceeds size limit")
- img_data = response.read()
- if len(img_data) > max_bytes:
- raise ValueError("Image response exceeds size limit")
+ pass # skip download; img_data stays None
+ else:
+ body = response.read()
+ if len(body) <= max_bytes:
+ img_data = body
except Exception:
pass
if img_data is None:
diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py
index c13f6a86f83..fb8fd903409 100644
--- a/litellm/llms/vertex_ai/common_utils.py
+++ b/litellm/llms/vertex_ai/common_utils.py
@@ -232,9 +232,9 @@ def get_vertex_base_url(
"""
if vertex_location == "global":
return "https://aiplatform.googleapis.com"
- if vertex_location is not None and not re.match(
- r"^[a-z][a-z0-9-]*$", vertex_location
- ):
+ if vertex_location is None:
+ raise ValueError("vertex_location is required")
+ if not re.match(r"^[a-z][a-z0-9-]*$", vertex_location):
raise ValueError("Invalid vertex_location format")
return f"https://{vertex_location}-aiplatform.googleapis.com"
diff --git a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
index 3cf155739ca..8a86b98fee2 100644
--- a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
+++ b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
@@ -1501,9 +1501,9 @@ def get_vertex_base_url(vertex_location: Optional[str]) -> str:
"""
if vertex_location == "global":
return "https://aiplatform.googleapis.com/"
- if vertex_location is not None and not re.match(
- r"^[a-z][a-z0-9-]*$", vertex_location
- ):
+ if vertex_location is None:
+ raise ValueError("vertex_location is required")
+ if not re.match(r"^[a-z][a-z0-9-]*$", vertex_location):
raise ValueError("Invalid vertex_location format")
return f"https://{vertex_location}-aiplatform.googleapis.com/"