Introduction to the Vertex AI SDK for Python

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

To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Vertex 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 machine learning (ML) and artificial intelligence (AI) engineer or a data scientist who wants to programmatically automate your workflow. The Vertex AI SDK for Python is similar to the Vertex AI Python client library, except the Vertex AI SDK is higher-level and less granular. For more information, see Understand 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 the google-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:

    pip install --upgrade google-cloud-aiplatform
    
  2. Use the following code to import the google.cloud.aiplatform namespace:

    from google.cloud import aiplatform
    

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 the google-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

Jupyter notebook tutorials show how to use the Vertex AI SDK for Python as part of a larger workflow. For more information, see Vertex AI notebook tutorials.

Code samples in the Vertex AI SDK for Python GitHub repository show you how to complete individual tasks. For more information, see the Vertex 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 client library is also installed. The Vertex AI SDK and the Vertex AI Python client library provide similar functionality with different levels of granularity. The Vertex AI SDK operates at a higher level of abstraction than the client library and is suitable for most common data science workflows. If you need lower-level functionality, then use the Vertex AI Python client library.

The Vertex AI SDK is available for Python and a Vertex AI client library is available for Python, Java, and Node.js. To learn how to install the Java or Node.js client library, see Install the Vertex AI client libraries. If a client library isn't available in your preferred programming language, you can use the Vertex AI REST API. For more information, see the Vertex 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 flexibility or control, or if you need a method not included in the Vertex AI SDK, you can use the Vertex AI Python client library in the same workflow. The Vertex AI Python client library uses a different namespace to access the Vertex AI API. The client library and the Vertex AI SDK for Python namespaces can be used in the same Python script by adding an import line for each in your Python script.

Import the Vertex AI Python client library namespace

The Vertex AI Python client library namespace is google.cloud.aiplatform.gapic. This namespace maps to the google.cloud.aiplatform_v1 namespace. These two namespaces can be used interchangeably. To import the Python client library, include one of the following in your Python script:

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

What's next