# 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="/files/TRd81aWr7gWbGhKPoACD" 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](/reference/working-with-actions/open-api-request.md) 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="/files/ovcjQ7TFl4xgyQ22A91l" alt=""><figcaption></figcaption></figure>

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uibakery.io/reference/data-sources/openai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
