---
title: "OpenAI"
section: "Third party keys"
route: /thirdpartykeysopenai
account: {accountId}
bruce_api: https://{accountId}.api.nextspace.host
guardian_api: https://guardian.nextspace.host
---
# OpenAI

An OpenAI API key is saved under the program ID "ChatGPT". The API sends it as a bearer token to OpenAI's chat completions endpoint, "https://api.openai.com/v1/chat/completions", so it must be an OpenAI key. No other AI provider's key is read.

In Operator it is the "ChatGPT" field of the Third Party Keys panel. You can read about the record and its requests in [Third party keys](/thirdpartykeys).

## What it powers

AI actions other than Ask Nextspace use this key. These include AI suggested Data Transforms, AI suggested Data Mappings and Document View hot-spot detection.

Embeddings and the Entity summaries made while generating them run on separate self-hosted services configured for the deployment, and do not use this key.

## Set the key

### Set the OpenAI key

```http
POST https://{accountId}.api.nextspace.host/programkey
```

**Requires:**

- Account ID: Account ID must be specified in the subdomain of the request url.
- Logged in user auth token: A token for an active user session on the account, sent as "Authorization: Bearer <token>".

| Parameter | In | Required | Description |
| --- | --- | --- | --- |
| `{accountId}` | path | yes | The account id of the account to perform the request on. |

**Example request body**

```json
{
    "ProgramId": "ChatGPT",
    "Key": "your-openai-api-key"
}
```

**Response**

```typescript
// The response is the saved Program Key record.
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/programkey";
const method = "post";
const token = "your-token";
const body = {
    "ProgramId": "ChatGPT",
    "Key": "your-openai-api-key"
};

async function doRequest(type, url, body, token) {
    const headers = {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json"
    };
    const options = {
        method: type,
        headers: headers,
        body: body ? JSON.stringify(body) : null
    };
    const res = await fetch(url, options);
    const json = await res.json();
    return json;
}

doRequest(method, url, body, token).then((res) => {
    console.log(res);
}).catch((err) => {
    console.error(err);
});
```

---

Urls on this page are resolved for account `{accountId}`.
Site index: https://docs.nextspace.host/llms.txt · whole site in one file: https://docs.nextspace.host/llms-full.txt
Human-readable version of this page: https://docs.nextspace.host/thirdpartykeysopenai
