BerriAI/litellm · error · ValueError
vertex_location is required
Error message
vertex_location is required
What it means
validate_vertex_location guard: the client-supplied vertex_location is None/empty after resolution. Because it is interpolated into the request host (SSRF-sensitive), an explicit error is raised instead of defaulting silently.
Source
Thrown at litellm/llms/vertex_ai/common_utils.py:329
def validate_vertex_location(vertex_location: str | None) -> str:
"""
Validate a Vertex AI location before interpolating it into a request host or
URL path.
``vertex_location`` is client-controllable on the proxy (it flows in from the
request body), so it must never be trusted verbatim in a URL or an attacker
could point the host at their own server and exfiltrate the admin's Google
access token. Allow the special ``global`` control plane and otherwise require
a lowercase alphanumeric-plus-hyphen token (e.g. ``us``, ``us-central1``,
``eu``), which rejects host injection like ``attacker.example/`` or
``evil.com#``.
"""
if vertex_location == "global":
return 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 vertex_location
def get_vertex_base_url(
vertex_location: str | None,
) -> str:
"""
Get the base URL for Vertex AI API calls.
- ``global`` uses the global control plane host.
- Multi-region geographies (e.g. ``us``, ``eu``) use ``aiplatform.{geo}.rep.googleapis.com``.
- Regional locations (e.g. ``us-central1``) use ``{region}-aiplatform.googleapis.com``.
"""
validated_location: Final = validate_vertex_location(vertex_location)
if validated_location == "global":
return "https://aiplatform.googleapis.com"View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set VERTEXAI_LOCATION environment variable.
- Or pass vertex_location in litellm_params.
Example fix
os.environ["VERTEXAI_LOCATION"] = "us-central1"
Defensive patterns
Strategy: validation
When it happens
Trigger: Triggered when a Vertex AI call requires vertex_location but none is provided.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/e4fd0878013dfc8d.
Report an issue: GitHub.