> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://respan.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/docs/_mcp/server.

# Codex CLI (tracing)

> Trace Codex CLI conversations with Respan — auto-instrumented spans, gateway routing, and full observability.

[Codex CLI](https://github.com/openai/codex) is OpenAI's open-source coding agent that runs in the terminal. It can reason about your codebase, make file edits, execute shell commands, and handle multi-step coding tasks autonomously. Respan gives you full observability over every conversation including reasoning, tool calls, and responses — and gateway routing through the OpenAI-compatible Respan endpoint.

#### Set up Respan

Create an account at [platform.respan.ai](https://platform.respan.ai) and grab an [API key](https://platform.respan.ai/platform/gateway/api-keys).

For application setup, follow [Agent setup](/docs/documentation/agent-setup).

#### Use Respan Gateway

See [Codex CLI gateway setup](/docs/gateway/codex-cli) to route this integration through the Respan gateway.

## Setup

Paste this into your coding agent:

```text
Help me set up Respan tracing for Codex CLI: fetch and follow https://www.respan.ai/docs/documentation/agent-setup.md
```

The agent checks your credentials, configures tracing, and verifies that a session reached Respan. Include your project, customer identifier, and preferred configuration scope in the request if needed.

## Configuration

Ask your coding agent to adjust the existing tracing configuration for your project, customer identifier, workflow name, or custom attributes. It should preserve unrelated agent settings and verify the result with Respan traces or logs.

## Captured data

| Data               | Description                                                           |
| ------------------ | --------------------------------------------------------------------- |
| User prompt        | The user's input text.                                                |
| Assistant response | Codex CLI's final response.                                           |
| Thinking blocks    | Reasoning content.                                                    |
| Tool calls         | Tool name, input, and output (file operations, shell commands, etc.). |
| Token usage        | Input, output, and cache tokens (when available).                     |
| Timing             | Start time, end time, latency.                                        |
| Model              | Model name used (e.g. `codex-mini`, `o4-mini`).                       |

## Span types

| Span     | `log_type`   | Description                     |
| -------- | ------------ | ------------------------------- |
| Root     | `agent`      | The complete conversation turn. |
| Thinking | `generation` | Reasoning blocks.               |
| Tool     | `tool`       | Tool invocations.               |

## Uninstall

Ask your coding agent:

```text
Remove Respan tracing from Codex CLI, preserving unrelated agent settings and provider configuration.
```