StackSpendDocs

OTel Ingest

StackSpend accepts OpenTelemetry (OTLP) telemetry from Claude Code, Codex, and Claude-based agents, converting spans and metrics into estimated cost line items.

Who needs this guide

Most users connecting Claude or Codex don't need to read this. The StackSpend MCP server or provider setup handles OTel configuration automatically.

This guide is for teams building custom integrations or self-hosting agent infrastructure who need to configure their own OTLP exporter.

Note.For direct API billing, connect the Anthropic or OpenAI provider instead. OTel ingest is for agent-based usage attribution — costs are estimated from token counts extracted from telemetry spans, not pulled from billing APIs.

Supported providers and endpoints

Each provider has its own set of OTLP endpoints. Replace {connectionId} with the Connection ID from your provider detail page.

ProviderLogs endpointMetrics endpointTraces endpoint
claude/api/v1/public/ingest/otel/claude/{connectionId}/v1/logs/v1/metrics
claude-code/api/v1/public/ingest/otel/claude-code/{connectionId}/v1/logs/v1/metrics
codex/api/v1/public/ingest/otel/codex/{connectionId}/v1/logs/v1/metrics/v1/traces

All endpoints are hosted at https://app.stackspend.com. The metrics and traces paths shown above are appended to the provider-specific base path.

Authentication

The connectionId in the URL authenticates the request — no API key header is needed. The connection ID is provider-specific and generated when you create the provider connection in StackSpend.

Setup

1

Find your Connection ID

In StackSpend, go to Providers and open your Claude or Codex provider. The Connection ID is displayed on the provider detail page.

If you haven't created a provider yet, go to Providers → Add provider and select Claude Code or Codex. The Connection ID is generated on save.

2

Configure your OTLP exporter

Set the following environment variables in your agent or CI environment. Replace <connectionId> with the value from step 1.

OTEL_EXPORTER_OTLP_ENDPOINT=https://app.stackspend.com/api/v1/public/ingest/otel/claude/<connectionId>
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf

For Codex, replace claude in the path with codex.

3

Verify data is arriving

Run your agent and then check Providers → [your provider] in StackSpend. Cost data appears within approximately one hour of telemetry being received.

If no data appears after an hour, confirm the OTEL_EXPORTER_OTLP_ENDPOINT value matches the Connection ID on the provider detail page exactly.

How data is processed

When StackSpend receives OTLP telemetry it extracts token counts and model information from the spans and metrics. It then applies current model pricing to produce estimated cost line items, which appear in the Data Explorer and dashboard alongside costs from other providers.

Data appears within approximately one hour of ingest. Costs are estimates based on token counts and published pricing — they are not pulled from Anthropic or OpenAI billing APIs and may differ from your actual invoice.

Estimated costs only.OTel-derived costs are estimates. For exact billing figures, connect the Anthropic or OpenAI provider directly. OTel ingest is best suited for per-agent or per-team usage attribution where token-level granularity matters more than billing accuracy.
OTel Ingest — StackSpend Docs — StackSpend Docs