StackSpendDocs

Codex

Track OpenAI Codex agent usage via OpenTelemetry for per-session cost attribution.

What this provider does

The Codex provider collects usage data from OpenAI Codex-based agents via OpenTelemetry (OTel). Codex agents emit cost and token telemetry as they run — StackSpend receives that telemetry and turns it into estimated cost line items, broken down by session and agent.

This works the same way as the Claude OTel provider. Cost figures are estimated from agent telemetry, not pulled from a billing API, so they are useful for trend tracking, attribution, and early warning — not as an exact invoice replacement.

No credentials are required. StackSpend generates a connection ID that you embed in your OTLP endpoint URL.

Looking for direct OpenAI API billing?.This provider tracks OTel-based estimated usage from Codex agents specifically. If you want to pull your OpenAI invoice data — covering the full OpenAI API, not just Codex agents — connect the OpenAI provider instead.

Who should use this

Teams running OpenAI Codex-based agents locally or in CI who want per-session cost attribution without switching to a different billing integration. If your agents support OTLP export, this is the fastest way to get Codex spend into StackSpend dashboards and alerts.

MetricDetail
Latency~1 hour
Historical dataFrom setup date
Setup time~5 minutes

Setup

1

Add the Codex provider

  1. In StackSpend, go to Providers and click Add provider.
  2. Select Codex from the list.
  3. No credentials are required. Click Create Provider.
  4. Copy the generated connection ID from the provider page. You will use it to construct your OTLP endpoint URL in the next step.
2

Configure OTel export

Point your Codex agent's OTLP exporter at the StackSpend ingest endpoint. Replace {connectionId} with the connection ID from Step 1.

Logs and metrics endpoints:

https://app.stackspend.com/api/v1/public/ingest/otel/codex/{connectionId}/v1/logs
https://app.stackspend.com/api/v1/public/ingest/otel/codex/{connectionId}/v1/metrics
https://app.stackspend.com/api/v1/public/ingest/otel/codex/{connectionId}/v1/traces

If your exporter accepts a single base URL and appends signal paths automatically, use:

https://app.stackspend.com/api/v1/public/ingest/otel/codex/{connectionId}
3

Verify

Run your Codex agent. Data appears in StackSpend within approximately 1 hour of the first telemetry payload being received. To confirm, return to the Providers page and check the Last synced timestamp next to the Codex entry.

StackSpend Docs