> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vantage.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI

> Connect OpenAI to Vantage to track cost and usage from both the OpenAI Platform and OpenAI Codex.

export const VantageIpAddresses = () => <ul>
    <li><code>54.87.66.45</code></li>
    <li><code>3.95.43.133</code></li>
    <li><code>54.162.3.72</code></li>
    <li><code>44.199.143.63</code></li>
    <li><code>3.218.103.23</code></li>
  </ul>;

Vantage ingests OpenAI cost and usage data from two independent data sources. You can connect either source on its own or connect both for a complete view of your OpenAI spend:

* **OpenAI Platform**: programmatic OpenAI usage accessed through the [OpenAI Platform Costs API](https://platform.openai.com/docs/api-reference/usage/costs), broken down by operation (e.g., Chat and Completions, Images, or Embeddings) and model (e.g., gpt-4o). Connected with a read-only **Admin API key**.
* **OpenAI Codex**: Codex usage from a ChatGPT workspace, broken down by Codex client (e.g., Codex CLI, Codex Web, or Codex VS Code), model, and token type. Connected with a **Codex Analytics API key** and workspace ID.

[Usage data](/usage_based_reporting) is available for both data sources, measured in tokens. Vantage tags every row with an `openai:billing_source` value (`admin` for OpenAI Platform or `codex_analytics` for OpenAI Codex), so you can filter, group, and allocate costs by data source. See [OpenAI Reporting Dimensions](#openai-reporting-dimensions) for details.

<Note>
  Codex Analytics is available only for **OpenAI Enterprise** customers with a ChatGPT Enterprise workspace. The OpenAI Platform data source has no such requirement.
</Note>

<Note>
  To attribute OpenAI spend to teams, users, applications, and features by your own per-request dimensions, see [Custom LLM Enrichment](/custom_llm_enrichment), which joins per-request token telemetry you deliver to S3 with your OpenAI Platform costs.
</Note>

## OpenAI Data Sources

The table below summarizes the two data sources, what each captures, and what you need to connect them. In Cost Reports, you can filter by the `openai:billing_source` tag to see which data source is associated with a given cost row.

| Data Source     | What It Captures                                                   | Key                                                                                    | Requirement                                                                                       | `openai:billing_source` |
| --------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------- |
| OpenAI Platform | API cost and usage by operation, model, project, and API key       | Admin API key (`sk-admin-`)                                                            | OpenAI Organization Owner                                                                         | `admin`                 |
| OpenAI Codex    | Codex cost and usage by client, model, token type, speed, and user | Codex Analytics API key (scoped to `codex.enterprise.analytics.read`) and workspace ID | OpenAI Enterprise account with a ChatGPT Enterprise workspace that has Codex Analytics API access | `codex_analytics`       |

<Info>
  The two data sources fill the shared dimensions differently. On OpenAI Platform rows, **Account** is the project and **Resource** is the API key ID. On OpenAI Codex rows, **Billing Account (Organization)** is the workspace ID, **Account** is the account name you set at connect, and **Resource** is the user's email. **Service** is an operation on Platform rows and a Codex client on Codex rows. Filter on the `openai:billing_source` tag to keep a report focused on one data source.
</Info>

<Note>
  This integration covers OpenAI costs billed directly by OpenAI. OpenAI models accessed through **Azure OpenAI** are captured under your [Azure](/connecting_azure) cost integration instead.
</Note>

## OpenAI Permissions

Vantage cannot perform cost-incurring actions and only ever reads cost and usage data from OpenAI.

### OpenAI Platform Permissions

OpenAI requires a read-only Admin API key to access the [Costs API endpoint](https://platform.openai.com/docs/api-reference/usage/costs). The Costs endpoint is not available to non-admin API keys. Vantage only reads from this endpoint and never performs any action that incurs costs. You must be an *Organization Owner* in your OpenAI organization to create an Admin key.

### OpenAI Codex Permissions

Codex Analytics is available only for **OpenAI Enterprise** customers with a ChatGPT Enterprise workspace. OpenAI requires a dedicated Codex Analytics API key scoped to `codex.enterprise.analytics.read` to access the [Codex Analytics API](https://developers.openai.com/codex/enterprise/analytics-api). The key's Platform organization must match the organization associated with the ChatGPT workspace you connect. Vantage reads only aggregated Codex analytics data for that workspace; it does not ingest prompts, generated code, or raw audit-event content, and it cannot run Codex tasks or change workspace settings.

Vantage stores only usage metadata (e.g., token consumption). The imported daily aggregates can include user email and user ID, which Vantage uses for Resource and tag-based reporting.

## Connect Your OpenAI Account

You can connect the OpenAI Platform, OpenAI Codex, or both. Each data source has its own key and its own connection flow in Vantage. Both appear under the **OpenAI** provider in Cost Reports.

### Prerequisites

* You must have a Vantage **Organization Owner** or **Integration Owner** role to add or remove this integration. See the [Role-Based Access Control](/rbac) documentation for details.
* For the **OpenAI Platform**, you must be an *Organization Owner* in your OpenAI organization to create a read-only Admin key.
* For **OpenAI Codex**, you must be an **OpenAI Enterprise** customer with a ChatGPT Enterprise workspace that has Codex Analytics API access, and be able to provision a dedicated Codex Analytics API key whose Platform organization matches the organization associated with the workspace.
* [Create a free Vantage account](https://console.vantage.sh/signup), then follow the steps below to integrate OpenAI costs.

<Info>
  If your organization restricts access to the provider by IP address, add the following Vantage IP addresses to your provider's allowlist:

  <VantageIpAddresses />
</Info>

### Connect the OpenAI Platform

Use this data source to track programmatic OpenAI usage from the Platform Costs API.

<Steps>
  <Step>
    Navigate to the [Admin Keys](https://platform.openai.com/settings/organization/admin-keys) page of the OpenAI console, and log in using your company email.
  </Step>

  <Step>
    At the top, click **+ Create new Admin key**.
  </Step>

  <Step>
    For **Name**, add an identifiable name, like *Vantage Integration*.

    <Accordion title="Click to view example image">
      <Frame>
        ![Create API key modal with a number 1 next to the Create new secret key button and number 2 next to the input field for the key name](https://assets.vantage.sh/docs/openai-admin-key.png)
      </Frame>
    </Accordion>
  </Step>

  <Step>
    For **Permissions**, select **Read only**.
  </Step>

  <Step>
    Click **Create admin key** and copy the generated key. Admin keys start with `sk-admin-`.
  </Step>

  <Step>
    Navigate to the **Connect** tab of the [OpenAI Settings](https://console.vantage.sh/settings/open_ai?connect=true) page in the Vantage console. In the **OpenAI Platform** section, click **Add Admin API Key**.
  </Step>

  <Step>
    The **New OpenAI Account** modal is displayed. For **API key**, paste your previously generated Admin Key. For **Description**, enter any descriptor to identify that you've added this integration, such as your name.

    <Accordion title="Click to view example image">
      <Frame>
        ![The API key account modal in the Vantage console with sample data added](https://assets.vantage.sh/docs/open-ai-add-key.png)
      </Frame>
    </Accordion>
  </Step>

  <Step>
    Click **Connect Account**.
  </Step>
</Steps>

### Connect OpenAI Codex

Use this data source to track Codex usage across clients like Codex CLI, Codex Web, and Codex VS Code. You connect a single ChatGPT workspace per integration; connect multiple workspaces as separate integrations if needed.

<Note>
  Codex Analytics is available only for **OpenAI Enterprise** customers. Confirm your organization is on OpenAI Enterprise before you begin; Codex Analytics is not available for non-Enterprise plans.
</Note>

<Steps>
  <Step>
    Log in to the [OpenAI Admin Console](https://admin.openai.com/), then go to **Credentials** > **Admin keys**.
  </Step>

  <Step>
    Click **Create new admin key**. Select the ChatGPT workspace you want Vantage to report on.

    <Note>
      The key's Platform organization must match the organization associated with the ChatGPT workspace you plan to connect.
    </Note>
  </Step>

  <Step>
    Enter a **Name**, then set **Permissions** to **Restricted** or **Custom**.
  </Step>

  <Step>
    Enable the **Codex Analytics: Read** (the `codex.enterprise.analytics.read` scope).
  </Step>

  <Step>
    Click **Create admin key**, then copy the key.

    <Note>
      It's best practice to use a dedicated key for Vantage, store it in your organization's secret-management system, and rotate it according to your security policy.
    </Note>
  </Step>

  <Step>
    From the **Workspace details** in the [ChatGPT Admin Console](https://chatgpt.com/admin), copy your **Workspace ID**.
  </Step>

  <Step>
    Navigate to the **Connect** tab of the [OpenAI Settings](https://console.vantage.sh/settings/open_ai?connect=true) page in the Vantage console. In the **OpenAI Codex** section, click **Add Analytics API Key**.
  </Step>

  <Step>
    The **New OpenAI Codex Account** modal is displayed. Paste your **Codex Analytics API Key**, enter your **Codex Workspace ID**, and enter an **Account Name** to label this connection in Vantage.

    <Note>
      The Analytics API does not expose an account name, so the **Account Name** you enter is used to identify this connection in the Vantage UI and as the **Account** dimension on Codex cost rows.
    </Note>
  </Step>

  <Step>
    Click **Connect Account**.
  </Step>
</Steps>

After you connect a data source, the integration status changes to **Importing** within the Vantage console, indicating that Vantage is actively importing your OpenAI cost data. On initial connection, Vantage backfills OpenAI Platform costs and imports up to the most recent 90 days of Codex data available from the Analytics API. See the [Integration Status](/vantage_account#integration-status) documentation for details on integration statuses.

<Info>
  As soon as costs are processed, they will be available on your **All Resources** Cost Report. If you remove an OpenAI integration from Vantage, all costs associated with that OpenAI key are removed from the Vantage console.
</Info>

### Next Steps - Manage Workspace Access

Once the import is complete and the integration status changes to **Stable**, you can select which workspaces each integration is associated with. See the [Workspaces](/workspaces#manage-workspace-provider-integrations) documentation for information.

## Data Refresh

See the [provider data refresh documentation](/provider_data_refresh) for information on when data for each provider refreshes in Vantage. Both OpenAI data sources refresh once daily.

## OpenAI Reporting Dimensions

On OpenAI [Cost Reports](/cost_reports), you can filter and group across several dimensions. The values available for each dimension depend on the data source, as shown below.

| Dimension                      | OpenAI Platform                                            | OpenAI Codex                                             |
| ------------------------------ | ---------------------------------------------------------- | -------------------------------------------------------- |
| Billing Account (Organization) | Organization                                               | Workspace ID                                             |
| Account                        | Project                                                    | Account Name (entered at connect)                        |
| Service                        | Operation (e.g., Chat and Completions, Images, Embeddings) | Codex client (e.g., Codex CLI, Codex Web, Codex VS Code) |
| Category                       | Model (e.g., gpt-4o)                                       | Model                                                    |
| Subcategory                    | Token type (e.g., input, output, cached input)             | Token type (uncached input, cached input, output)        |
| Resource ID                    | API key ID                                                 | User email                                               |
| Charge Type                    | Usage                                                      | Usage                                                    |

<Info>
  When OpenAI Platform appends billing qualifiers to a line item, the token type is retained ahead of the qualifier in the **Subcategory**, such as "input, long context".
</Info>

In addition, OpenAI costs include the following provider tags, which are automatically created by Vantage and available for filtering and grouping alongside any [Virtual Tags](/tagging) you create. The **Source** column indicates which data source populates each tag.

| Tag                       | Description                                                                                           | Source               |
| ------------------------- | ----------------------------------------------------------------------------------------------------- | -------------------- |
| `openai:billing_source`   | The data source the row came from (`admin` for OpenAI Platform or `codex_analytics` for OpenAI Codex) | Both                 |
| `openai:api_key_id`       | The OpenAI API key ID associated with the usage                                                       | OpenAI Platform only |
| `openai:owner_name`       | The name of the OpenAI API key's owner, when available                                                | OpenAI Platform only |
| `openai:owner_email`      | The email of the OpenAI API key's owner, when available                                               | OpenAI Platform only |
| `openai:endpoint_type`    | The endpoint type for the usage (e.g., `regional`), when applicable                                   | OpenAI Platform only |
| `openai:client_id`        | The Codex client that generated the usage (e.g., `CODEX_CLI`)                                         | OpenAI Codex only    |
| `openai:model`            | The model name associated with the usage                                                              | OpenAI Codex only    |
| `openai:speed`            | The service speed tier for the usage                                                                  | OpenAI Codex only    |
| `openai:user_email`       | The email of the user associated with the usage                                                       | OpenAI Codex only    |
| `openai:user_id`          | The stable user ID associated with the usage                                                          | OpenAI Codex only    |
| `openai:cost_attribution` | Set to `unattributed` on reconciliation rows for spend not attributable to a specific user            | OpenAI Codex only    |

Vantage also applies [Managed AI Tags](/managed_ai_tags) to OpenAI costs. This is a normalized `vntg:ai:` schema shared across all AI providers, so you can analyze AI spend with consistent dimensions. For OpenAI, the following keys are emitted: `vntg:ai:model`, `vntg:ai:raw_model`, `vntg:ai:model_provider`, `vntg:ai:provider_region`, `vntg:ai:service_tier`, `vntg:ai:token_type`, `vntg:ai:user_id`, and `vntg:ai:api_key_id`. See [Managed AI Tags](/managed_ai_tags) for the full schema.

[Usage data](/usage_based_reporting) is available for OpenAI, measured in tokens, when usage enrichment data is available.

<Note>
  **Notes on OpenAI Codex costs:**

  * Codex client- and token-type dollar amounts are allocation estimates. Vantage allocates OpenAI's model-level estimated costs across clients and token types so the resulting rows reconcile to OpenAI's imported model-level estimated cost. Model-level estimated cost and speed originate from OpenAI's model breakdown.
  * Tax is not included. OpenAI's Codex Analytics API reports estimated cost that does not include tax.
</Note>

### View OpenAI Codex Spend by User

For **OpenAI Codex** spend, cost rows use the user's email as the **Resource ID** and include the `openai:user_email` tag, so you can group a Cost Report by **Resource** or filter and group by the `openai:user_email` tag. The stable user identifier is also available as the `openai:user_id` tag. Codex spend that OpenAI reports at the workspace level but does not attribute to a specific user appears on a reconciliation row tagged `openai:cost_attribution` = `unattributed`.
