Skip to main content

AI · API reference

POST /v1/classify

Classifies a document into one or more of your labels and returns a confidence score for each.

Sample content

The Atlas API is fictional. Endpoints, fields, and limits are illustrative.

POST https://api.atlas.example.com/v1/classify

OpenAPI: Download the OpenAPI spec (OpenAPI 3.1, YAML). The file is linted in CI and checked against this page.

Authentication​

Send your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Requests without a valid key return 401 unauthorized.

Request body​

FieldTypeRequiredDescription
textstringYesThe document to classify. 1 to 100,000 characters.
labelsarray of stringsYesThe labels to choose from. 2 to 50 labels, each up to 100 characters.
multi_labelbooleanNoIf true, the document can match more than one label. Default: false.
thresholdnumberNoMinimum confidence (0.0–1.0) for a label to count as a match. Default: 0.5.
explainbooleanNoIf true, include a one-sentence reason for each match. Default: false.

Unknown fields are rejected with 400 invalid_request.

Example request​

The same request in curl, Python (with requests) and JavaScript (with fetch). The Atlas API is fictional, so these calls return nothing real; they show the shape of a correct call. Each one reads the key from the ATLAS_API_KEY environment variable instead of the source code.

curl https://api.atlas.example.com/v1/classify \
-H "Authorization: Bearer $ATLAS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "The left landing gear actuator leaked hydraulic fluid during the preflight check.",
"labels": ["hydraulics", "avionics", "propulsion", "structures"],
"multi_label": false,
"explain": true
}'

Example response​

{
"id": "cls_7f3a9c21",
"matches": [
{
"label": "hydraulics",
"confidence": 0.94,
"reason": "Describes a hydraulic fluid leak from a landing gear actuator."
}
],
"scores": {
"hydraulics": 0.94,
"structures": 0.31,
"avionics": 0.04,
"propulsion": 0.02
},
"model": "atlas-classify-2",
"usage": { "input_characters": 81 }
}

Response fields​

FieldTypeDescription
idstringUnique ID for this request. Include it when you contact support.
matchesarrayLabels at or above threshold, highest confidence first. Empty if none qualify.
matches[].labelstringThe matched label.
matches[].confidencenumberConfidence from 0.0 to 1.0.
matches[].reasonstringPresent only when explain is true.
scoresobjectConfidence for every label you sent, including those below threshold.
modelstringThe model version that produced the result.
usage.input_charactersintegerCharacters billed for this request.
Interpreting confidence

Confidence scores rank labels for this request only. A score of 0.94 does not mean the result is correct 94% of the time. To set a threshold for production, test the endpoint on your own labeled examples.

Errors​

HTTP statuserror.typeCauseWhat to do
400invalid_requestA field is missing, unknown, or out of rangeCheck error.message for the field name
401unauthorizedAPI key is missing or invalidCheck the Authorization header
413text_too_longtext is over 100,000 charactersSplit the document and classify each part
429rate_limitedToo many requestsWait for the time in the Retry-After header, then retry
500server_errorTemporary problem on our sideRetry with exponential backoff

Error responses use this shape:

{
"error": {
"type": "invalid_request",
"message": "labels must contain between 2 and 50 items."
}
}

Rate limits​

PlanRequests per minuteCharacters per day
Free20500,000
Team60050,000,000

Every response includes two headers: X-RateLimit-Remaining (requests you can still make in the current minute) and X-RateLimit-Reset (seconds until the window resets).