Prediction for Intent

Returns an intent prediction for the given string.

Request Parameters

Name

Type

Description

Available Version

document

string

Text for which you want to return an intent prediction.

2.0

modelId

string

ID of the model that makes the prediction. The model must have been created from a dataset with a type of text-intent.

2.0

numResults

int

Number of probabilities to return. Optional. If passed, must be a number greater than zero.

The response is sorted by probability in descending order. For example, if you pass in 3, only the top three label and probability values are returned.

2.0

sampleId

string

String that you can pass in to tag the prediction. Optional. Can be any value, and is returned in the response.

2.0

Keep the following points in mind when sending text in for prediction:

  • If you omit the numResults parameter, the response returns probabilities for all the labels in the model.

Response Body

Name

Type

Description

Available Version

probabilities

array

Array of probabilities for the prediction.

2.0

sampleId

string

Value passed in when the prediction call was made. Returned only if the sampleId request parameter is provided.

2.0

Probabilities Response Body

Name

Type

Description

Available Version

label

string

Probability label for the input.

2.0

probability

float

Probability value for the input. Values are between 0–1.

2.0

Passing Parameters as JSON

As an alternative to passing the modelId and document parameters as multipart/form-data fields, you can pass those parameters as JSON. You can pass the JSON directly as a string or reference a file that contains the JSON.

This cURL call sends a JSON string into a case routing model for classification. The Content-Type has changed to application/json.

curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: application/json" -d "{\"modelId\":\"2ELVAO5BNVGZLBHMYTV7CGD5AY\",\"document\":\"my password stopped working\"}" https://api.einstein.ai/v2/language/intent

Here's what the response might look like.

{
  "probabilities": [
    {
      "label": "Password Help",
      "probability": 0.99040705
    },
    {
      "label": "Order Change",
      "probability": 0.003532466
    },
    {
      "label": "Shipping Info",
      "probability": 0.003473858
    },
    {
      "label": "Billing",
      "probability": 0.0024010758
    },
    {
      "label": "Sales Opportunity",
      "probability": 0.00018560764
    }
  ],
  "object": "predictresponse"
}

You can store the JSON in a file and reference that file. For example, the file intent.json might look like the following.

{
"modelId":"2ELVAO5BNVGZLBHMYTV7CGD5AY",
"document":"my password stopped working"
}

This cURL call references that file.

curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: application/json" -d @c:\data\intent.json https://api.einstein.ai/v2/language/intent

Rate Limit Headers

Any time you make an API call to the /intent resource, your rate limit information is returned in the header. The rate limit headers specify your prediction usage for the current calendar month only.

X-RateLimit-Limit 2000
X-RateLimit-Remaining 1997
X-RateLimit-Reset 2017-04-01 19:31:42.0

Header

Description

Example

X-RateLimit-Limit

Maximum number of prediction calls available for the current plan month.

2000

X-RateLimit-Remaining

Total number of prediction calls you have left for the current plan month.

1997

X-RateLimit-Reset

Date on which your predictions are next provisioned. Always the first of the month.

2017-04-01 22:07:40.0

Language