StackSpendDocs

Claude (OTel)

Track estimated costs from Claude Code, Cowork, and Anthropic-based agents via OpenTelemetry telemetry.

Claude (OTel) logo

Claude (OTel)

AI · ~1 hour latency · 5 min setup

What is the Claude provider?

The Claude provider ingests OpenTelemetry (OTel) telemetry emitted by Claude Code, Claude Cowork, and any Anthropic-based agent you run locally or in CI. StackSpend receives OTLP spans and metrics from your agents, extracts token counts, and converts them to estimated cost data using current Anthropic model pricing.

Because the data flows through OTel rather than Anthropic's billing API, this provider gives you per-user and per-session attribution that Anthropic's own dashboard does not expose. You can see exactly which developer, team, or automated pipeline is driving spend.

Who should use this?

This provider is intended for teams who:

  • Run Claude Code or Anthropic-based agents locally or in CI pipelines.
  • Want per-user or per-session cost attribution across their engineering team.
  • Need to chargeback AI spend to specific projects or cost centers.
Claude (OTel) vs Anthropic provider.The Anthropic provider shows what Anthropic bills your account — pulled directly from the Anthropic billing API. The Claude provider shows estimated costs derived from Claude Code and agent telemetry, which is useful for attributing spend by user or session. Use both if you want complete visibility: Anthropic for billing accuracy, Claude (OTel) for attribution granularity.

Prerequisites

  • Claude Code or an Anthropic-based agent that supports OpenTelemetry export.
  • A StackSpend account with permission to add providers.

Setup

1

Add Claude provider in StackSpend

Go to Settings → Providers → Add provider and select Claude. No credentials are required — StackSpend generates a unique connection ID and ingest endpoint for your account.

After saving, copy the connection ID shown on the provider detail page. You will need it in the next step.

2

Configure OTel export

Set the OTLP endpoints in your Claude Code or agent configuration, replacing {connectionId{} with the connection ID from Step 1.

Logs endpoint

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

Metrics endpoint

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

Consult your agent's OTel documentation for the exact environment variable or config key to set. For Claude Code, this is typically OTEL_EXPORTER_OTLP_ENDPOINT.

3

Verify

Run Claude Code or trigger your agent, then return to the Claude provider page in StackSpend. Data appears within approximately 1 hour of the first telemetry being received.

If no data appears after an hour, confirm that your agent is exporting to the correct endpoint and that the connection ID in the URL matches the one shown in StackSpend.

Data availability

PropertyValue
Data latency~1 hour
Historical dataFrom setup date
Setup time~5 min
Note.Claude Code usage is estimated from token counts in OTel spans — it is not exact Anthropic billing. Costs may differ slightly from your Anthropic invoice due to rounding, caching discounts, or spans that do not include full token metadata. For billing accuracy, also connect the Anthropic provider.
StackSpend Docs