Codex CLI

Codex CLI 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.

Create an account at platform.respan.ai and grab an API key. For gateway, also add credits or a provider key.

Run npx @respan/cli setup to set up with your coding agent.

Setup

Prerequisite: Codex CLI must be installed before integrating with Respan.

$npm install -g @openai/codex
1

Install the Respan CLI

$npm install -g @respan/cli
2

Set your API key

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
3

Integrate

$respan integrate codex-cli

This automatically configures Codex CLI’s notify hook to send traces to Respan.

4

Use Codex CLI normally

$codex "Add input validation to the user registration form"

All conversations are now traced automatically.

5

View your trace

Open the Traces page to see your Codex CLI conversations with reasoning, tool calls, and responses.

Configuration

Customize the integration with flags.

$respan integrate codex-cli --customer-id "frank" --project-id "proj-123" --span-name "my-app"
FlagEnv varDefaultDescription
--globalBothWrite user-level global config (~/.codex/config.toml).
--localBothWrite per-project config (.codex/respan.json).
--customer-idRESPAN_CUSTOMER_IDCustomer/user identifier for traces.
--project-idRESPAN_PROJECT_IDRespan project ID.
--span-namecodex-cliRoot span name.
--workflow-namecodex-cliWorkflow name for traces.
--attrsCustom attributes JSON (e.g. '{"env":"prod"}').
--base-urlRESPAN_BASE_URLhttps://api.respan.ai/apiRespan API base URL.
--dry-runPreview changes without writing files.

Captured data

DataDescription
User promptThe user’s input text.
Assistant responseCodex CLI’s final response.
Thinking blocksReasoning content.
Tool callsTool name, input, and output (file operations, shell commands, etc.).
Token usageInput, output, and cache tokens (when available).
TimingStart time, end time, latency.
ModelModel name used (e.g. codex-mini, o4-mini).

Span types

Spanlog_typeDescription
RootagentThe complete conversation turn.
ThinkinggenerationReasoning blocks.
TooltoolTool invocations.

Uninstall

To remove the integration:

$respan integrate codex-cli --remove