Introduction to the Agent Platform SDK for Python

The Agent Platform SDK for Python helps you automate data ingestion, train models, and get predictions on Gemini Enterprise Agent Platform. The Agent Platform SDK uses Python code to access the Agent Platform 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 Agent Platform SDK for Python, see Install the Agent Platform SDK for Python. For more information, see the Agent Platform SDK for Python API reference documentation.

Why use the Agent Platform SDK

The Agent Platform 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 Agent Platform SDK for Python is similar to the Gemini Enterprise Agent Platform Python client library, except the Agent Platform SDK is higher-level and less granular. For more information, see Understand the SDK and client library differences.

Write code with the Agent Platform SDK for Python

To use the Agent Platform SDK for Python:

  1. Install the google-cloud-aiplatform package, which includes both the Agent Platform SDK for Python and the Gemini Enterprise Agent Platform 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
    

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

    gcloud auth application-default login

    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 Agent Platform SDK for Python

See the following documentation:

Try code samples and tutorials

Notebook tutorials show how to use the Agent Platform SDK for Python as part of a larger workflow. For more information, see Gemini Enterprise Agent Platform notebook tutorials.

Code samples in the Agent Platform SDK for Python GitHub repository show you how to complete individual tasks. For more information, see the Agent Platform SDK for Python GitHub repository.

Understand the Agent Platform SDK and client library differences

When you install the Agent Platform SDK for Python, the Gemini Enterprise Agent Platform Python client library is also installed. The Agent Platform SDK and the Gemini Enterprise Agent Platform Python client library provide similar functionality with different levels of granularity. The Agent Platform 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 Gemini Enterprise Agent Platform Python client library.

The Agent Platform SDK is available for Python and a Gemini Enterprise Agent Platform 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 Gemini Enterprise Agent Platform client libraries. If a client library isn't available in your preferred programming language, you can use the Gemini Enterprise Agent Platform REST API. For more information, see the Gemini Enterprise Agent Platform REST reference.

Use Gemini Enterprise Agent Platform Python client library and SDK together

If you use the Agent Platform SDK for Python and discover you need greater flexibility or control, or if you need a method not included in the Agent Platform SDK, you can use the Gemini Enterprise Agent Platform Python client library in the same workflow. The Gemini Enterprise Agent Platform Python client library uses a different namespace to access the Agent Platform API. The client library and the Agent Platform 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 Gemini Enterprise Agent Platform Python client library namespace

The Gemini Enterprise Agent Platform 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