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

# Codex CLI Connector

> Zero-code telemetry from OpenAI Codex CLI's built-in OpenTelemetry exporter

# 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`:

```toml theme={null}
[otel]
environment = "prod"
log_user_prompt = false  # default; prompts leave the machine as "[REDACTED]"

[otel.exporter.otlp-http]
endpoint = "https://api.meshai.dev/api/v1/ingest/v1/logs"
protocol = "json"

[otel.exporter.otlp-http.headers]
authorization = "Bearer msh_YOUR_API_KEY"
```

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.

<Note>
  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.
</Note>

## What's tracked

| Codex event                            | Becomes                                                 |
| -------------------------------------- | ------------------------------------------------------- |
| `codex.sse_event` (turn completed)     | Token usage and cost row: input, output, model, session |
| `codex.tool_decision`                  | Activity: tool name and approve/deny decision           |
| `codex.sandbox_outcome`                | Activity: sandbox escalations and outcomes              |
| `codex.user_prompt`, connection events | Activity and session liveness                           |

## 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](/getting-started/claude-code) 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).
