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

NameTypeRequiredMaxDescription
textstringYes2000The text to classify
typestringNo-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)
thresholdnumberNo-Optional threshold to filter classifications with scores below this value (0 to 1)
categoriesarrayYes20The categories to classify the text against (max 25 categories)
categories[].keystringYes25Unique identifier for the category (max 25 characters, alphanumeric and spaces only)
categories[].descriptionstringYes150Description of the category (max 150 characters)

Response

NameTypeDescription
dataobjectThe data of the text classification
data.<key>stringThe key of the category
data.<value>numberConfidence score between 0 and 1 for the category
metadataobjectMetadata about the text classification process
metadata.costnumberThe cost of the text classification request

Errors

{
   "error": "string", 
   "code": "string"
}
HTTP StatusError CodeMessage
400INVALID_PAYLOADOccurs when the payload is invalid.
400INVALID_REQUESTEx.: The request is invalid.
400TEXT_CLASSIFICATION_ERROREx: could not classify the text | parsing error
400HARM_CONTENTEx.: The content is harmful and cannot be processed.
400INSUFFICIENT_BALANCEThe user has insufficient balance
400INPUT_TOO_LONGThe input text exceeds the maximum allowed length.
401UNAUTHORIZEDEx.: The token is invalid.
429TOO_MANY_REQUESTSEx.: The request limit has been reached.