Serverless AI Text Classification
AI powered text classification service that analyzes and categorizes text based on predefined categories with confidence scores.
Endpoint
Text classification with customizable categories
POSThttps://api.xtartapp.com/text/classification
*Authentication
You must use a Bearer token provided by the dashboard to use for authentication. Add the token to the Authorization header.
Request body
| Name | Type | Required | Max | Description |
|---|---|---|---|---|
| text | string | Yes | 2000 | The text to classify |
| type | string | No | - | The classification type: 'exclusive' (sum of all scores equals 1) or 'confidence' (independent scores for each category) or 'binary' (only 0 or 1 for each category) |
| threshold | number | No | - | Optional threshold to filter classifications with scores below this value (0 to 1) |
| categories | array | Yes | 20 | The categories to classify the text against (max 25 categories) |
| categories[].key | string | Yes | 25 | Unique identifier for the category (max 25 characters, alphanumeric and spaces only) |
| categories[].description | string | Yes | 150 | Description of the category (max 150 characters) |
Response
| Name | Type | Description |
|---|---|---|
| data | object | The data of the text classification |
| data.<key> | string | The key of the category |
| data.<value> | number | Confidence score between 0 and 1 for the category |
| metadata | object | Metadata about the text classification process |
| metadata.cost | number | The cost of the text classification request |
Errors
{
"error": "string",
"code": "string"
}| HTTP Status | Error Code | Message |
|---|---|---|
| 400 | INVALID_PAYLOAD | Occurs when the payload is invalid. |
| 400 | INVALID_REQUEST | Ex.: The request is invalid. |
| 400 | TEXT_CLASSIFICATION_ERROR | Ex: could not classify the text | parsing error |
| 400 | HARM_CONTENT | Ex.: The content is harmful and cannot be processed. |
| 400 | INSUFFICIENT_BALANCE | The user has insufficient balance |
| 400 | INPUT_TOO_LONG | The input text exceeds the maximum allowed length. |
| 401 | UNAUTHORIZED | Ex.: The token is invalid. |
| 429 | TOO_MANY_REQUESTS | Ex.: The request limit has been reached. |