Google.Cloud.AIPlatform.V1

Google.Cloud.AIPlatform.V1 is a.NET client library for the Cloud AI Platform API.

Note: This documentation is for version 2.22.0 of the library. Some samples may not work with other versions.

Install the Google.Cloud.AIPlatform.V1 package from NuGet. Add it to your project in the normal way (for example by right-clicking on the project in Visual Studio and choosing "Manage NuGet Packages...").

When running on Google Cloud, no action needs to be taken to authenticate.

Otherwise, the simplest way of authenticating your API calls is to set up Application Default Credentials. The credentials will automatically be used to authenticate. See Set up Application Default Credentials for more details.

Getting started

All operations are performed through the following client classes:

Clients in this API must be constructed with a regional endpoint. This can be done easily using the builder for a specific client (DatasetServiceClientBuilder for DatasetServiceClient for example). The following example shows how to list the datasets for a given project in the us-central1 region.

string region = "us-central1";
DatasetServiceClient client = new DatasetServiceClientBuilder
{
   
Endpoint = $"{region}-aiplatform.googleapis.com"
}.Build();

LocationName location = new LocationName(projectId, region);
PagedEnumerable<ListDatasetsResponse, Dataset> datasets = client.ListDatasets(location);
foreach (Dataset dataset in datasets)
{
   
Console.WriteLine(dataset.Name);
}

Constructing schema values

Various aspects of the API use schemas which are represented using Google.Protobuf.WellKnownTypes.Value, which is a generic representation of a JSON value in Protocol Buffers.

Protocol Buffer messages are available for these schemas, and they can be converted to and from Value objects using the ValueConverter class, as shown below.

AutoMlImageClassificationInputs inputs = new AutoMlImageClassificationInputs
{
   
ModelType = AutoMlImageClassificationInputs.Types.ModelType.Cloud,
   
BaseModelId = "model-id",
   
// Other properties
};
TrainingPipeline pipeline = new TrainingPipeline
{
   
TrainingTaskInputs = ValueConverter.ToValue(inputs)
};
// Use pipeline in API calls such as PipelineServiceClient.CreateTrainingPipeline.