# Method: projects.locations.models.predict

- [HTTP request](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#body.PredictResponse.SCHEMA_REPRESENTATION)
- [Authorization Scopes](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#body.aspect)
- [ExamplePayload](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#ExamplePayload)
  - [JSON representation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#ExamplePayload.SCHEMA_REPRESENTATION)
- [Image](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#Image)
  - [JSON representation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#Image.SCHEMA_REPRESENTATION)
- [TextSnippet](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TextSnippet)
  - [JSON representation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TextSnippet.SCHEMA_REPRESENTATION)
- [AnnotationPayload](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#AnnotationPayload)
  - [JSON representation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#AnnotationPayload.SCHEMA_REPRESENTATION)
- [TranslationAnnotation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TranslationAnnotation)
  - [JSON representation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TranslationAnnotation.SCHEMA_REPRESENTATION)
- [ClassificationAnnotation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#ClassificationAnnotation)
  - [JSON representation](https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#ClassificationAnnotation.SCHEMA_REPRESENTATION)

Perform a prediction.

### HTTP request

`POST https://automl.googleapis.com/v1beta1/{name}:predict`

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` Name of the model requested to serve the prediction. Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the specified resource `name`: - `automl.models.predict` <br /> |

### Request body

The request body contains data with the following structure:

| JSON representation ||
|---|---|
| ``` { "payload": { object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#ExamplePayload`) }, "params": { string: string, ... } } ``` |

| Fields ||
|---|---|
| `payload` | ``object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#ExamplePayload`)`` Required. Payload to perform a prediction on. The payload must match the problem type that the model was trained to solve. |
| `params` | `map (key: string, value: string)` Additional domain-specific parameters, any string must be up to 25000 characters long. - For Image Classification: `score_threshold` - (float) A value from 0.0 to 1.0. When the model makes predictions for an image, it will only produce results that have at least this confidence score threshold. The default is 0.5. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. <br /> |

### Response body

If successful, the response body contains data with the following structure:
Response message for `https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#google.cloud.automl.v1beta1.PredictionService.Predict`.

Currently, this is only used to return an image recognition prediction result. More prediction output metadata might be introduced in the future.

| JSON representation ||
|---|---|
| ``` { "payload": [ { object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#AnnotationPayload`) } ], "metadata": { string: string, ... } } ``` |

| Fields ||
|---|---|
| `payload[]` | ``object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#AnnotationPayload`)`` Prediction result. |
| `metadata` | `map (key: string, value: string)` Additional domain-specific prediction response metadata. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. <br /> |

### Authorization Scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://cloud.google.com/docs/authentication/).

## ExamplePayload

Example data used for training or prediction.

| JSON representation ||
|---|---|
| ``` { // Union field `payload` can be only one of the following: "image": { object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#Image`) }, "textSnippet": { object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TextSnippet`) } // End of list of possible types for union field `payload`. } ``` |

| Fields ||
|---|---|---|
| Union field `payload`. Required. Input only. The example data. `payload` can be only one of the following: |||
| `image` | ``object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#Image`)`` An example image. |
| `textSnippet` | ``object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TextSnippet`)`` Example text. |

## Image

A representation of an image.

| JSON representation ||
|---|---|
| ``` { "thumbnailUri": string, // Union field `data` can be only one of the following: "imageBytes": string, "inputConfig": { object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/InputConfig`) } // End of list of possible types for union field `data`. } ``` |

| Fields ||
|---|---|---|
| `thumbnailUri` | `string` Output only. HTTP URI to the thumbnail image. |
| Union field `data`. Input only. The data representing the image. For Predict calls \[image_bytes\]\[\] must be set, as other options are not currently supported by prediction API. You can read the contents of an uploaded image by using the \[content_uri\]\[\] field. `data` can be only one of the following: |||
| `imageBytes` | `string (https://developers.google.com/discovery/v1/type-format format)` Image content represented as a stream of bytes. Note: As with all `bytes` fields, protobuffers use a pure binary representation, whereas JSON representations use base64. A base64-encoded string. <br /> |
| `inputConfig` | ``object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/InputConfig`)`` An input config specifying the content of the image. |

## TextSnippet

A representation of a text snippet.

| JSON representation ||
|---|---|
| ``` { "content": string, "mimeType": string, "contentUri": string } ``` |

| Fields ||
|---|---|
| `content` | `string` Required. The content of the text snippet as a string. Up to 250000 characters long. |
| `mimeType` | `string` The format of the source text. For example, "text/html" or "text/plain". If left blank the format is automatically determined from the type of the uploaded content. The default is "text/html". Up to 25000 characters long. |
| `contentUri` | `string` Output only. HTTP URI where you can download the content. |

## AnnotationPayload

Contains annotation information that is relevant to AutoML.

| JSON representation ||
|---|---|
| ``` { "annotationSpecId": string, "displayName": string, // Union field `detail` can be only one of the following: "translation": { object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TranslationAnnotation`) }, "classification": { object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#ClassificationAnnotation`) } // End of list of possible types for union field `detail`. } ``` |

| Fields ||
|---|---|---|
| `annotationSpecId` | `string` Output only . The resource ID of the annotation spec that this annotation pertains to. The annotation spec comes from either an ancestor dataset, or the dataset that was used to train the model in use. |
| `displayName` | `string` Output only. The value of `AnnotationSpec.display_name` when the model was trained. Because this field returns a value at model training time, for different models trained using the same dataset, the returned value could be different as model owner could update the displayName between any two model training. |
| Union field `detail`. Output only . Additional information about the annotation specific to the AutoML solution. `detail` can be only one of the following: |||
| `translation` | ``object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TranslationAnnotation`)`` Annotation details for translation. |
| `classification` | ``object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#ClassificationAnnotation`)`` Annotation details for content or image classification. |

## TranslationAnnotation

Annotation details specific to translation.

| JSON representation ||
|---|---|
| ``` { "translatedContent": { object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TextSnippet`) } } ``` |

| Fields ||
|---|---|
| `translatedContent` | ``object(`https://docs.cloud.google.com/translate/automl/docs/reference/rest/v1beta1/projects.locations.models/predict#TextSnippet`)`` Output only . The translated content. |

## ClassificationAnnotation

Contains annotation details specific to classification.

| JSON representation ||
|---|---|
| ``` { "score": number } ``` |

| Fields ||
|---|---|
| `score` | `number` Output only. A confidence estimate between 0.0 and 1.0. A higher value means greater confidence that the annotation is positive. If a user approves an annotation as negative or positive, the score value remains unchanged. If a user creates an annotation, the score is 0 for negative or 1 for positive. |