Creating a product set resource

A product set is a simple container for a group of products.

We recommend a single product set for all of your items. You can create additional product sets for testing.


To create a product set, send a POST to the{parent=projects/*/locations/*}/productSets endpoint in the following format.

  • Replace project-id with the id of your Google Cloud Platform (GCP) project.

  • Replace location-id with a valid location identifier. Valid location identifiers are: us-west1, us-east1, europe-west1, and asia-east1.

  • Replace display-name with the display name for your new product set.

   'displayName' : 'display-name'


from import vision_v1p3beta1 as vision

def create_product_set(
        project_id, location, product_set_id, product_set_display_name):
    """Create a product set.
        project_id: Id of the project.
        location: A compute region name.
        product_set_id: Id of the product set.
        product_set_display_name: Display name of the product set.
    client = vision.ProductSearchClient()

    # A resource that represents Google Cloud Platform location.
    location_path = client.location_path(
        project=project_id, location=location)

    # Create a product set with the product set specification in the region.
    product_set = vision.types.ProductSet(

    # The response is the product set with `name` populated.
    response = client.create_product_set(

    # Display the product set information.
    print('Product set name: {}'.format(


 * Create a product set
 * @param projectId - Id of the project.
 * @param computeRegion - Region name.
 * @param productSetId - Id of the product set.
 * @param productSetDisplayName - Display name of the product set.
 * @throws IOException - on I/O errors.
public static void createProductSet(
    String projectId, String computeRegion, String productSetId, String productSetDisplayName)
    throws IOException {
  ProductSearchClient client = ProductSearchClient.create();

  // A resource that represents Google Cloud Platform location.
  LocationName projectLocation = LocationName.of(projectId, computeRegion);

  // Create a product set with the product set specification in the region.
  ProductSet myProductSet = ProductSet.newBuilder().setDisplayName(productSetDisplayName).build();
  CreateProductSetRequest request =
  ProductSet productSet = client.createProductSet(request);

  // Display the product set information
  System.out.println(String.format("Product set name: %s", productSet.getName()));



// Imports the Google Cloud client library
const vision = require('@google-cloud/vision').v1p3beta1;

// Creates a client
const client = new vision.ProductSearchClient();

 * TODO(developer): Uncomment the following line before running the sample.
// const projectId = 'Your Google Cloud project Id';
// const location = 'A compute region name';
// const productSetId = 'Id of the product set';
// const productSetDisplayName = 'Display name of the product set';

// Resource path that represents Google Cloud Platform location.
const locationPath = client.locationPath(projectId, location);

const productSet = {
  displayName: productSetDisplayName,

const request = {
  parent: locationPath,
  productSet: productSet,
  productSetId: productSetId,

  .then(results => {
    // The response is the product set with the `name` field populated
    const createdProductSet = results[0];
    console.log(`Product Set name: ${}`);
  .catch(err => {
    console.error('ERROR:', err);

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Vision API
Need help? Visit our support page.