Google Cloud Platform logo

Cloud AutoML: Node.js Client

release level npm version codecov

Cloud AutoML API client for Node.js

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Cloud AutoML API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/automl

Using the client library

  const automl = require('@google-cloud/automl');
  const fs = require('fs');

  // Create client for prediction service.
  const client = new automl.PredictionServiceClient();

  /**
   * TODO(developer): Uncomment the following line before running the sample.
   */
  // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`;
  // const computeRegion = `region-name, e.g. "us-central1"`;
  // const modelId = `id of the model, e.g. “ICN723541179344731436”`;
  // const filePath = `local text file path of content to be classified, e.g. "./resources/flower.png"`;
  // const scoreThreshold = `value between 0.0 and 1.0, e.g. "0.5"`;

  // Get the full path of the model.
  const modelFullId = client.modelPath(projectId, computeRegion, modelId);

  // Read the file content for prediction.
  const content = fs.readFileSync(filePath, 'base64');

  const params = {};

  if (scoreThreshold) {
    params.score_threshold = scoreThreshold;
  }

  // Set the payload by giving the content and type of the file.
  const payload = {};
  payload.image = {imageBytes: content};

  // params is additional domain-specific parameters.
  // currently there is no additional parameters supported.
  const [response] = await client.predict({
    name: modelFullId,
    payload: payload,
    params: params,
  });
  console.log(`Prediction results:`);
  response.payload.forEach(result => {
    console.log(`Predicted class name: ${result.displayName}`);
    console.log(`Predicted class score: ${result.classification.score}`);
  });

Samples

Samples are in the samples/ directory. The samples' README.md has instructions for running the samples.

Sample Source Code Try it
Quickstart source code Open in Cloud Shell

The Cloud AutoML Node.js Client API Reference documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be in beta. This means it is expected to be mostly stable while we work toward a general availability release; however, complete stability is not guaranteed. We will address issues and requests against beta libraries with a high priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

google

google.cloud

google.cloud.automl

google.cloud.automl.v1beta1

google.cloud.automl.v1beta1
google.cloud.automl.v1beta1.AnnotationPayload
google.cloud.automl.v1beta1.AnnotationSpec
google.cloud.automl.v1beta1.ArrayStats
google.cloud.automl.v1beta1.BatchPredictInputConfig
google.cloud.automl.v1beta1.BatchPredictOutputConfig
google.cloud.automl.v1beta1.BatchPredictRequest
google.cloud.automl.v1beta1.BatchPredictResult
google.cloud.automl.v1beta1.BigQueryDestination
google.cloud.automl.v1beta1.BigQuerySource
google.cloud.automl.v1beta1.BoundingBoxMetricsEntry
google.cloud.automl.v1beta1.BoundingPoly
google.cloud.automl.v1beta1.CategoryStats
google.cloud.automl.v1beta1.ClassificationAnnotation
google.cloud.automl.v1beta1.ClassificationEvaluationMetrics
google.cloud.automl.v1beta1.ClassificationType
google.cloud.automl.v1beta1.ColumnSpec
google.cloud.automl.v1beta1.ConfidenceMetricsEntry
google.cloud.automl.v1beta1.ConfusionMatrix
google.cloud.automl.v1beta1.CorrelatedColumn
google.cloud.automl.v1beta1.CorrelationStats
google.cloud.automl.v1beta1.CreateDatasetRequest
google.cloud.automl.v1beta1.CreateModelRequest
google.cloud.automl.v1beta1.Dataset
google.cloud.automl.v1beta1.DataStats
google.cloud.automl.v1beta1.DataType
google.cloud.automl.v1beta1.DeleteDatasetRequest
google.cloud.automl.v1beta1.DeleteModelRequest
google.cloud.automl.v1beta1.DeploymentState
google.cloud.automl.v1beta1.DeployModelRequest
google.cloud.automl.v1beta1.Document
google.cloud.automl.v1beta1.DocumentInputConfig
google.cloud.automl.v1beta1.DoubleRange
google.cloud.automl.v1beta1.ExamplePayload
google.cloud.automl.v1beta1.ExportDataRequest
google.cloud.automl.v1beta1.ExportEvaluatedExamplesOutputConfig
google.cloud.automl.v1beta1.ExportEvaluatedExamplesRequest
google.cloud.automl.v1beta1.ExportModelRequest
google.cloud.automl.v1beta1.Float64Stats
google.cloud.automl.v1beta1.GcrDestination
google.cloud.automl.v1beta1.GcsDestination
google.cloud.automl.v1beta1.GcsSource
google.cloud.automl.v1beta1.GetAnnotationSpecRequest
google.cloud.automl.v1beta1.GetColumnSpecRequest
google.cloud.automl.v1beta1.GetDatasetRequest
google.cloud.automl.v1beta1.GetModelEvaluationRequest
google.cloud.automl.v1beta1.GetModelRequest
google.cloud.automl.v1beta1.GetTableSpecRequest
google.cloud.automl.v1beta1.GranularStats
google.cloud.automl.v1beta1.HistogramBucket
google.cloud.automl.v1beta1.Image
google.cloud.automl.v1beta1.ImageClassificationDatasetMetadata
google.cloud.automl.v1beta1.ImageClassificationModelMetadata
google.cloud.automl.v1beta1.ImageObjectDetectionAnnotation
google.cloud.automl.v1beta1.ImageObjectDetectionDatasetMetadata
google.cloud.automl.v1beta1.ImageObjectDetectionEvaluationMetrics
google.cloud.automl.v1beta1.ImageObjectDetectionModelDeploymentMetadata
google.cloud.automl.v1beta1.ImageObjectDetectionModelMetadata
google.cloud.automl.v1beta1.ImportDataRequest
google.cloud.automl.v1beta1.InputConfig
google.cloud.automl.v1beta1.ListColumnSpecsRequest
google.cloud.automl.v1beta1.ListColumnSpecsResponse
google.cloud.automl.v1beta1.ListDatasetsRequest
google.cloud.automl.v1beta1.ListDatasetsResponse
google.cloud.automl.v1beta1.ListModelEvaluationsRequest
google.cloud.automl.v1beta1.ListModelEvaluationsResponse
google.cloud.automl.v1beta1.ListModelsRequest
google.cloud.automl.v1beta1.ListModelsResponse
google.cloud.automl.v1beta1.ListTableSpecsRequest
google.cloud.automl.v1beta1.ListTableSpecsResponse
google.cloud.automl.v1beta1.Model
google.cloud.automl.v1beta1.ModelEvaluation
google.cloud.automl.v1beta1.ModelExportOutputConfig
google.cloud.automl.v1beta1.NormalizedVertex
google.cloud.automl.v1beta1.OutputConfig
google.cloud.automl.v1beta1.PredictRequest
google.cloud.automl.v1beta1.PredictResponse
google.cloud.automl.v1beta1.RegressionEvaluationMetrics
google.cloud.automl.v1beta1.Row
google.cloud.automl.v1beta1.SingleCategoryStats
google.cloud.automl.v1beta1.StringStats
google.cloud.automl.v1beta1.StructStats
google.cloud.automl.v1beta1.StructType
google.cloud.automl.v1beta1.TablesAnnotation
google.cloud.automl.v1beta1.TablesDatasetMetadata
google.cloud.automl.v1beta1.TablesModelColumnInfo
google.cloud.automl.v1beta1.TablesModelMetadata
google.cloud.automl.v1beta1.TableSpec
google.cloud.automl.v1beta1.TextClassificationDatasetMetadata
google.cloud.automl.v1beta1.TextClassificationModelMetadata
google.cloud.automl.v1beta1.TextExtractionAnnotation
google.cloud.automl.v1beta1.TextExtractionDatasetMetadata
google.cloud.automl.v1beta1.TextExtractionEvaluationMetrics
google.cloud.automl.v1beta1.TextExtractionModelMetadata
google.cloud.automl.v1beta1.TextSegment
google.cloud.automl.v1beta1.TextSentimentAnnotation
google.cloud.automl.v1beta1.TextSentimentDatasetMetadata
google.cloud.automl.v1beta1.TextSentimentEvaluationMetrics
google.cloud.automl.v1beta1.TextSentimentModelMetadata
google.cloud.automl.v1beta1.TextSnippet
google.cloud.automl.v1beta1.TimeSegment
google.cloud.automl.v1beta1.TimestampStats
google.cloud.automl.v1beta1.TranslationAnnotation
google.cloud.automl.v1beta1.TranslationDatasetMetadata
google.cloud.automl.v1beta1.TranslationEvaluationMetrics
google.cloud.automl.v1beta1.TranslationModelMetadata
google.cloud.automl.v1beta1.TypeCode
google.cloud.automl.v1beta1.UndeployModelRequest
google.cloud.automl.v1beta1.UnigramStats
google.cloud.automl.v1beta1.UpdateColumnSpecRequest
google.cloud.automl.v1beta1.UpdateDatasetRequest
google.cloud.automl.v1beta1.UpdateTableSpecRequest
google.cloud.automl.v1beta1.VideoClassificationAnnotation
google.cloud.automl.v1beta1.VideoClassificationDatasetMetadata
google.cloud.automl.v1beta1.VideoClassificationModelMetadata
google.cloud.automl.v1beta1.VideoObjectTrackingAnnotation
google.cloud.automl.v1beta1.VideoObjectTrackingDatasetMetadata
google.cloud.automl.v1beta1.VideoObjectTrackingEvaluationMetrics
google.cloud.automl.v1beta1.VideoObjectTrackingModelMetadata

v1beta1.AutoMlClient

v1beta1.AutoMlClient#importData(request[, options][, callback])
v1beta1.AutoMlClient#listColumnSpecs(request[, options][, callback])
v1beta1.AutoMlClient#listColumnSpecsStream(request[, options])
v1beta1.AutoMlClient#listDatasets(request[, options][, callback])
v1beta1.AutoMlClient#listDatasetsStream(request[, options])
v1beta1.AutoMlClient#listModelEvaluations(request[, options][, callback])
v1beta1.AutoMlClient#listModelEvaluationsStream(request[, options])
v1beta1.AutoMlClient#listModels(request[, options][, callback])
v1beta1.AutoMlClient#listModelsStream(request[, options])
v1beta1.AutoMlClient#listTableSpecs(request[, options][, callback])
v1beta1.AutoMlClient#listTableSpecsStream(request[, options])
v1beta1.AutoMlClient#locationPath(project, location)
v1beta1.AutoMlClient#matchAnnotationSpecFromAnnotationSpecName(annotationSpecName)
v1beta1.AutoMlClient#matchColumnSpecFromColumnSpecName(columnSpecName)
v1beta1.AutoMlClient#matchDatasetFromAnnotationSpecName(annotationSpecName)
v1beta1.AutoMlClient#matchDatasetFromColumnSpecName(columnSpecName)
v1beta1.AutoMlClient#matchDatasetFromDatasetName(datasetName)
v1beta1.AutoMlClient#matchDatasetFromTableSpecName(tableSpecName)
v1beta1.AutoMlClient#matchLocationFromAnnotationSpecName(annotationSpecName)
v1beta1.AutoMlClient#matchLocationFromColumnSpecName(columnSpecName)
v1beta1.AutoMlClient#matchLocationFromDatasetName(datasetName)
v1beta1.AutoMlClient#matchLocationFromLocationName(locationName)
v1beta1.AutoMlClient#matchLocationFromModelEvaluationName(modelEvaluationName)