Text Classification
Use text classification to rank a fixed set of labels for one or more documents without training a custom classifier. It fits tasks such as tagging, triage, or routing requests, where the categories are known in advance and you need a similarity ranking rather than a generated answer.
AIVAX embeds every document and label with the default embedding model and compares their vectors using cosine similarity. For each document, it returns every label ordered from the most similar to the least similar.
Before calling this endpoint, create an API key and make sure the account has a positive balance.
Endpoint #
Request behavior #
| Property | Type | Required | Description |
|---|---|---|---|
documents | string[] | Yes | One or more non-empty documents to classify. Results preserve this order and each document’s zero-based index. |
labels | string[] | Yes | One or more non-empty labels. Every label is scored for every document. |
The endpoint uses the default embedding model and does not accept a model parameter, score threshold, or result limit.
The following request classifies three documents, one of them in German, against three labels:
{
"documents": [
"Compare the total cost of two loans for a principal of $10,000 over 5 years at different annual rates",
"Erklären Sie die Unterschiede zwischen Merge-Sort und Quicksort-Algorithmen in Bezug auf Zeitkomplexität, Platzkomplexität und Leistung in der Praxis.",
"Write a poem about the beauty of nature and its healing power on the human soul"
],
"labels": [
"Creative writing",
"Complex problem",
"Simple task"
]
}Read the response #
results contains one item for each input document. Each scores array contains every supplied label, ordered by descending cosine similarity. The example below is abbreviated to the first document:
{
"results": [
{
"index": 0,
"document": "Compare the total cost of two loans for a principal of $10,000 over 5 years at different annual rates",
"scores": [
{
"label": "Complex problem",
"score": 0.98828
},
{
"label": "Simple task",
"score": 0.45272
},
{
"label": "Creative writing",
"score": 0.06823
}
]
}
]
}A score measures vector similarity, not a probability. Compare scores within the same request rather than reading a value as a percentage confidence.
Async generation #
Add "async": true to queue the classification. The API answers with HTTP 202 and an ID, and you fetch the stored result later or receive a webhook when it is done. See Async generations.
{
"documents": ["Write a poem about the beauty of nature"],
"labels": ["Creative writing", "Complex problem", "Simple task"],
"async": true
}Pricing and limits #
| Description | Pricing |
|---|---|
| Text classification | $0.015/M tokens |
The number of classified documents per minute and per day depends on the plan; see Data processing limits. The quota counts every item in the request’s documents array, not each HTTP request. A request that would exceed any active window returns 429 Too Many Requests.
The embedded API reference contains the server-maintained request, response, authentication, and error details:
