---
title: OpenAI Codex
description: >-
  Track Codex analytics and classified turn-level cost, token, and activity
  metrics.
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.1.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 Codex analytics and optional turn-level activity, reports it to Datadog as standard metrics, and uses engagement data to attribute AI-assisted pull requests in AI Impact. Engineering leaders can measure Codex adoption, understand classified work, and correlate AI usage with software delivery performance.

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

The integration 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.
- **Optional turn metrics**: Stable turn and session identity, Work Insights classification, token usage, credits, estimated cost, duration, response counts, and skill, plugin, and artifact activity.

Analytics metrics are collected once per day. Optional turn metrics are collected hourly from the Compliance Logs Platform. Turn cost is a provider estimate derived from credits and can differ from invoiced charges.

### Turn metric tags and aggregation{% #turn-metric-tags-and-aggregation %}

All turn metrics include `event_id`, `turn_id`, and `turn_key`. When available, they also include `thread_id`, `session_id`, `gen_ai.conversation.id`, `user_id`, `user_email`, `codex_client`, `model`, `model_speed`, and `gen_ai.request.reasoning_effort`.

Work Insights classification uses `work_insights_taxonomy_version`, `work_insights_level_1`, and `work_insights_level_2`. The `work_insights_coverage` tag is `complete`, `partial`, or `unavailable`, indicating which classification fields the source supplied.

`openai.codex.turn.completed` also includes `cost_coverage` and `token_usage_coverage`. Cost points include `cost_role:attribution`, `cost_source:codex_turn_compliance`, and `cost_fidelity:provider_estimate`. Skill points add `skill_id`, `skill_name`, and `skill_scope`; plugin points add `plugin_id`, `plugin_name`, `plugin_category`, and `marketplace_name`; artifact points add `artifact_kind` and `action`.

Turn counts, estimated cost, credits, tokens, responses, skill and plugin invocations, and artifact actions are additive count metrics. Query them with `sum` and `.as_count()`. Group additive turn metrics by `session_id` or `gen_ai.conversation.id` for session-level views. `openai.codex.turn.duration_ms` is a per-turn gauge; use an average, maximum, or percentile rather than summing it. Missing cost or token fields are omitted rather than reported as zero, while explicit zero cost remains present.

### 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.
- Analyze classified work and aggregate additive turn metrics by session.
- Attribute estimated cost, credits, and tokens to individual turns and users.
- 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 OpenAI Admin console.

### 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 Admin 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`).
1. To collect per-turn metrics, also grant `chatgpt.enterprise.compliance_logs_platform.workspace_analytics.read` to the same Admin key. A second key is not required.

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

1. Enter a unique name to identify your account in Datadog. Enter the **Codex API Key** and **Codex Workspace ID** from OpenAI.
1. To send engagement data to [AI Impact](https://docs.datadoghq.com/delivery_performance/ai_impact.md), select **Use for attribution in AI Impact**.
1. To collect turn-level identity, classification, token usage, credits, estimated cost, and tool activity, select **Enable Codex turn metrics**.
1. Click **Create Account**.

Usage, code-attribution, and code-review metrics are collected once per day. When enabled, Codex turn metrics are collected hourly. View the data in the **OpenAI Codex Overview** dashboard or [Metrics Explorer](https://app.datadoghq.com/metric/explorer). If you enabled AI Impact, also check the [Delivery Performance Explorer](https://app.datadoghq.com/ci/dora/ai-impact).

If the Admin key does not have the Compliance Logs workspace-analytics permission, only the **Codex Turn Metrics** dataflow reports a configuration error; the existing analytics collection remains healthy.

## 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.                                                 |
| **openai.codex.turn.completed**(count)                              | Completed Codex turns with stable turn and session identity and Work Insights classification. |
| **openai.codex.turn.cost.usd.additive**(count)                      | Estimated USD cost attributed to completed Codex turns.*Shown as dollar*                      |
| **openai.codex.turn.credits**(count)                                | Codex credits attributed to completed turns.                                                  |
| **openai.codex.turn.tokens.uncached_input**(count)                 | Uncached input tokens attributed to completed Codex turns.                                    |
| **openai.codex.turn.tokens.cached_input**(count)                   | Cached input tokens attributed to completed Codex turns.                                      |
| **openai.codex.turn.tokens.output**(count)                          | Output tokens attributed to completed Codex turns.                                            |
| **openai.codex.turn.duration_ms**(gauge)                           | Duration of completed Codex turns.*Shown as millisecond*                                      |
| **openai.codex.turn.responses**(count)                              | Responses generated during completed Codex turns.                                             |
| **openai.codex.turn.skill_invocations**(count)                     | Skill invocations during completed Codex turns.                                               |
| **openai.codex.turn.plugin_invocations**(count)                    | Plugin invocations during completed Codex turns.                                              |
| **openai.codex.turn.artifact_actions**(count)                      | Codex-owned artifact actions during completed turns.                                          |

## 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/)
