Skip to main content

Codex CLI

OpenAI Codex CLI ships a built-in OpenTelemetry exporter. Point it at MeshAI’s OTLP logs endpoint and every Codex session is monitored with no package to install: per-turn token usage and cost, tool approval decisions, sandbox outcomes, and session activity.

Configure

Add an [otel] block to ~/.codex/config.toml:
Use an API key with the telemetry:write scope. The next Codex session (interactive or codex exec) starts exporting; the agent appears in your MeshAI registry within about a minute as codex_exec or codex_tui, framework codex, with each Codex conversation tracked as a session.
The API key sits in plaintext in config.toml, so keep the file chmod 600 and use a key scoped to telemetry:write only. Codex has no environment-variable indirection for exporter headers yet.

What’s tracked

Privacy

Only usage, model, and session metadata is persisted. MeshAI’s ingest maps Codex events onto OpenTelemetry GenAI semantic conventions at the boundary and drops everything else: prompts (already [REDACTED] by Codex unless you opt in), user.email, and auth diagnostics never reach storage. Leave log_user_prompt = false; the Codex log integration does not use prompt text.

Durability caveat

Codex’s exporter is in-process and fire-and-forget: events buffered when the process crashes or the network is down are lost. That is fine for monitoring and cost attribution. If you need evidence-grade capture with a local write-ahead log, that is what the Claude Code connector provides for Claude Code; a durable Codex connector is on the roadmap.

Requirements

Codex CLI 0.146 or later (earlier versions with the [otel] config section also work; telemetry verified against 0.147).