# OpenAI account connection

The connection allows you to use the API of your OpenAI account to process ChatRex messages. OpenAI costs and ChatRex write-off conditions are accounted for separately; check current values in the interfaces of both services.

ChatGPT does not replace API balance. To operate the key in the OpenAI account, access to the API and billing must be configured.

## Creating an API key

1. Open [OpenAI API Keys page](https://platform.openai.com/api-keys).
2. Enter the right organization or project.
3. Create a new secret key.
4. Copy it immediately: the full value is not shown later.
5. Save the key in a secure secret manager until the connection is complete.

OpenAI’s official documentation recommends keeping the API key in a secure location and not publishing it in client code or documents.

## Connecting to ChatRex

1. Open **Integrations**.
2. Press **Connect integration**.
3. In the **Data Sources** tab, select OpenAI or ChatGPT integration.
4. Insert the API key in the field intended for it.
5. Press **Connect**.
6. Make sure the connection is active.

## Verification

1. Select the bot that should use the connection.
2. Send a short message in **Testing**.
3. Check the answer and no authorization error.
4. Check the flow at ChatRex and OpenAI.

If an error occurs, check the selected OpenAI project, billing status, key rights and model availability.

!!!warning
Never insert an API key into a system prompt, messages, knowledge base files, tasks, or screenshots. If the key is unlocked, delete it in OpenAI, create a new one, and update the integration.
!!!
