Introduction to the Vertex AI SDK for Python

The Vertex AI SDK for Python helps you automate data ingestion, train models, andget predictions on Vertex AI. The Vertex AI SDK uses Python code toaccess the Vertex AI API so that you can programmatically accomplish most of whatyou can do in the Google Cloud console.

To learn how to install or update the Vertex AI SDK for Python, seeInstall theVertex AI SDK for Python. For more information, seetheVertex AI SDK for Python API reference documentation.

Why use the Vertex AI SDK

The Vertex AI SDK for Python is recommended if you're an experienced machinelearning (ML) and artificial intelligence (AI) engineer or a data scientist whowants to programmatically automate your workflow. The Vertex AI SDK for Python issimilar to the Vertex AI Python client library, except theVertex AI SDK is higher-level and less granular. For more information, seeUnderstand the SDK and client library differences.

Write code with the Vertex AI SDK for Python

To use the Vertex AI SDK for Python:

  1. Install thegoogle-cloud-aiplatform package, which includes both the Vertex AI SDK for Python and the Vertex AI Python client library, by running the following command in your virtual environment:

    pipinstall--upgradegoogle-cloud-aiplatform
  2. Use the following code to import thegoogle.cloud.aiplatform namespace:

    fromgoogle.cloudimportaiplatform
    Preview: To use features for the Vertex AI SDK for Python that are still inpreview, importvertexai.preview:
    importvertexai.preview

  3. If you're using a local shell, then create local authentication credentials for your user account:

    gcloudauthapplication-defaultlogin

    You don't need to do this if you're using Cloud Shell.

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

Learn about the Vertex AI SDK for Python

See the following documentation:

  • Vertex AI SDK class overview: introduces the key classes and functionality in the Vertex AI SDK.

  • Python reference for Vertex AI: contains reference documentation for all of the namespaces, classes, methods, and properties in thegoogle-cloud-aiplatform package, which includes the Vertex AI SDK, the Vertex AI SDK preview, and the Vertex AI Client libraries.

Try code samples and tutorials

Notebook tutorials show how to use the Vertex AI SDK for Python as part of alarger workflow. For more information, seeVertex AI notebook tutorials.

Code samples in the Vertex AI SDK for Python GitHub repository show you how tocomplete individual tasks. For more information, see theVertex AI SDK for Python GitHub repository.

Understand the Vertex AI SDK and client library differences

When you install the Vertex AI SDK for Python, the Vertex AI Python clientlibrary is also installed. The Vertex AI SDK and theVertex AI Python client library provide similar functionality withdifferent levels of granularity. The Vertex AI SDK operates at ahigher level of abstraction than the client library and is suitable for mostcommon data science workflows. If you need lower-level functionality, then usethe Vertex AI Python client library.

The Vertex AI SDK is available for Python and a Vertex AI clientlibrary is available for Python, Java, and Node.js. To learn how to install theJava or Node.js client library, seeInstall the Vertex AI client libraries.If a client library isn't available in your preferred programming language, youcan use the Vertex AI REST API. For more information, see theVertex AI REST reference.

Use Vertex AI Python client library and SDK together

If you use the Vertex AI SDK for Python and discover you need greater flexibilityor control, or if you need a method not included in the Vertex AI SDK, youcan use the Vertex AI Python client library in the same workflow. TheVertex AI Python client library uses a different namespace to access theVertex AI API. The client library and the Vertex AI SDK for Pythonnamespaces can be used in the same Python script by adding animport line foreach in your Python script.

Import the Vertex AI Python client library namespace

The Vertex AI Python client library namespace isgoogle.cloud.aiplatform.gapic. This namespace maps to thegoogle.cloud.aiplatform_v1 namespace. These two namespaces can be usedinterchangeably. To import the Python client library, include one of thefollowing in your Python script:

from google.cloud import aiplatform_v1
from google.cloud.aiplatform import gapic

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.