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
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Vertex AI API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
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
. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
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. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Vertex AI API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
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
. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
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
Package cloud.google.com/go/vertexai (recommended)
Samples for using this package are available, in the
golang-samples
GitHub repository in the top-levelvertexai
directory:Package cloud.google.com/go/aiplatform
Samples for using this package are available, in the
golang-samples
GitHub repository in the top-levelaiplatform
directory:
Client library documentation
For more information about the library, see the Vertex AI client library for Go documentation:
Package cloud.google.com/go/vertexai (recommended)
- Vertex AI
cloud.google.com/go/vertexai
API reference
- Vertex AI
Package cloud.google.com/go/aiplatform
- Vertex AI
cloud.google.com/go/aiplatform
v1 API reference - Vertex AI
cloud.google.com/go/aiplatform
v1beta1 API reference
- Vertex AI