Skip to main content

OpenAI Codex

This article explains how to connect OpenAI Codex to Pensero using Open Telemetry, what data Pensero imports.

Written by Wayne

Overview

Pensero collects OpenAI Codex usage with OpenTelemetry. Each developer's Codex CLI and Codex app send their usage to Pensero while they work.

With this data, Pensero shows for each developer and each day:

  • AI lines: lines that Codex added and removed

  • Models: the models used, and the processing mode (for example Fast)

  • Tokens: input, output and cached tokens

  • Cost: calculated from the list price of each model

  • Sessions: the number of Codex conversations

Pensero aligns this data with your delivery data, so you can see how Codex helps your teams deliver.

Pensero does not store prompts, source code, patch text or command output.

The OpenAI Admin API key is no longer available

You can no longer connect Codex with an OpenAI Admin API key. That option only gave usage billed per API key, with no AI lines and no usage from ChatGPT seats. OpenTelemetry is now the only way to connect Codex.

If your organization connected an Admin API key before, set up developer telemetry as shown below to get the full data.

No historical data

Pensero does not import past Codex usage. Data starts on the day each developer's computer has the Pensero configuration. Usage from before that day does not show in Pensero.

Before you start

  • A Pensero admin generates the organization token (Step 1).

  • Each developer signs in to Codex with their ChatGPT account. With an API key sign in, Codex does not send the developer's email, so Pensero cannot link the usage to a person.

  • The email of the Codex account is the same as the developer's email in Pensero. If it is different, the usage shows in Data health > Unlinked accounts, where an admin can link it to the correct person.

Step 1: Generate the organization token

  1. Go to Integrations > OpenAI Codex.

  2. In Setup & developer configuration, find the Developer telemetry setup card.

  3. Click Generate organization token. Pensero shows the [otel] configuration to give to your developers.

The configuration holds your organization token secret. Send it only to your developers. If it leaks, click Regenerate token and send the new configuration.

Step 2: Add the configuration to each computer

Choose one of these two options.

Option A: Each developer adds it

  1. Open the global Codex configuration file ~/.codex/config.toml. The Codex CLI and the Codex app both read this file.

  2. Paste the [otel] section from Pensero. If the file already has an [otel] section, replace it.

  3. Restart Codex: quit the Codex app, or start a new CLI session.

Developers with Pensero login can also copy the configuration from Profile & settings > Linked accounts > Track your AI tool usage > Codex.

Do not set OTEL_* environment variables for Codex. They replace the values in config.toml, and some values stop Codex from starting.

Option B: Managed settings for all developers

If your organization manages its computers, push the same [otel] section to all developers. Developers then do not edit their own file, and they cannot change the Pensero configuration.

  1. Copy the [otel] section from Pensero into a file, for example otel.toml.

  2. Push it with one of these methods:

    • macOS MDM (Jamf, Fleet, Kandji): encode the file with base64 -i otel.toml. Create a configuration profile with a custom setting for the preference domain com.openai.codex, key config_toml_base64, and the base64 text as the value. Deploy the profile.

    • Managed file: copy the section to /etc/codex/managed_config.toml on macOS and Linux, or to ~/.codex/managed_config.toml on Windows.

  3. Test on one computer first with the health check in Step 3. If the value is not valid base64 or TOML, Codex does not start.

Step 3: Run the health check

Each developer runs the health check after the configuration is on their computer. The check reads the Codex configuration, asks you to sign in to Pensero, and sends one test request. Pensero does not count the test request as usage.

macOS and Linux: run this in a terminal.

curl -fsSL https://pensero.ai/otel/codex/report | sh -s -- --check

Windows: run this in PowerShell.

& ([scriptblock]::Create((irm https://pensero.ai/otel/codex/report.ps1))) --check

The check shows each setting and where it comes from, the email that Codex sends, and if Pensero received the test request. All lines must pass.

The check needs Pensero login. Developers without login cannot run it. Their manager confirms their data in Step 4.

Step 4: Confirm that Pensero collects your data

Usage shows in Pensero about 15 minutes after the Codex session stops.

  1. Open AI impact > Raw data in your own profile.

  2. Find the rows with the provider Codex. There is one row for each day.

  3. Check the AI lines, sessions, tokens and cost of today.

You see AI impact in your profile only if your organization lets people see it. If you do not see it, ask your manager to check.

Managers can check their whole team in AI-assisted > Raw data. A developer with no Codex rows after a Codex session is not set up correctly.

If the check fails or data is missing

  • Make sure that config.toml has only one [otel] section.

  • Remove OTEL_* variables from your shell profile, for example from an earlier Claude Code setup.

  • Sign in to Codex with your ChatGPT account, not with an API key.

  • Restart Codex after each change.

  • If the email of your Codex account is not your Pensero email, ask your admin to link the account in Data health > Unlinked accounts.

  • If the data is still missing, read Diagnosing Missing or Incorrect AI Data.

Did this answer your question?