Google Cloud AI Platform Python Client Library

raw JSON →
1.143.0 verified Tue May 12 auth: no python install: verified quickstart: stale

The Google Cloud AI Platform Python Client Library provides a set of tools for interacting with Vertex AI services, enabling users to build, deploy, and manage machine learning models on Google Cloud. As of version 1.143.0, released on March 25, 2026, the library continues to evolve with regular updates to enhance functionality and performance.

pip install google-cloud-aiplatform
error ModuleNotFoundError: No module named 'google.cloud.aiplatform'
cause The `google-cloud-aiplatform` library is not installed in the active Python environment, or the environment where it's installed is not the one being used.
fix
Ensure the library is installed in your environment by running: pip install google-cloud-aiplatform.
error ImportError: cannot import name 'aiplatform' from 'google.cloud'
cause This error often occurs when the `google-cloud-aiplatform` package is missing, improperly installed, or there's a version conflict with other `google-cloud` packages in the Python environment.
fix
Upgrade the library and its dependencies: pip install --upgrade google-cloud-aiplatform or pip install google-cloud-aiplatform --force-reinstall.
error 403 PERMISSION_DENIED: Client doesn't have sufficient permission to call the API.
cause The authenticated service account or user lacks the necessary IAM roles (e.g., 'Vertex AI User') to access the Vertex AI API or specific resources within your Google Cloud project, or the Vertex AI API is not enabled for the project.
fix
Grant the required IAM roles to your service account or user, typically 'Vertex AI User' at minimum, and ensure the 'Vertex AI API' is enabled in your Google Cloud Project's API Library. Authenticate correctly, often via gcloud auth application-default login for local development.
error 404 Not Found: Publisher Model projects/[PROJECT_ID]/locations/[REGION]/publishers/google/models/[MODEL_NAME] was not found or your project does not have access to it.
cause The requested model name, project ID, or region is incorrect, the model is not available in that region, or the project/account lacks specific access or has not enabled necessary APIs for publisher models.
fix
Verify the model name, project ID, and region in your code. Ensure the Vertex AI API is enabled and that your service account has the 'Vertex AI User' role. Some generative models may require specific regional availability or additional allowlisting by Google Cloud Support.
error com.google.cloud.ai.platform.common.errors.AiPlatformException: code=RESOURCE_EXHAUSTED, message=The following quota metrics exceed quota limits...
cause Your Google Cloud project has reached its quota limit for a specific Vertex AI resource, such as custom model training CPUs, GPUs, or API requests.
fix
Review your project's quotas for Vertex AI in the Google Cloud Console's 'Quotas' page and request an increase for the relevant metrics if needed. Implement exponential backoff and retry logic in your application to handle temporary quota spikes.
breaking Python versions <= 3.8 are deprecated and no longer supported in the latest release.
fix Upgrade your Python environment to version 3.9 or later to ensure compatibility with the latest version of the library.
gotcha Ensure that the 'google-cloud-aiplatform' package is installed in your environment to avoid ImportError.
fix Install the package using 'pip install google-cloud-aiplatform' if it's not already installed.
breaking Your default Google Cloud credentials were not found. The application requires Application Default Credentials (ADC) or explicit credentials to authenticate with Google Cloud services.
fix Set up Application Default Credentials by running `gcloud auth application-default login` or ensure appropriate service account credentials are provided to your environment or code (e.g., via `GOOGLE_APPLICATION_CREDENTIALS` environment variable).
breaking Application Default Credentials (ADC) were not found, preventing authentication with Google Cloud services.
fix Set up Application Default Credentials (ADC) in your environment. Refer to the official Google Cloud documentation for instructions: https://cloud.google.com/docs/authentication/external/set-up-adc
python os / libc status wheel install import disk
3.10 alpine (musl) - - 16.48s 240.5M
3.10 slim (glibc) - - 5.05s 237M
3.11 alpine (musl) - - 17.91s 270.8M
3.11 slim (glibc) - - 8.68s 268M
3.12 alpine (musl) - - 16.73s 258.6M
3.12 slim (glibc) - - 9.57s 256M
3.13 alpine (musl) - - 15.74s 255.8M
3.13 slim (glibc) - - 9.42s 253M
3.9 alpine (musl) - - 15.86s 236.9M
3.9 slim (glibc) - - 5.29s 234M

This quickstart guide demonstrates how to initialize the AI Platform SDK, create a TabularDataset, upload a model, and deploy it to an endpoint using environment variables for authentication.

import os
from google.cloud import aiplatform

aiplatform.init(
    project=os.environ.get('GOOGLE_CLOUD_PROJECT', 'your-project-id'),
    location='us-central1',
    staging_bucket='gs://your-staging-bucket'
)

# Example: Create a TabularDataset
my_dataset = aiplatform.TabularDataset.create(
    display_name='my-dataset',
    gcs_source=['gs://path/to/your/data.csv']
)

# Example: Train a Model
my_model = aiplatform.Model.upload(
    display_name='my-model',
    artifact_uri='gs://path/to/your/model',
    serving_container_image_uri='gcr.io/cloud-aiplatform/training/tf2-cpu.2-3:latest'
)

# Example: Deploy the Model
endpoint = my_model.deploy(
    deployed_model_display_name='my-deployed-model',
    machine_type='n1-standard-4'
)