---
date_modified: '2026-10-28'
version: '26.3'
llms_txt_path: For the complete documentation index, see [llms.txt](https://dbeaver.com/docs/dbeaver/llms.txt).
---



# OpenAI

> OpenAI supports two login methods: an API token or a ChatGPT account subscription.

To use OpenAI as an AI provider in DBeaver, configure it as follows:

1. Sign up on the [OpenAI platform](https://openai.com/api/)
2. Navigate to the [API Keys section](https://platform.openai.com/account/api-keys) and generate a new secret key
3. In DBeaver, go to **Window -> Preferences -> AI -> Model configurations**
4. Click **+** and choose **OpenAI** as the engine to create a profile
5. Select a login method:
    - **API token**: Insert the secret key into the **API token** field.
    - **ChatGPT account**: Sign in to your ChatGPT account.
6. Choose the model.
7. Click **Test connection** to verify that the key and model work correctly.
8. Apply the changes.

> **Note**: OpenAI services are available in specific countries. Consult the [supported countries](https://platform.openai.com/docs/supported-countries) list to verify availability in your location.

## Configure an OpenAI-compatible endpoint


You can connect to services that provide an OpenAI-compatible API:

1. Open **Window -> Preferences -> AI -> Model configurations**.
2. Add or edit an OpenAI provider profile.
3. Enter the endpoint in **API base URL**. If you leave this field blank, DBeaver uses `https://api.openai.com/v1/`.
4. Enter an **API token** if the endpoint requires Bearer authorization. If you provide a token, DBeaver adds the `Authorization: Bearer <api_key>` header automatically. Otherwise, leave the field blank.
5. Open **Advanced settings** and add any required headers under **Custom HTTP headers**. Custom headers can replace an automatically added header, including `Authorization`.
6. Choose a model, test the connection, and apply the changes.

Custom headers apply when DBeaver loads models and sends requests through either the Responses API or the Chat
Completions fallback. Invalid or unsupported headers are rejected with `Invalid or unsupported HTTP header: <name>`.

DBeaver stores custom-header values as profile secrets.

> **Example**: Configure an endpoint that uses an API key in a custom header as follows:
>
> - **API base URL**: `https://llm.example.com/v1/`.
> - **API token**: Leave blank.
> - **Custom HTTP headers**: `X-API-Key: <api_key>`.

## Settings

| Setting                           | Description                                                                                                                                                                                                                        | Default                      |
|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| **API token**                     | Enter the provider token if the endpoint requires Bearer authorization                                                                                                                                                             |                              |
| **Model**                         | Choose the AI model. Models are loaded dynamically and can be refreshed using the **Refresh models** button next to the field. You can also type a model name manually.                                                            |                              |
| **Context window size**           | A larger number allows the AI to use more data for better answers but may slow down response time. The size is set dynamically based on the selected model when available. ChatGPT account connections use `128000` as a fallback. | Model-dependent              |
| **Temperature**                   | Control AI's creativity from `0.0` (more precise) to `0.9` (more diverse).</br> Note that higher temperature can lead to less predictable results.                                                                                 | `0.0`                        |
| **API base URL**                  | The address where requests to the AI service are sent (for example, `https://api.openai.com/v1/`). Normally this is filled automatically for the selected provider. Change it only if you use a custom endpoint.                   | `https://api.openai.com/v1/` |
| **Custom HTTP headers**           | Additional HTTP headers required by the endpoint; available under **Advanced settings**                                                                                                                                            |                              |
| **Use environment variables**     | Read supported environment variables to override saved settings; available under **Advanced settings**                                                                                                                             | Off                          |
| **Request timeout (sec)**         | Maximum time DBeaver waits for a response from the AI engine before the request fails; available under **Advanced settings**                                                                                              | `30`                         |
| **Write AI queries to debug log** | Logs your AI requests. For more details on logging, see [Log Viewer](Log-files.md); available under **Advanced settings**                                                                                                          | disabled                     |

> **Tip**: If you use OpenAI with a model that supports tool calling, [AI tools](AI-Tools-and-MCP.md) are available.

### Use environment variables

| Variable                  | Description  |
|---------------------------|--------------|
| `OPENAI_API_KEY`          | API token    |
| `OPENAI_BASE_URL`         | API base URL |
| `DBEAVER_AI_OPENAI_MODEL` | Model name   |

Token and base URL overrides apply to **API token** authentication, not **ChatGPT account** authentication.
