Basic classify request
Set your API key as a shell variable first so you don't have to type it on every command:
export CAI_KEY="cai_live_your_key_here"
Then make a classify request:
curl -X POST https://api.classifaily.com/v1/classify \
-H "Authorization: Bearer $CAI_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "My invoice shows a double charge this month.",
"categories": ["billing", "technical_bug", "account_access", "general"]
}'
Reading the response
{
"id": "101",
"status": "completed",
"type": "text",
"result": {
"label": "billing",
"confidence": 0.97
}
}
Pipe through jq to extract just the label and confidence:
curl -s -X POST https://api.classifaily.com/v1/classify \
-H "Authorization: Bearer $CAI_KEY" \
-H "Content-Type: application/json" \
-d '{"input": "double charge", "categories": ["billing", "bug", "account"]}' \
| jq '{label: .result.label, confidence: .result.confidence}'
With explanation
curl -X POST https://api.classifaily.com/v1/classify \
-H "Authorization: Bearer $CAI_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "My invoice shows a double charge this month.",
"categories": ["billing", "technical_bug", "account_access", "general"],
"explain": true
}'
Batch request
Classify up to 25 items in one call using the /batch endpoint:
curl -X POST https://api.classifaily.com/v1/batch \
-H "Authorization: Bearer $CAI_KEY" \
-H "Content-Type: application/json" \
-d '{
"items": [
{"id": "1", "input": "I cannot log in."},
{"id": "2", "input": "Refund request for last month."},
{"id": "3", "input": "Can I export my data as CSV?"}
],
"categories": ["billing", "technical_bug", "account_access", "feature_request", "general"]
}'
Check your usage
curl https://api.classifaily.com/v1/usage \
-H "Authorization: Bearer $CAI_KEY"
Common errors
- 401 Unauthorized - Missing or invalid API key. Check that
$CAI_KEYis set and the key is active in your dashboard. - 429 Too Many Requests - You have hit your plan's rate limit. Check usage with the
/usageendpoint. - 422 Unprocessable Entity - Missing required fields. Ensure
inputis present and non-empty.
Ready to go further?
See the full API reference for all parameters and response formats.
API Reference