Claude (OTel)
Track estimated costs from Claude Code, Cowork, and Anthropic-based agents via OpenTelemetry telemetry.
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.
Prerequisites
- Claude Code or an Anthropic-based agent that supports OpenTelemetry export.
- A StackSpend account with permission to add providers.
Setup
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.
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/logsMetrics endpoint
https://app.stackspend.com/api/v1/public/ingest/otel/claude/{connectionId}/v1/metricsConsult 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.
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
| Property | Value |
|---|---|
| Data latency | ~1 hour |
| Historical data | From setup date |
| Setup time | ~5 min |
