> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# ai_classify

> Asks the model to classify text into one of the given categories.

Asks the model to classify text into one of the given categories.

## Syntax

```sql theme={null}
ai_classify(input, categories[, provider[, model]])
```

## Arguments

* `input`: A VARCHAR expression containing the text to classify.
* `categories`: A nonempty constant `ARRAY<VARCHAR>` containing the candidate categories.

For the types and default behavior of `provider` and `model`, see [Common calling rules](/documents/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#common-calling-rules).

## Return value

Returns a nullable JSON object. The database asks the model to choose one category from `categories` and put it in the `labels` array, for example, `{"labels":["support"]}`.

The database only checks that the result is a JSON object. It does not check the length of `labels`, whether the category appears in `categories`, or whether the classification is correct.

## Examples

```sql theme={null}
SELECT ai_classify('Please reset my password.', ['support', 'sales']);

SELECT ai_classify(
    input => 'Please reset my password.',
    categories => ['support', 'sales'],
    provider => 'support_chat'
);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.