BerriAI/litellm · error · ValueError

vertex_project, vertex_location, and model are required when

Error message

vertex_project, vertex_location, and model are required when use_psc_endpoint_format=True

What it means

Raised when use_psc_endpoint_format=True but one of vertex_project, vertex_location, or model is missing: the PSC URL format embeds all three ({api_base}/v1/projects/{project}/locations/{location}/endpoints/{model}:{endpoint}) and cannot be templated without them.

Source

Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:653

        if api_base:
            if custom_llm_provider == "gemini":
                # For Gemini (Google AI Studio), construct the full path like other providers
                if model is None:
                    raise ValueError("Model parameter is required for Gemini custom API base URLs")
                url = f"{api_base}/models/{model}:{endpoint}"
                if gemini_api_key is None:
                    raise ValueError(
                        "Missing Gemini API key. Set the GEMINI_API_KEY or GOOGLE_API_KEY environment variable."
                    )
                if gemini_api_key is not None:
                    auth_header = {"x-goog-api-key": gemini_api_key}
            else:
                # For Vertex AI
                if use_psc_endpoint_format:
                    # User explicitly specified PSC endpoint format
                    # Construct full PSC/custom endpoint URL
                    if not (vertex_project and vertex_location and model):
                        raise ValueError(
                            "vertex_project, vertex_location, and model are required when use_psc_endpoint_format=True"
                        )
                    # Strip routing prefixes (bge/, gemma/, etc.) for endpoint URL construction
                    model_for_url: Final = get_vertex_base_model_name(model=model)
                    # Format: {api_base}/v1/projects/{project}/locations/{location}/endpoints/{model}:{endpoint}
                    version: Final = vertex_api_version or "v1"
                    url = "{}/{}/projects/{}/locations/{}/endpoints/{}:{}".format(
                        api_base.rstrip("/"),
                        version,
                        vertex_project,
                        vertex_location,
                        model_for_url,
                        endpoint,
                    )
                elif urlparse(api_base).path in ("", "/"):
                    url = api_base.rstrip("/") + urlparse(url).path
                else:
                    url = f"{api_base}:{endpoint}"

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Provide vertex_project, vertex_location, and model when use_psc_endpoint_format=True.
  2. Set them via parameters or the VERTEXAI_PROJECT / VERTEXAI_LOCATION environment variables.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:653 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/5b4be3e6cf706b4a. Report an issue: GitHub.