Copied to clipboard

Codex Setup

Launch Codex through tapes to capture every conversation automatically.

Codex needs an explicit API key

Codex normally authenticates with a ChatGPT OAuth token, which tapes can't forward. Store an OpenAI service account key (sk-svcacct-...) with tapes auth openai first — tapes uses it for the session and restores your original Codex auth on exit.

Quick Start

1. Store an OpenAI key

Create a service account key at platform.openai.com/api-keys (scope: All), then:

tapes auth openai
# Enter your service account key (sk-svcacct-...)

2. Launch Codex through tapes

tapes start codex

This automatically:

  • Starts the tapes daemon with auto-selected ports
  • Points Codex at the proxy via OPENAI_BASE_URL
  • Temporarily writes your stored key into ~/.codex/auth.json so Codex uses it instead of its OAuth token
  • Tags all conversations with agent_name: codex, and restores ~/.codex/auth.json when you exit

Codex speaks the OpenAI Responses API; the proxy captures it natively. Pass flags to Codex after --, e.g. tapes start codex -- --model gpt-5.2-codex.

Manual Setup

For control over ports and storage, run the proxy yourself and point Codex at it. This is what tapes start codex does under the hood.

1. Start tapes

tapes serve \
  --provider openai \
  --upstream "https://api.openai.com/v1" \
  --proxy-listen "0.0.0.0:8080" \
  --postgres "postgres://tapes:tapes@localhost:5432/tapes?sslmode=disable"

2. Point Codex at the proxy

Set the OpenAI base URL to the proxy, and make sure Codex authenticates with your API key rather than its OAuth token:

export OPENAI_BASE_URL="http://localhost:8080"
export OPENAI_API_BASE="http://localhost:8080"
codex

Launching via tapes start codex is recommended — it also patches and restores ~/.codex/auth.json for you.

Verify It's Working

After sending a message, confirm the session was captured:

tapes sessions

Your new session appears in the list, tagged agent_name: codex.

Troubleshooting

"run 'tapes auth openai' with a service account key"

Codex refuses to start until a service account key is stored. A standard sk-... key is not enough — it must be a service account key (sk-svcacct-...) with the All scope. Re-run tapes auth openai and paste that key.

Codex still uses its OAuth login

tapes start codex patches ~/.codex/auth.json for the session and restores it on exit. If you configured Codex manually, remove or override its stored OAuth token so it falls back to the API key.

Next Steps

Everything you capture is queryable the same way, whatever agent produced it:

Last updated: