Registry / gcp / vertexai

vertexai

JSON →
library1.71.1pypypi✓ verified 28d ago

Google Cloud Vertex AI SDK for Python. Two separate PyPI packages exist: google-cloud-aiplatform (GAPIC clients, full Vertex AI platform) and vertexai (higher-level SDK, same underlying package). Install is google-cloud-aiplatform, import is vertexai — classic name mismatch. Generative AI modules (vertexai.generative_models, vertexai.language_models, etc.) deprecated June 24, 2025 and will be removed June 24, 2026. Current version: google-cloud-aiplatform 1.142.0 / vertexai 1.71.1.

pip install google-cloud-aiplatform
INSTALL
IMPORT
SIG · VERTEXAI
V
vertexai
gcppythonv1.71.1
Install
20.8s avg
Import
10123ms
Disk
493MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.71.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 20.97s
py 3.11
✓ —
✓ 20.2s
py 3.12
✓ —
✓ 18.57s
py 3.13
✓ —
✓ 18.5s
py 3.9
2/3 runs
✓ 25.97s
493MB installed
● package 493MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vertexai.init
import vertexai vertexai.init( project='your-project-id', location='us-central1' )
from google.cloud import aiplatform aiplatform.init(project='your-project-id', location='us-central1')
install is google-cloud-aiplatform but import is vertexai — not google.cloud.aiplatform. Both packages coexist but vertexai is the high-level SDK. google.cloud.aiplatform is the low-level GAPIC client.
vertexai.generative_models (deprecated)
# Use google-genai for generative AI on Vertex AI from google import genai client = genai.Client( vertexai=True, project='your-project-id', location='us-central1' ) response = client.models.generate_content( model='gemini-2.5-flash', contents='Explain neural networks' ) print(response.text)
import vertexai from vertexai.generative_models import GenerativeModel vertexai.init(project='your-project', location='us-central1') model = GenerativeModel('gemini-2.5-flash') response = model.generate_content('Explain neural networks') print(response.text)
vertexai.generative_models deprecated June 24, 2025. Removed June 24, 2026. Migrate to google-genai with vertexai=True.
Application Default Credentials
import vertexai # Uses ADC automatically — run: gcloud auth application-default login vertexai.init(project='your-project-id', location='us-central1')
import vertexai vertexai.init(project='your-project-id', location='us-central1', credentials='your-api-key')
Vertex AI does not use API keys. Uses Google Cloud Application Default Credentials (ADC) or service account JSON. No api_key parameter exists on vertexai.init().

Vertex AI Gemini call using google-genai with vertexai=True (recommended path from 2025 onwards).

# For Vertex AI generative AI — use google-genai # pip install google-genai from google import genai client = genai.Client( vertexai=True, project='your-gcp-project-id', location='us-central1' ) response = client.models.generate_content( model='gemini-2.5-flash', contents='What is Vertex AI?' ) print(response.text)
Debug
Known issues
breakingInstall package is google-cloud-aiplatform but import is 'import vertexai'. LLMs consistently confuse this and generate 'from google.cloud import vertexai' or 'pip install vertexai-sdk'. Both are wrong.
fix
pip install google-cloud-aiplatform; import vertexai
affects: all
breakingvertexai.generative_models, vertexai.language_models, vertexai.vision_models, vertexai.tuning, vertexai.caching deprecated June 24, 2025. Will be removed June 24, 2026.
fix
Migrate to google-genai with vertexai=True. See migration guide at cloud.google.com/vertex-ai/generative-ai/docs/deprecations/genai-vertexai-sdk
affects: >= 1.114.0
breakingVertex AI does not use API keys. Uses Application Default Credentials (ADC). No api_key parameter. LLMs frequently hallucinate an api_key argument on vertexai.init().
fix
Run: gcloud auth application-default login. Or set GOOGLE_APPLICATION_CREDENTIALS to service account JSON path.
affects: all
gotchaTwo PyPI packages: google-cloud-aiplatform and vertexai. They install the same underlying package. Installing either gives you both namespaces. Pinning both to different versions causes conflicts.
fix
Pin only one. Prefer google-cloud-aiplatform for consistency with GCP tooling.
affects: all
gotchavertexai.init() must be called before any Vertex AI SDK calls. Forgetting this causes authentication or project resolution errors.
fix
Always call vertexai.init(project='...', location='...') at startup.
affects: all
gotchalocation parameter is required and must be a valid GCP region. 'us-central1' is most common. Wrong or missing location raises InvalidArgument errors.
fix
Always pass location='us-central1' or your preferred region.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'vertexai'
The `vertexai` SDK is part of the `google-cloud-aiplatform` package, which was not installed or installed incorrectly.
fix
pip install google-cloud-aiplatform
google.api_core.exceptions.InvalidArgument: 400 The model specified does not exist in this region.
The specified model name (e.g., `gemini-pro`) is either misspelled or not available in the Google Cloud region specified during `vertexai.init()` or model instantiation.
fix
Verify the model ID and ensure the `location` parameter in `vertexai.init()` or `GenerativeModel()` call matches a region where the model is available.
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials.
The environment lacks valid Google Cloud credentials, or the service account/user running the code does not have the necessary permissions to access Vertex AI resources.
fix
Authenticate using `gcloud auth application-default login`, set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, or ensure a service account with the 'Vertex AI User' role is active.
ValueError: Project ID must be specified
The `vertexai.init()` function could not automatically determine the Google Cloud project ID from environment variables, and it was not explicitly provided.
fix
Call `vertexai.init(project="your-project-id", location="your-region")` or set the `GCLOUD_PROJECT` environment variable.
AttributeError: 'NoneType' object has no attribute 'generate_content'
The `GenerativeModel` or `ChatSession` object was not successfully initialized, often due to an issue during its creation (e.g., invalid model name, region, or authentication failure), resulting in the variable being `None`.
fix
Ensure `vertexai.init()` is called with correct project/location, the `GenerativeModel` is instantiated with a valid model name, and verify that the model object is not `None` before attempting to call generation methods.
Upgrade
Version history
1.71.1latest on PyPI · released Oct 31, 2024
Audit
Dependencies
google-authrequiredRequired for Application Default Credentials. Installed automatically.
google-genaioptionalRequired for new generative AI features. Generative AI modules moving from vertexai to google-genai.
Agent activity
60 hits · last 30 days
node
54
OpenAI (training)
1
Resources
vertexai — pip install vertexai · libregistry