---
title: OpenAI Codex
description: >-
  Track Codex usage, code-review, and token metrics from the Codex Analytics
  API.
breadcrumbs: Docs > Integrations > OpenAI Codex
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# OpenAI Codex
Supported OS Integration version1.0.0
{% callout %}
# Important note for users on the following Datadog sites: us2.ddog-gov.com

{% alert level="info" %}
To find out if this integration is available in your organization, see your [Datadog Integrations](https://app.datadoghq.com/integrations) page or ask your organization administrator.

To initiate an exception request to enable this integration for your organization, email [support@ddog-gov.com](mailto:support@ddog-gov.com).
{% /alert %}

{% /callout %}
  Track Codex usage, tokens, and code changes in the Overview Dashboard.See Codex's impact on delivery in the Delivery Performance Explorer.
## Overview{% #overview %}

OpenAI Codex is OpenAI's enterprise AI coding agent. This integration collects per-user, per-day Codex activity from the Codex Analytics API, reports it to Datadog as standard metrics, and uses it to attribute AI-assisted pull requests in AI Impact. Engineering leaders can measure Codex adoption and correlate it with software delivery performance.

### What this integration collects{% #what-this-integration-collects %}

The integration polls the Codex Analytics API once per day for each enterprise workspace and emits metrics under the `openai.codex.*` namespace:

- **Usage totals**: Threads, turns, credits, and token counts for each engineer.
- **Usage breakdowns**: Token counts by model, and thread and turn counts by client.
- **Code attribution**: Lines of code added and removed that are attributable to Codex.
- **Code reviews**: Reviews completed and review comments by priority, with the reactions and replies those comments receive.
- **User engagement**: A daily per-engineer signal that AI Impact uses to attribute AI assistance.

Spend and dollar amounts are not collected. Credits reflect consumed Codex credits, not a currency amount.

### Dashboards and monitors{% #dashboards-and-monitors %}

- An **OpenAI Codex Overview** dashboard for usage, token consumption by model, client activity, code attribution, and code reviews.
- A recommended monitor that alerts when usage metrics stop reporting.
- [Delivery Performance Explorer](https://app.datadoghq.com/ci/dora/ai-impact), available when you enable AI Impact.

### Use cases{% #use-cases %}

- Track Codex adoption, token consumption, and engagement across teams and models.
- Measure how much code Codex contributes and how its reviews are received.
- Segment deployment frequency, lead time, change failure rate, and mean time to restore by Codex engagement.

## Setup{% #setup %}

### Prerequisites{% #prerequisites %}

- An active OpenAI enterprise subscription with Codex enabled.
- Workspace admin access to the Codex enterprise admin portal.

### Get your Codex credentials{% #get-your-codex-credentials %}

1. Sign in to [admin.openai.com](https://admin.openai.com), then go to **Credentials** → **Admin keys**.
1. Create an API key and select the workspace you'd like to collect metrics for. Note your workspace ID.
1. Choose **Restricted** permissions and enable the **Codex Analytics read** scope (`codex.enterprise.analytics.read`).

### Configure the integration in Datadog{% #configure-the-integration-in-datadog %}

1. Enter a unique name to identify your account from within Datadog. Also enter your **Codex API Key** and **Codex Workspace ID**, both copied from OpenAI on the Integration tile.
1. To send engagement data to [AI Impact](https://docs.datadoghq.com/delivery_performance/ai_impact.md), select the **Use for attribution in AI Impact** toggle.
1. Click **Create Account**.

The integration automatically collects usage, code-attribution, and code-review metrics after account configuration. Data is reported once per day, so it may take up to 24 hours for metrics to appear. You can view your data in the **OpenAI Codex Overview** dashboard or the [Metrics Explorer](https://app.datadoghq.com/metric/explorer) to confirm that usage metrics appear. If you enabled AI Impact, also check the [Delivery Performance Explorer](https://app.datadoghq.com/ci/dora/ai-impact).

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **openai.codex.usage.threads**(count)                               | Codex threads (conversations) started by the user that day            |
| **openai.codex.usage.turns**(count)                                 | User turns (messages) sent across Codex threads that day              |
| **openai.codex.usage.credits**(count)                               | Codex credits consumed by the user that day                           |
| **openai.codex.usage.tokens.uncached_input**(count)                | Uncached text input tokens processed by the user that day             |
| **openai.codex.usage.tokens.cached_input**(count)                  | Cached text input tokens processed by the user that day               |
| **openai.codex.usage.tokens.output**(count)                         | Text output tokens generated for the user that day                    |
| **openai.codex.usage.tokens.total**(count)                          | Total text tokens (input and output) processed for the user that day  |
| **openai.codex.usage.by_model.tokens.uncached_input**(count)      | Uncached text input tokens broken down by model                       |
| **openai.codex.usage.by_model.tokens.cached_input**(count)        | Cached text input tokens broken down by model                         |
| **openai.codex.usage.by_model.tokens.output**(count)               | Text output tokens broken down by model                               |
| **openai.codex.usage.by_model.tokens.total**(count)                | Total text tokens broken down by model                                |
| **openai.codex.usage.by_client.threads**(count)                    | Codex threads started via this client (for example, cli, ide, or web) |
| **openai.codex.usage.by_client.turns**(count)                      | User turns sent via this client (for example, cli, ide, or web)       |
| **openai.codex.usage.code_attribution.lines_added**(count)        | Lines of code added attributable to Codex that day                    |
| **openai.codex.usage.code_attribution.lines_removed**(count)      | Lines of code removed attributable to Codex that day                  |
| **openai.codex.code_reviews.completed**(count)                     | Pull request reviews completed by Codex                               |
| **openai.codex.code_reviews.comments.total**(count)                | Total review comments left by Codex                                   |
| **openai.codex.code_reviews.comments.p0**(count)                   | P0 (highest priority) review comments left by Codex                   |
| **openai.codex.code_reviews.comments.p1**(count)                   | P1 review comments left by Codex                                      |
| **openai.codex.code_reviews.comments.p2**(count)                   | P2 review comments left by Codex                                      |
| **openai.codex.code_review_responses.reactions.upvotes**(count)   | Upvote reactions received on Codex review comments                    |
| **openai.codex.code_review_responses.reactions.downvotes**(count) | Downvote reactions received on Codex review comments                  |
| **openai.codex.code_review_responses.reactions.other**(count)     | Other reactions received on Codex review comments                     |
| **openai.codex.code_review_responses.replies**(count)             | Codex review comments that received a reply                           |
| **openai.codex.code_review_responses.engaged**(count)             | Codex review comments that were engaged with                          |

## Uninstallation{% #uninstallation %}

To uninstall, remove all configured accounts from the **OpenAI Codex** tile in Datadog. Deleting the last account stops all data collection for this integration.

## Support{% #support %}

Need help? Contact [Datadog Support](https://app.datadoghq.com/help).

## Further Reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Measure the real impact of AI coding tools on software delivery with Datadog AI Impact](https://www.datadoghq.com/blog/ai-impact/)
- [Measure AI Coding Tool Impact](https://www.datadoghq.com/product/software-delivery/ai-impact/)
