> For the complete documentation index, see [llms.txt](https://docs.finout.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.finout.io/billing-integrations/ai-providers/connect-to-openai.md).

# Connect to OpenAI

### Overview

Finout's OpenAI integration ingests usage and cost data across two surfaces — **OpenAI Platform** (API-based usage via the Cost API) and **OpenAI Codex** (Enterprise usage via the Codex Analytics API). You connect either or both, and your OpenAI spend appears alongside your other cloud and SaaS services in [MegaBill](https://docs.finout.io/user-guide/inform/megabill) for a unified view.

The two surfaces are:

* **OpenAI Platform** — usage and cost data via the Cost API (models, tokens, projects, users).
* **OpenAI Codex** — usage and cost data via the Codex Analytics API, across the CLI, IDE extension, cloud agent, desktop app, and GitHub/Code Review surfaces.

With this integration, you can:

* Connect one or both OpenAI surfaces, and one or more OpenAI organizations.
* Include OpenAI cost and usage data in [custom dashboards](https://docs.finout.io/user-guide/inform/finops-dashboards), set up alerts to [track anomalies](https://docs.finout.io/user-guide/optimize/anomalies), and incorporate it into your [financial plans](https://docs.finout.io/user-guide/inform/financial-plans).

{% hint style="info" %}
**Note:** Finout uses read-only access to OpenAI APIs. It does not perform actions that can create, modify, or incur costs.
{% endhint %}

### Before you start

Each surface you connect requires its own credentials:

* **OpenAI Platform** requires an **Admin API key**. You must be an **Organization Owner** to create one.
* **OpenAI Codex** requires an **Analytics API key** and your **Codex Workspace ID**. You must have Codex enabled on a **ChatGPT Enterprise** plan, with access to the [OpenAI Platform Portal](https://platform.openai.com) to create the key and the [ChatGPT Admin console](https://chatgpt.com/admin) to find your Workspace ID.

#### Step 1: Create your OpenAI credentials

Create a key for each surface you plan to connect.

**OpenAI Platform — Admin API key**

{% hint style="success" %}
**Prerequisite:** Only Organization Owners can create Admin API keys.
{% endhint %}

1. **Go to** the [OpenAI Admin Keys page](https://platform.openai.com/settings/organization/admin-keys).
2. **Click** **+ Create new admin key**.
3. **Add** a **Name** (e.g. "Finout Integration") and set **Permissions** to **Read only** (or **Restricted**, with the Usage API scope and Organization Administration set to read-only).\
   ![](/files/WxcLIWeU4kgwCY6BO2e1)
4. **Click** **Create admin key**. Copy it immediately — it will not be shown again.

{% hint style="info" %}
**Note:** Only Admin API keys can access the Usage API endpoints. Finout cannot perform any actions that incur costs, but OpenAI requires an Admin key to read usage data.
{% endhint %}

**OpenAI Codex — Analytics API key and Workspace ID**

{% hint style="success" %}
**Prerequisite:** You must be an owner or admin on a ChatGPT Enterprise plan with Codex enabled.
{% endhint %}

**Collect your Workspace ID:**

1. **Log in** to the [ChatGPT Admin console](https://chatgpt.com/admin).
2. **Navigate** to **Workspace details**.
3. **Copy** your **Workspace ID** — this is a ChatGPT UUID, distinct from your OpenAI organization ID. Save it for the connection step below.

**Create an Analytics API key:**

The Codex Analytics API key comes from the **OpenAI Platform Portal** (`platform.openai.com`) — not the ChatGPT Admin console.

1. **Go to** [platform.openai.com/api-keys](https://platform.openai.com/api-keys). Sign in as an owner or admin and confirm you're in the correct organization and project.
2. **Click** **Create new secret key**. Name it something descriptive (e.g. "Codex Analytics API") and set permissions to **Read only**.
3. **Copy** the key immediately — you cannot view it again after creation.
4. **Email** OpenAI support at <support@openai.com> with the last 4 digits of the key, the key name, and the name of the key creator, and request the key be scoped to `codex.enterprise.analytics.read`.

{% hint style="warning" %}
**This scoping step requires a manual reply from OpenAI support** before the key can access Codex Analytics — wait for their confirmation before entering it in Finout.
{% endhint %}

#### Step 2: Connect OpenAI to Finout

1. In Finout, **navigate** to **Settings > Cost Centers** and **click** **Add cost center**.

<figure><img src="/files/FIeYWUaPYdDwgfbBCA6l" alt="" width="563"><figcaption></figcaption></figure>

2. Under **OpenAI**, **click** **Connect Now**. The OpenAI integration pop-up opens.

<figure><img src="/files/pLlexMPZhDL2d2e23d1R" alt="" width="563"><figcaption></figcaption></figure>

3. **Enter** a **Cost Center Name**.
4. Under **Select the OpenAI products to connect**, **select** **OpenAI Platform**, **OpenAI Codex**, or both.

<figure><img src="/files/8T6Mg3QwgPSqzRPa4NH1" alt="" width="563"><figcaption></figcaption></figure>

5. **Enter** the credentials for each product you selected:
   * **OpenAI Platform API Key** — the Admin API key from Step 1.
   * **OpenAI Codex API Key** — the Analytics API key from Step 1.
   * **OpenAI Codex Workspace ID** — the Workspace ID from Step 1.
6. **Click** **Complete Setup** if you selected OpenAI Platform only, or **Next** if you selected OpenAI Codex, to continue to credit pricing.

{% hint style="info" %}
Finout validates each credential on submit with a lightweight, read-only check. If a key or Workspace ID is invalid, the error identifies exactly which field failed.
{% endhint %}

If you connected OpenAI Platform only, your Cost Center is created here — skip ahead to What happens next. If you connected OpenAI Codex, continue below.

#### Step 3: Configure Credit Pricing (OpenAI Codex only)

OpenAI's Codex Analytics API reports **credit consumption**, not dollars. Finout calculates your cost as credits × price per credit, using the rate(s) you enter here — this figure comes from your OpenAI contract and isn't available through any API, so confirm it with your OpenAI account manager if you're unsure.

<figure><img src="/files/F8iCjkUgAXDLDQCHf5FG" alt="" width="563"><figcaption></figcaption></figure>

**1. Ongoing pricing** — the rate applied to your current usage onward:

* **Price Per Credit (USD)**
* **Start Date** — the date this rate takes effect

**2. Historical pricing for backfilling (optional)** — define previous pricing periods, for up to 13 months, so backfilled historical data is costed at the rate that was actually in effect at the time.

**Click Next** to review your entries on the **Credit Pricing Summary** step, then **click Complete Setup**.

#### What happens next

Your Cost Center is created, and you'll receive an email notification once Finout has retrieved your data. OpenAI data is backilled for the current month and up to two previous months.

#### Editing your integration

You can edit your OpenAI Platform key, Codex key, Workspace ID, price-per-credit schedule, or Cost Center Name at any time from **Settings > Cost Centers**. Editing a credential re-triggers the same validation check. Once done, you can contact Finout support at <support@finout.io> to back-correct data based on your edit.

### Understanding the OpenAI Origin dimension

When you connect both surfaces, every OpenAI row in MegaBill carries an **OpenAI Origin** dimension identifying which surface it came from:

* **OpenAI Platform** — rows ingested via the Cost API.
* **Codex** — rows ingested via the Codex Analytics API.

Some fields apply to only one surface:

| Field                                       | OpenAI Platform | OpenAI Codex                                                          |
| ------------------------------------------- | --------------- | --------------------------------------------------------------------- |
| Project Name, Project ID                    | Yes             | Empty                                                                 |
| API Key                                     | Yes             | Empty — Codex usage is user-authenticated, not key-metered            |
| Organization ID                             | Yes             | Empty — Codex is workspace-scoped                                     |
| Speed (standard / fast)                     | Empty           | Yes                                                                   |
| User Email                                  | Empty           | Yes, when your workspace exposes it — falls back to User ID otherwise |
| Actor Type (Account User / Service Account) | Empty           | Yes                                                                   |
| Model, Token Type, User ID                  | Yes             | Yes                                                                   |

### Codex API Constraints

* **Codex Enterprise seat fees aren't included.** OpenAI invoices flat per-seat Codex fees separately, and they never appear in the Analytics API — Finout reflects consumption spend only.
* **Token-level cost isn't available for Codex.** The Codex API reports credits per user, day, model, and speed, but doesn't break credits down by token type — so token type rows show usage without cost.

### FAQs

**Which OpenAI services does Finout support?**

* Finout retrieves cost data for all OpenAI Platform services, and detailed usage data for Completions and Images. Usage data for Embeddings, Vector Stores, Code Interpreter Sessions, Moderations, Audio Speeches, and Audio Transcriptions is expected in upcoming months.

{% hint style="info" %}
**Note:** If you identify a service that isn't yet supported, contact Finout support at <support@finout.io>
{% endhint %}

**Does Finout track historical name changes to OpenAI Projects or Users?**

Finout shows data exactly as returned by OpenAI's API, which doesn't provide point-in-time names for Projects or Users. Project IDs and User IDs are unique and immutable, so this only affects display names: renaming a Project or User in OpenAI updates the name across all historical data, and if a User is deleted, Finout still shows the user ID but not the name.

**Can I use one Cost Center for both OpenAI Platform and Codex?**

Yes. They're two ingestion paths under a single OpenAI integration — connect either or both under one Cost Center Name.

**Why is my Codex cost lower than my OpenAI invoice?**

Codex Enterprise seat fees are invoiced separately by OpenAI and aren't included in Finout's Codex numbers — Finout reflects consumption (credit) spend only.

**Why don't I see my onboarded Codex cost center?**

Codex is reported as part of an OpenAI cost center. For Codex-specific costs, use the Origin dimension and filter it for the 'Codex' value.

***

{% hint style="info" %}
**Need help?** If you run into any issues during setup, contact our support team at <support@finout.io> — we're happy to help.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.finout.io/billing-integrations/ai-providers/connect-to-openai.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
