BerriAI/litellm · error · VertexAIError

vertexai import failed please run `pip install google-cloud-

Error message

vertexai import failed please run `pip install google-cloud-aiplatform`. This is required for the 'vertex_ai/' route on LiteLLM

What it means

VertexAIError (400) raised when 'import vertexai' fails in the non-Gemini handler (legacy PaLM / Model Garden route). The SDK simply is not installed in the environment, and the message gives the install command.

Source

Thrown at litellm/llms/vertex_ai/vertex_ai_non_gemini.py:101

    vertex_project=None,
    vertex_location=None,
    vertex_credentials=None,
    litellm_params=None,
    logger_fn=None,
    acompletion: bool = False,
):
    """
    NON-GEMINI/ANTHROPIC CALLS.

    This is the handler for OLDER PALM MODELS and VERTEX AI MODEL GARDEN

    For Vertex AI Anthropic: `vertex_anthropic.py`
    For Gemini: `vertex_httpx.py`
    """
    try:
        import vertexai
    except Exception:
        raise VertexAIError(
            status_code=400,
            message="vertexai import failed please run `pip install google-cloud-aiplatform`. This is required for the 'vertex_ai/' route on LiteLLM",
        )

    if not (hasattr(vertexai, "preview") or hasattr(vertexai.preview, "language_models")):
        raise VertexAIError(
            status_code=400,
            message="""Upgrade vertex ai. Run `pip install "google-cloud-aiplatform>=1.38"`""",
        )
    try:
        import google.auth
        from google.cloud import aiplatform
        from google.cloud.aiplatform_v1beta1.types import (
            content as gapic_content_types,
        )
        from google.protobuf import json_format
        from google.protobuf.struct_pb2 import Value
        from vertexai.language_models import CodeGenerationModel, TextGenerationModel

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Install the Vertex AI SDK: pip install google-cloud-aiplatform.
  2. Ensure the package is installed into the same environment/interpreter that runs litellm, then retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/vertex_ai_non_gemini.py:101 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/af8da4bafcc229c0. Report an issue: GitHub.