Returns an intent prediction for the given string.
Request Parameters
Name | Type | Description | Available Version |
---|---|---|---|
| string | Text for which you want to return an intent prediction. | 2.0 |
| string | ID of the model that makes the prediction. The model must have been created from a dataset with a type of | 2.0 |
| int | Number of probabilities to return. Optional. If passed, must be a number greater than zero. The response is sorted by | 2.0 |
| 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 |
---|---|---|---|
| array | Array of probabilities for the prediction. | 2.0 |
| string | Value passed in when the prediction call was made. Returned only if the | 2.0 |
Probabilities Response Body
Name | Type | Description | Available Version |
---|---|---|---|
| string | Probability label for the input. | 2.0 |
| 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 |
---|---|---|
| Maximum number of prediction calls available for the current plan month. | 2000 |
| Total number of prediction calls you have left for the current plan month. | 1997 |
| Date on which your predictions are next provisioned. Always the first of the month. | 2017-04-01 22:07:40.0 |