{"record":{"id":"a578f59e67e7853c","repo":"BerriAI/litellm","slug":"upgrade-vertex-ai-run-pip-install-google-cloud-a578f5","errorCode":null,"errorMessage":"Upgrade vertex ai. Run `pip install \"google-cloud-aiplatform>=1.38\"`","messagePattern":"Upgrade vertex ai\\. Run `pip install \"google-cloud-aiplatform>=1\\.38\"`","errorType":"http","errorClass":"VertexAIError","httpStatus":400,"severity":"error","filePath":"litellm/llms/vertex_ai/vertex_model_garden/main.py","lineNumber":97,"sourceCode":"        client=None,\n    ):\n        \"\"\"\n        Handles calling Vertex AI Model Garden Models in OpenAI compatible format\n\n        Sent to this route when `model` is in the format `vertex_ai/openai/{MODEL_ID}`\n        \"\"\"\n        try:\n            import vertexai\n\n            from litellm.llms.openai_like.chat.handler import OpenAILikeChatHandler\n        except Exception as e:\n            raise VertexAIError(\n                status_code=400,\n                message=f\"\"\"vertexai import failed please run `pip install -U \"google-cloud-aiplatform>=1.38\"`. Got error: {e}\"\"\",\n            )\n\n        if not (hasattr(vertexai, \"preview\") or hasattr(vertexai.preview, \"language_models\")):\n            raise VertexAIError(\n                status_code=400,\n                message=\"\"\"Upgrade vertex ai. Run `pip install \"google-cloud-aiplatform>=1.38\"`\"\"\",\n            )\n        try:\n            model = get_vertex_base_model_name(model=model)\n\n            access_token, project_id = self._ensure_access_token(\n                credentials=vertex_credentials,\n                project_id=vertex_project,\n                custom_llm_provider=\"vertex_ai\",\n            )\n\n            openai_like_chat_completions: Final = OpenAILikeChatHandler()\n\n            ## CONSTRUCT API BASE\n            # Skip _check_custom_proxy: its \":verb\" URL construction corrupts a\n            # user-supplied api_base (e.g. Vertex MG dedicated endpoint), and\n            # OpenAILikeChatHandler already appends \"/chat/completions\".","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/vertex_model_garden/main.py#L79-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# requirements.txt\n# before\ngoogle-cloud-aiplatform==1.35.0\n\n# after\ngoogle-cloud-aiplatform>=1.38","handlingStrategy":"validation","validationCode":"def vertexai_version_ok() -> bool:\n    try:\n        import vertexai\n        return hasattr(vertexai, \"preview\")\n    except Exception:\n        return False\n\nassert vertexai_version_ok(), \"Upgrade: pip install -U 'google-cloud-aiplatform>=1.38'\"","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"vertex_ai/openai/...\", messages=msgs)\nexcept VertexAIError as e:\n    if \"Upgrade vertex ai\" in str(e):\n        raise RuntimeError(\"Incompatible google-cloud-aiplatform version — upgrade to >=1.38\") from e\n    raise","preventionTips":["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."],"tags":["vertex-ai","model-garden","version-mismatch","dependency"],"backgroundTag":"dependency-version-mismatch","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}