> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-013b37f0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Moderation

CometChat allows you to integrate OpenAI for real-time message moderation, enabling automated detection of harmful, offensive, or inappropriate content.

## Integration

### **Step 1: Configure OpenAI Settings**

1. **Login to the CometChat Dashboard**
   * Navigate to [CometChat Dashboard](https://app.cometchat.com) and select your app.

2. **Navigate to Moderation Settings**
   * Go to **Moderation → Settings** in the left-hand menu.

3. **Open OpenAI Settings Tab**
   * Click on the **OpenAI Settings** tab within the Moderation Settings.

4. **Fill in the OpenAI Configuration**

   * **Select OpenAI Model**
     * Choose the OpenAI model you want to use (e.g., `gpt-4-turbo`).

   * **Provide OpenAI API Key**
     * Enter your OpenAI API key to authenticate requests.

   * **Set Action on OpenAI Error**
     * Define how the system should respond if OpenAI is unavailable (e.g., "Allow message" or "Block message").

   * **Set Context Window**
     * Specify the number of previous messages in a conversation that will be used for OpenAI context.

5. **Click Save Settings**

### **Step 2: Enable OpenAI Moderation**

1. Navigate to **Moderation → List**.
2. Click **"Create New Rule"**.
3. Select **OpenAI** as the moderation type.
4. Select a predefined **prompt** from the List Section or create your own.
5. **Ensure that the rule type is either** `Text Contains` **or** `Image Contains`.
6. Save the rule and Enable it.

> **Note:** The rule you create should be of type **Text Contains** or **Image Contains** to work with OpenAI moderation.

***
