docs / claude-code-telemetry

Claude Code Telemetry

Claude Code can export its own usage over OpenTelemetry. Point that export at PromptConduit and each developer's Claude Code spend shows up on your team page, with nothing to install. Six settings, set once per developer.

What you get

Claude Code sends one api_request event per model call, priced by Claude Code itself: cost, model, input, output, and cache tokens, the session, and (with the repository setting below) the repo it ran in. PromptConduit stores these alongside CLI events, so they count in team cost by member, model, repository, client, and day, in budgets and their alerts, and in the savings report.

Set it up

  1. Each developer joins your team on app.promptconduit.dev and creates their own API key on their profile. Use one key per person: the key decides whose spend it is.
  2. Add the settings to ~/.claude/settings.json, then restart Claude Code:
~/.claude/settings.json
{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "https://api.promptconduit.dev/v1/otlp",
    "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer sk_your_api_key_here",
    "OTEL_METRICS_INCLUDE_REPOSITORY": "true"
  }
}

Or, as environment variables in your shell profile:

shell
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT=https://api.promptconduit.dev/v1/otlp
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer sk_your_api_key_here"
export OTEL_METRICS_INCLUDE_REPOSITORY=true

Spend appears on the team page within a minute of the next prompt; Claude Code flushes events every five seconds.

The settings

SettingWhy
CLAUDE_CODE_ENABLE_TELEMETRYTurns telemetry on. It's off by default.
OTEL_LOGS_EXPORTERCost arrives on the logs signal, one event per request.
OTEL_EXPORTER_OTLP_PROTOCOLClaude Code has no default. Use http/protobuf or http/json; grpc isn't served.
OTEL_EXPORTER_OTLP_ENDPOINTThe exporter appends /v1/logs to this base.
OTEL_EXPORTER_OTLP_HEADERSYour API key, so events land on your account and team.
OTEL_METRICS_INCLUDE_REPOSITORYAdds the repository from the origin remote, for spend per repo and per client. Without it, spend still counts by member and model.

Metrics (OTEL_METRICS_EXPORTER) are optional. They're accepted and discarded, because they repeat the spend the request events already carry. Gzip compression (OTEL_EXPORTER_OTLP_COMPRESSION=gzip) is supported.

Telemetry or the CLI?

Telemetry is the quickest way to get a team's Claude Code spend in one place. The CLI covers more:

  • Cursor, Codex, Gemini CLI, Copilot, and Grok Build, not just Claude Code.
  • The branch and pull request behind each turn, for spend per PR and the GitHub PR comment.
  • The prompt-cache savings figure, which needs the per-token prices the CLI records.
  • A local event log, the editor extension, and local coaching.

You can run both. When the CLI has already priced a Claude Code session, its numbers are used for that session and the telemetry cost is left out, so spend is never counted twice.

Troubleshooting

  • Nothing arrives. Check that CLAUDE_CODE_ENABLE_TELEMETRY is 1, that you restarted Claude Code, and that the protocol is set. With grpc the export fails silently.
  • Spend shows, but not on the team page. The developer hasn't accepted the team invite, or the key belongs to someone else. Events count toward the team the key's owner belongs to.
  • No repository column. Set OTEL_METRICS_INCLUDE_REPOSITORY=true (Claude Code 2.1.269 or later), and make sure the repo has an origin remote.

For the fields Claude Code sends and how to query them in your own stack, see Claude Code OpenTelemetry cost tracking. Endpoint details, status codes, and other OTLP sources are in the API Reference.