---
schema_version: "1"
id: 1173161b9a0755c6f7a777206e3db245c743b20772ef3cefc078513f3f03346e
title: AI_CLASSIFY
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/ai-func/ai-classify.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/ai-classify.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3a563ff3eefd2ebae54c78bebb1a1e0868715225f29eaf30e14652c897bc27e8
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `AI_CLASSIFY`

**Applies to:** ✅ Data 360 SQL ❌ Tableau Hyper API

Analyzes text and classifies it into the best matching category from a list of categories you define. This function uses the classification model to categorize support cases, customer inquiries, product feedback, and other unstructured text.

## Syntax

```sql
ai_classify(<input_text>, <input_categories>)
```

## Arguments

### Required

- `<input_text>`: The [text](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/string.md) to classify.
- `<input_categories>`: A text [array](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/array.md) of categories with at least one unique value. An empty category list results in the `Input categories cannot be empty` validation error message.

## Returns

After analyzing the `input_text`, returns the category with the highest confidence score from the `input_categories`.

## Considerations

- **Input text length**: The function supports input text up to 512 tokens (approximately 400-500 words). For longer text such as full emails or lengthy documents, split the content into shorter passages before classifying.
- **Best for short text**: This function works best on short, intent-rich text such as support case descriptions, product inquiries, and customer feedback.
- **Category consistency**: The `input_categories` parameter must be constant across all rows in the query.
- **Performance**: Requests to the function time out after 30 seconds.
- **First execution**: When executing this function on a large number of rows for the first time, you can encounter timeout or capacity errors. Start with smaller row counts and gradually increase volume to avoid these issues.
- **Non-NULL values**: `input_text` must be a non-NULL value. Add `IS NOT NULL` to the `WHERE` clause in your SQL statement to avoid `NULL` value errors.
- **Multilingual support**: The underlying model supports multiple languages.

## Examples

### Basic Usage

Classify issues in an automobile repair center based on the type of issue.

```sql
SELECT
  "issuesIdentified__c",
  ai_classify(input_text=>"issuesIdentified__c",
  input_categories=>'["Engine", "Chassis", "Electrical"]') AS category
  FROM "AutomobileServiceFeedback__dll"
```

Returns:

| issuesIdentified\_\_c                                                             | category   |
| --------------------------------------------------------------------------------- | ---------- |
| Electrical system failure causing intermittent starting and dashboard warnings    | Electrical |
| Shock absorber replacement due to oil leakage and poor ride quality               | Chassis    |
| Engine overheating issue traced to failed radiator and thermostat replacement     | Engine     |
| Exhaust system repair and catalytic converter replacement                         | Engine     |
| Steering system malfunction requiring tie rod and power steering pump replacement | Chassis    |

### Filter Classification Results

Returns only the rows matching the defined classification.

```sql
WITH ClassifiedIssues AS (
  SELECT
    "serviceCenterName__c",
    "costOfService__c",
    "issuesIdentified__c",
    ai_classify(
      input_text => "issuesIdentified__c",
      input_categories => '["Engine", "Chassis", "Electrical"]'
    ) AS category
  FROM "AutomobileServiceFeedback__dll"
)
SELECT * FROM ClassifiedIssues
WHERE category = 'Engine';
```

Returns all reported vehicle issues related to the engine.

## Related Documentation

- [Topic Classification](https://help.salesforce.com/s/articleView?id=data.c360_a_ai_predictive_model_classify.htm&type=5): Learn about topic classification models, use cases, and integration options.
- [AI Models in Data Cloud](https://help.salesforce.com/s/articleView?id=data.c360_a_ai_create_connect_activate_models.htm&type=5): Read an overview of AI model capabilities.
