BerriAI/litellm · error · VertexAIError
Upgrade vertex ai. Run `pip install "google-cloud-aiplatform
Error message
Upgrade vertex ai. Run `pip install "google-cloud-aiplatform>=1.38"`
What it means
Raised by the Vertex Model Garden handler right after the import check: it verifies the installed `vertexai` SDK exposes the `preview.language_models` API needed for OpenAI-compatible Model Garden calls. If the version predicate fails, the installed google-cloud-aiplatform is too old (< 1.38) and lacks that preview surface. Note the guard is lenient — `hasattr(vertexai, "preview")` alone short-circuits the check — so in practice this fires mainly on very old installs where `preview` is absent entirely.
Source
Thrown at litellm/llms/vertex_ai/vertex_model_garden/main.py:97
client=None,
):
"""
Handles calling Vertex AI Model Garden Models in OpenAI compatible format
Sent to this route when `model` is in the format `vertex_ai/openai/{MODEL_ID}`
"""
try:
import vertexai
from litellm.llms.openai_like.chat.handler import OpenAILikeChatHandler
except Exception as e:
raise VertexAIError(
status_code=400,
message=f"""vertexai import failed please run `pip install -U "google-cloud-aiplatform>=1.38"`. Got error: {e}""",
)
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:
model = get_vertex_base_model_name(model=model)
access_token, project_id = self._ensure_access_token(
credentials=vertex_credentials,
project_id=vertex_project,
custom_llm_provider="vertex_ai",
)
openai_like_chat_completions: Final = OpenAILikeChatHandler()
## CONSTRUCT API BASE
# Skip _check_custom_proxy: its ":verb" URL construction corrupts a
# user-supplied api_base (e.g. Vertex MG dedicated endpoint), and
# OpenAILikeChatHandler already appends "/chat/completions".View on GitHub (pinned to 77b7c6c40c)
Solutions
- pip install -U "google-cloud-aiplatform>=1.38".
- If a hard pin blocks the upgrade, relax the constraint in requirements.txt/lockfile (check pip check for conflicts).
- Verify with python -c "import vertexai; print(vertexai.preview.language_models)" that the preview API is present.
- Rebuild Docker/CI images after the upgrade so stale layers don't re-inject the old SDK.
Example fix
# requirements.txt # before google-cloud-aiplatform==1.35.0 # after google-cloud-aiplatform>=1.38
Defensive patterns
Strategy: validation
Validate before calling
def vertexai_version_ok() -> bool:
try:
import vertexai
return hasattr(vertexai, "preview")
except Exception:
return False
assert vertexai_version_ok(), "Upgrade: pip install -U 'google-cloud-aiplatform>=1.38'" Try / catch
try:
litellm.completion(model="vertex_ai/openai/...", messages=msgs)
except VertexAIError as e:
if "Upgrade vertex ai" in str(e):
raise RuntimeError("Incompatible google-cloud-aiplatform version — upgrade to >=1.38") from e
raise Prevention
- Pin google-cloud-aiplatform>=1.38,<next-major in requirements to prevent stale pins from other tools.
- Run `pip check` in CI to catch dependency conflicts on google packages.
- Test model-garden routes in CI against the same image versions you deploy.
When it happens
Trigger: Using a model of the form vertex_ai/openai/{MODEL_ID} with google-cloud-aiplatform pinned below 1.38 (common in lockfiles/requirements that were generated before the SDK matured), where `vertexai` imports fine but has no `preview` attribute.
Common situations: Corporate environments pinning google-cloud-aiplatform==1.35.x for other tooling; base images like old airflow/python templates shipping stale SDKs; upgrading litellm but not the google extras.
Related errors
- vertexai import failed please run `pip install -U "google-cl
- vertexai.rag module not found. Vertex AI RAG requires google
- {e}
- azure-identity is required for Azure AD Redis authentication
- google-cloud-iam is required for GCP IAM Redis authenticatio
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/a578f59e67e7853c.
Report an issue: GitHub.