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

# OpenAI

> Enable secure integration between AirMDR and OpenAI by generating and configuring an Admin Key for OpenAI client authentication.

### 🔑 Admin Key Creation & Data Logging Configuration Guide in OpenAI for Authentication

This guide walks OpenAI account administrators through generating a new **Admin API key** and enabling **data logging** in the **Data Controls** section for audit, compliance, and operational purposes.

### ✅ **Prerequisites**

Ensure you meet these prerequisites before starting:

* Admin access to **AirMDR** application
* You must have access to the [OpenAI Developer Platform](https://platform.openai.com/account) with **Admin privileges** in your OpenAI organization
* Permissions to manage API keys and system-wide data settings

### Generate a New Admin API Key

To generate an Admin key in the OpenAI Platform for integrating with AirMDR, follow these steps:

<Steps>
  <Step title="Login to the OpenAI Platform">
    1. Navigate to [Open AI](https://platform.openai.com) Platform.
    2. Click **Login** in the top-right corner, and authenticate with your admin credentials.
  </Step>

  <Step title="Create a New Admin Key" stepNumber={2}>
    1. In the Left Navigation pane, enter the value "**Admin API Keys**" in the Search bar.
    2. Go to [Admin Keys management page](https://platform.openai.com/settings/organization/admin-keys).
    3. Click on the **“+ Create new Admin key”** button. A pop-up modal will show up.

           <img src="https://mintcdn.com/airmdr/SboUIdGiLVb2ztab/images/OpenAI10.png?fit=max&auto=format&n=SboUIdGiLVb2ztab&q=85&s=a3c3ff7f747f7b580ca21607361d757c" alt="Open AI10 Pn" width="2982" height="544" data-path="images/OpenAI10.png" />
    4. In the Create new admin key pop-up modal

       * Provide a descriptive name for the API key (e.g., `AirMDR Integration`).
       * In the Permissions, select the **Read only** option.

           <img src="https://mintcdn.com/airmdr/SboUIdGiLVb2ztab/images/OpenAI11.png?fit=max&auto=format&n=SboUIdGiLVb2ztab&q=85&s=81f3322a3ddbec7fd5c75532ae079fd6" alt="Open AI11 Pn" width="866" height="498" data-path="images/OpenAI11.png" />
    5. Click **Create admin key** to generate the key.
  </Step>

  <Step title="Copy and Store the API Key">
    1. A modal will display your new **secret API key**.
    2. Click **Copy** to save it to your clipboard.

           <Warning>
             This is the only time the **API Key** will be displayed. \
             Copy and securely save the secret API key in your preferred password manager or secure storage solution.
           </Warning>
    3. Once you successfully copy and securely saved the Key, click **Done**.

           <img src="https://mintcdn.com/airmdr/SboUIdGiLVb2ztab/images/OpenAI12.png?fit=max&auto=format&n=SboUIdGiLVb2ztab&q=85&s=c79710fa6b14a3a7f96df305d8f56b48" alt="Open AI12 Pn" width="872" height="728" data-path="images/OpenAI12.png" />

           <Tip>
             You can **Edit** <Icon icon="pencil" color="#080505" /> the *Name* and *Permissions* or **Delete** <Icon icon="trash-can" color="#050303" /> the Secret Key entirely.
           </Tip>

           <img src="https://mintcdn.com/airmdr/SboUIdGiLVb2ztab/images/OpenAI3.png?fit=max&auto=format&n=SboUIdGiLVb2ztab&q=85&s=0bb42f6bbfc75783a96bb77e8b5753f7" alt="Open AI3 Pn" width="2500" height="166" data-path="images/OpenAI3.png" />

           <Check>
             Email the **Admin** **API key** to AirMDR \
             or \
             Self [configure](https://docs.airmdr.com/Integrations/OpenAI#configure-openai-in-the-airmdr-integrations-dashboard) OpenAI in the AirMDR Integrations Dashboard.
           </Check>
  </Step>
</Steps>

### Enable Data Logging in Data Controls

<Steps>
  <Step title="Access Data Controls">
    1. Go to [Organization → Data Controls → Data retention](https://platform.openai.com/settings/organization/data-controls/data-retention).
    2. Locate the **Audit Logging** toggle.
    3. Set it to **Enabled (ON)**.
    4. Click **Save**.

           <img src="https://mintcdn.com/airmdr/SboUIdGiLVb2ztab/images/OpenAI13.png?fit=max&auto=format&n=SboUIdGiLVb2ztab&q=85&s=c8bc98d7d0e085751ab67e389dc00eb3" alt="Open AI13 Pn" width="2322" height="994" data-path="images/OpenAI13.png" />
    5. Review the logging policy and retention notice.
    6. Confirm your changes if prompted.
  </Step>

  <Step title="Verify Logging Behavior">
    1. Perform a test API call using the new Admin key.
    2. Confirm activity is recorded under **Usage** or via your **audit log provider** (if integrated).
  </Step>
</Steps>

### Post-Setup Security Best Practices (Optional)

* Rotate keys periodically and delete unused ones.
* Regularly review your organization’s data control settings for compliance.
* Monitor usage under: [https://platform.openai.com/account/usage](https://platform.openai.com/account/usage)
* Never share your API key publicly.
* Use environment variables or secret vaults (like AWS Secrets Manager, Azure Key Vault).
* Rotate keys regularly and revoke unused keys from the [API Key page](https://platform.openai.com/account/api-keys).

### Skills Provided by this Integration

| Skill ID                  | Purpose                                                                                                            |
| :------------------------ | :----------------------------------------------------------------------------------------------------------------- |
| **Get OpenAI Audit Logs** | Retrieve audit logs from the OpenAI platform with filtering capabilities for time ranges, actors, and event types. |

<Tip>
  To view the details of Input Parameters and Output for the respective skills

  * Go to [AirMDR → OpenAI](https://app.airmdr.com/integrations?search=OpenAI) Integration page.
  * Select the **Skills** tab and click on the required listed skills.
</Tip>

### OpenAI API Testing

Open **cURL** and run the following command to check if your API Key is working:

**Sample** `cURL`**Command**

```

curl --location 'https://api.openai.com/v1/organization/audit_logs' \
--header 'Authorization: Bearer <ADMIN_API_KEY>' \
--header 'Content-Type: application/json'
```

> Replace `ADMIN_API_KEY` with your actual secret API key.

**Sample JSON Response**

```

{
    "object": "list",
    "data": [
        {
            "object": "organization.audit_log",
            "id": "audit_log-YuMhFDGx9KyuKeCzOlgMUQmK",
            "type": "login.succeeded",
            "effective_at": 1751865809,
            "actor": {
                "type": "session",
                "session": {
                    "user": {
                        "id": "user-mT5AyiS89mUCGccNnsiiFTFg",
                        "email": "user@company.com"
                    },
                    "ip_address": "209.35.227.192",
                    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",
                    "ja3": "dc34fcc82fa919512cc12b7def99183c",
                    "ja4": "q13d0313h3_55b375c5d22e_226f3f127bbe",
                    "ip_address_details": {
                        "country": "GB",
                        "city": "Manchester",
                        "region": "England",
                        "region_code": "ENG",
                        "asn": "213176",
                        "latitude": "53.48095",
                        "longitude": "-2.23743"
                    }
                }
            }
        }
    ],
    "first_id": "audit_log-YuMhFDGx9KyuKeCzOlgMUQmK",
    "last_id": "audit_log-YuMhFDGx9KyuKeCzOlgMUQmK",
    "has_more": true
}
```

### Configure OpenAI in the AirMDR Integrations Dashboard

1. Navigate to [AirMDR](https://app.airmdr.com/auth/login), provide the credentials, and click **Login**

   <img src="https://mintcdn.com/airmdr/wnBXbVlE7mmN9W6R/images/Datadog11.png?fit=max&auto=format&n=wnBXbVlE7mmN9W6R&q=85&s=94afec6835b90abcec516831e584184f" alt="" width="443" height="568" data-path="images/Datadog11.png" />
2. Navigate to the AirMDR Integrations Dashboard in the left navigation pane and select **Integrations.**

   <img src="https://mintcdn.com/airmdr/-Uv__fqsZox2OjNr/images/Slack24.png?fit=max&auto=format&n=-Uv__fqsZox2OjNr&q=85&s=a9491b36c15fdaecb13d250b89843ad9" alt="Slack24 Pn" width="548" height="1456" data-path="images/Slack24.png" />
3. Use the search option, enter the keyword "**OpenAI**", select the **Connections** tab, and click **Create**.

   <img src="https://mintcdn.com/airmdr/SboUIdGiLVb2ztab/images/OpenAI6.png?fit=max&auto=format&n=SboUIdGiLVb2ztab&q=85&s=a14951b1da65315000f9c28f04e37370" alt="Open AI6 Pn" width="1244" height="662" data-path="images/OpenAI6.png" />
4. Enter an unique name to the Instance (e.g., `your org name-OpenAI`) to easily identify the user connection by AirMDR.
5. Enter the generated **API Token (Admin API Key)** in the Authentication Details field params, and click **Create.**

   <img src="https://mintcdn.com/airmdr/SboUIdGiLVb2ztab/images/OpenAI4.png?fit=max&auto=format&n=SboUIdGiLVb2ztab&q=85&s=e584c7760d0fb96b087777b1eda9f732" alt="Open AI4 Pn" width="1440" height="1118" data-path="images/OpenAI4.png" />
