# OpenAI

![OpenAI bought the web domain Chat.com](https://assets.relyanceuat.xyz/images/docs/42514909149581/ext-0640763886.jpg)
#### **Overview**

To facilitate a secure data analysis for the OpenAI, your organization must provide a Restricted API Key along with the associated Project and Organization IDs. This configuration ensures that access is limited strictly to "Read-Only" permissions, preventing any modification, deletion, or creation of resources within your OpenAI environment.

#### **Step 1: Locate Organization and Project IDs**

Before creating the key, please retrieve the following identifiers required for API authentication:

1. **Organization ID:** Navigate to **Settings > Organization > General**. Copy the string labeled "Organization ID" (starts with org- ).
2. **Project ID:** Navigate to **Settings > Project > General**. Copy the string labeled "Project ID" (starts with proj- ).

#### **Step 2: Initialize API Key Creation**

1. Log in to the **OpenAI Developer Dashboard**.
2. **Select Project:** Confirm you are in the correct Project context via the dashboard selector in the top-left navigation.
3. **Navigate to API Keys:** Select the "API Keys" section from the primary navigation menu.
4. **Create Key:** Click "Create new secret key."
5. **Labeling:** Assign a descriptive name to the key for auditing purposes (**e.g.,** Relyance_Key).
6. **Set Scope:** Change the permission setting from "All" to **"Restricted."**

#### **Step 3: Define Restricted Permissions**

In the permissions grid, locate the following endpoints and adjust the access levels to **Read** only. Ensure that no "Write," "Modify," or "Delete" permissions are enabled.

| **Resource Endpoint**| **Description**| **Required Permission** |
| --- | --- | --- |
| **Assistants** | Custom AI assistant configurations | Read |
| **Files** | Metadata for uploaded datasets | Read |
| **Fine-tuning** | Fine-tuning job history and status | Read |
| **Models** | List of available base and custom models | Read |
| **Vector Stores** | Metadata for embedding stores | Read |

*Note: For endpoints that provide a binary choice between "None" and "Read," ensure "Read" is selected to allow the application to view the necessary metadata.*

#### **Step 4: Initialize Integration in Relyance AI**

![Screenshot](https://assets.relyanceuat.xyz/images/docs/42514909149581/42514849042701.png)
1. Navigate to the **Integrations** page within the Relyance application.
2. Select the **OpenAI** integration card.
3. Review the integration overview and click **Next**.

    The **Authentication** step asks for:

    - **API Key**: Your OpenAI API key from https://platform.openai.com/api-keys; required; held as a secret.
    - **Project ID**: OpenAI project ID (required for organization accounts); required; held as a secret.
    - **Organization ID**: OpenAI organization ID (optional, for organization accounts); optional; held as a secret.

#### **Step 5: Configure Scan Parameters**

![Screenshot](https://assets.relyanceuat.xyz/images/docs/42514909149581/42514849043085.png)
1. Define the desired **Scan Interval** (the frequency at which the application will check for data updates).
2. **Recommendation:** Utilize the default settings provided to ensure optimal performance and data currency.
3. Click **Next** to proceed to authentication.

#### **Step 6: Authenticate and Finalize**

1. **Input Credentials:** Enter the **Restricted API Key**, **Organization ID**, and **Project ID** captured in the previous steps.
2. **Verify Connection:** Click **Authenticate** to establish the connection.
3. **Completion:** Once the authentication is successful, the integration will begin its initial metadata scan.

![Screenshot](https://assets.relyanceuat.xyz/images/docs/42514909149581/42514849048077.png)

<!-- terraform-examples:begin (generated from the integration catalog; do not hand-edit) -->

## Manage this integration with Terraform

Connections for this integration can be managed as code with the [Relyance Terraform provider](https://registry.terraform.io/providers/Relyance/relyance/latest). Non-secret fields go in `auth.params`; secret fields go in `auth.secrets_wo`, which is write-only — never stored in Terraform state. Rotate secrets by bumping `auth.secrets_wo_version`.

```hcl
resource "relyance_integration_connection" "openai" {
  vendor = "openai"
  name   = "<your connection name>"

  auth = {
    method = "api-key"
    params = {
      data_storage_location = "us"
    }
    # Secret fields are write-only: sent to Relyance, never stored in state.
    secrets_wo = {
      api_key = var.openai_api_key
      project_id = var.openai_project_id
      organization_id = var.openai_organization_id
    }
    secrets_wo_version = 1
  }

  scans = { "data-inspection" = { enabled = true } }
}
```

<!-- terraform-examples:end -->
