Install the Vertex AI client libraries

Client libraries provide an optimized developer experience for calling the Vertex AI API. The client libraries use each supported language's natural conventions and reduce boilerplate code that you have to write. The following guide explains how to install them.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Enable the Vertex AI API.

    Enable the API

  4. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  5. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  6. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.

  7. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  8. Enable the Vertex AI API.

    Enable the API

  9. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  10. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  11. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.

Client libraries

Vertex AI provides client libraries for the following languages. Select the language that you want to use.

C#

Run the following command to add the Google.Cloud.AIPlatform.V1 package reference to your project file:

dotnet add package Google.Cloud.AIPlatform.V1

Try code samples

To view or get individual code samples, go to the dotnet-aiplatform GitHub repository.

Client library documentation

For more information, view the Vertex AI .NET client library documentation.

Java

If you are using Maven, add the following to your dependencies:

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-aiplatform</artifactId>
  <version>3.35.0</version>
</dependency>

If you are using Gradle, add the following to your dependencies:

compile 'com.google.cloud:google-cloud-aiplatform:3.35.0'

If you are using sbt, add the following to your dependencies:

libraryDependencies += "com.google.cloud" % "google-cloud-aiplatform" % "3.35.0"

Try code samples

To view or get individual code samples, go to the java-aiplatform GitHub repository.

Client library documentation

For more information, view the Vertex AI client library for Java documentation.

Node.js

Before installing the library, prepare your environment for Node.js development.

Run the following command in your environment to install the client library:

npm install @google-cloud/aiplatform

Client library documentation

For more information, view the Vertex AI client library for Node.js documentation.

Python

The Vertex AI Python client library is installed when you install the Vertex AI SDK for Python.

For more information, see Install the Vertex AI SDK for Python.

Go

Before installing the library, prepare your environment for Go development.

Review available packages

Review the available Vertex AI API Go packages to determine which package best meets your project's needs:

  • Package cloud.google.com/go/vertexai (recommended)

    vertexai is a human authored package that provides access to common capabilities and features.

    This package is recommended as the starting point for most developers building with the Vertex AI API. To access capabilities and features not yet covered by this package, use the auto-generated aiplatform instead.

  • Package cloud.google.com/go/aiplatform

    aiplatform is an auto-generated package.

    This package is intended for projects that require access to Vertex AI API capabilities and features not yet provided by the human authored vertexai package.

Installation

  • Package cloud.google.com/go/vertexai (recommended)

    Run the following command to install this package in your environment:

    go get cloud.google.com/go/vertexai
    
  • Package cloud.google.com/go/aiplatform

    Run the following command to install this package in your environment:

    go get cloud.google.com/go/aiplatform
    

Samples

Client library documentation

For more information about the library, see the Vertex AI client library for Go documentation: