# Classify text into labels

Launch stage: GA

`POST /api/2.0/ai-functions/ai-classify`

Classifies content according to a set of provided labels.

API scopes: ai-functions

## Request body

- `content` (object, required)
  The content to classify. It accepts a plain string or the response object of [ai_parse_document](:method:AiFunctions/AiParseDocument).
- `labels` (object, required)
  The label set to classify as. Either a JSON array of label strings (e.g. ["spam", "not_spam"]), or a JSON object mapping each label to a description (e.g. {"spam": "unsolicited bulk message", "not_spam": "a legitimate message"}). Accepts 2 to 500 labels, each 1 to 100 characters.
- `options` (object, optional)
  Function options. Omitted fields fall back to their documented defaults.
  - `instructions` (string, optional)
    Natural-language guidance that steers how the text is classified (up to 20,000 characters).
  - `version` (string, optional)
    The function version to invoke. Defaults to the latest version. Supported versions: ["2.1"].
  - `multilabel` (boolean, optional)
    When true, allows more than one label to be returned per input.
  - `enable_confidence_scores` (boolean, optional)
    When true, includes a per-label confidence score in the response.
  - `enable_rationales` (boolean, optional)
    When true, includes a rationale explaining each classification in the response.

## Returns

- `response` (object, optional)
  The function result as a JSON value. An array of per-label objects: one element in single-label mode (the default), or multiple elements when `multilabel` is true. When `enable_confidence_scores` and `enable_rationales` are true, `confidence_score` and `rationale` are included in each response value, respectively.
- `metadata` (object, optional)
  Additional metadata returned by AI Classify.
  - `version` (string, optional)
    The resolved function version.

## Response

```json
{
  "response": {},
  "metadata": {
    "version": "string"
  }
}
```

