# OpenAI

## Configuration

### Prerequisites

First, you need to obtain an API key to connect to OpenAI. In the OpenAI Platform, go to *API keys* and click **Create new secret key**. Once generated, copy it for later use.

### Connecting the data source

When you obtained the key necessary for the data source configuration, you can proceed to connecting it.

1. On the **Data sources** page, click **Connect**, and select *OpenAI* in the Data sources list.
2. Select a *version* and paste the *API key* you copied before.
3. Click **Test connection** to check whether the data source can be connected, and then click **Connect Datasource** to complete the setup.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2F6ktZ3vM6tMC4fAl3jK36%2FCleanShot%202025-04-23%20at%2011.41.40%402x-min.png?alt=media&#x26;token=7df033b5-1e0c-489d-b696-97b7e6d7fcde" alt=""><figcaption></figcaption></figure>

## Usage

Once you have connected OpenAI to UI Bakery, you can start interacting with the data. For this purpose, you can use the [Open API Request](https://docs.uibakery.io/reference/working-with-actions/open-api-request) action type:

1. Create a new action and select your *OpenAI* data source - the Open API Request action will be selected automatically.\
   All available OpenAI endpoints will be already defined.
2. Select the required endpoint from the **Operation** dropdown.
3. Set any parameters and/or body if necessary.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FSPY4YcvFE0lAnSZphNR4%2FCleanShot%202025-04-23%20at%2011.50.19%402x-min.png?alt=media&#x26;token=02d39a07-9756-4505-b58c-4e9d189f878d" alt=""><figcaption></figcaption></figure>

4. Finally, click **Execute action** and check the *Result* tab.
