# 4.6 AI Configuration

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FYaTJPmQ2vTrt4IVxRHKW%2Fstep5.png?alt=media&#x26;token=cae56dcb-f18f-4897-ba91-a95667d17662" alt=""><figcaption></figcaption></figure>

### AI Operations Powered by OpenAI

We utilize OpenAI to enhance the AI capabilities within our web application. This integration ensures advanced, reliable, and efficient AI-driven features for a superior user experience.

### Steps to Generate an API Token for OpenAI

#### Step 1: Sign Up or Log In to OpenAI

1. **Visit OpenAI's Website:**
   * Open your web browser and navigate to [OpenAI's website](https://platform.openai.com/login?launch).
2. **Sign Up or Log In:**

   * If you do not have an account, click on the "Sign Up" button and follow the prompts to create a new account.
   * If you already have an account, click on the "Log In" button and enter your credentials to access your account.

   <figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FX5E4UyHK7qj1Wqqi2vKJ%2Flogin.png?alt=media&#x26;token=871a0fdd-85a6-4a5b-b629-358168be71b2" alt=""><figcaption></figcaption></figure>

#### Step 2: Access the API Dashboard

1. **Navigate to the API Section:**
   * Once logged in, go to the Dashboard section of the website. You can usually find this in the main menu.
2. **API Dashboard:**
   * Click on the link or menu item that takes you to the API dashboard. This is where you manage your API keys and settings.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2Fy2H8TIkQQVbYiTPIx3qr%2FClick_on_Dashboard.png?alt=media&#x26;token=e34370ea-572b-49ed-8850-3bd84f4a9108" alt=""><figcaption></figcaption></figure>

#### Step 3: Generate a New API Token

1. **Create New API Key:**

   * In the API dashboard, look for a button or link that says "Create New Secret Key". Click on it to start the process.

   <figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FtsEY8JUmmOLo65Z7WAYh%2FClick_on_Create_Secreat_key.png?alt=media&#x26;token=64894081-f662-4039-b24e-5ba7713e7fc2" alt=""><figcaption></figcaption></figure>
2. **Specify Key Details:**
   * You may be prompted to provide a name or label for the new API key. This helps you identify the key later, especially if you have multiple keys.
3. **Create Secret Key:**

   * Click on the "Create Secret Key" button to create the new API key.

   <figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2F7rOUDEvvPUKxpBRtpUxL%2FCreate_Secret_Key.png?alt=media&#x26;token=c51f0f6a-0601-44ec-a008-9b51a411a11f" alt=""><figcaption></figcaption></figure>

#### Step 4: Copy and Store the API Token

1. **Copy the Token:**
   * Once the key is generated, it will be displayed on the screen. Copy this key immediately. Some platforms do not show the key again for security reasons.
   * Paste the copied key in the form field in the installation step and choose your preferred AI model.

By following these steps, you can successfully generate a token for OpenAI.

### Add/Update API key later on

**Note:** if you have an **Extended License** then you will get the option to update the API key and gpt models from the admin panel as shown in the below image:

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FoZfOmdhx7CcheP8hNJBq%2FAI_Admin.png?alt=media&#x26;token=93399e37-7bcb-4492-aeec-f43ce2836313" alt=""><figcaption></figcaption></figure>

and if you have any other licenses then you can upate the API key and gpt models using the **.env** file present in the root directory of the project.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FrtEMFFM7Wm0GqFGG5nhz%2FENV%20PATH.png?alt=media&#x26;token=f13c5d18-ea28-4d77-897a-64f8e57f9342" alt=""><figcaption></figcaption></figure>

For the API key update the `AI_API_KEY` and for the models, you can change `AI_MODEL` as shown in the below image.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FOT3BAqJ5hm1wO3vk5CVC%2FAI_ENV_VAR.png?alt=media&#x26;token=c56de3e9-916e-404e-b08f-cd30516879d0" alt=""><figcaption></figcaption></figure>

**NOTE:** Please restart the server after the updates and be cautious when updating the **.env** files.
