Introducing Confident Monitor

Claude Platform

Export Claude API and Managed Agents traces to Confident AI with OpenTelemetry

Overview

The Claude Platform can export OpenTelemetry traces of your Messages API requests and Claude Managed Agents sessions. Send them to Confident AI to debug failed or slow requests, track token usage and latency, and run evals on real traffic.

There are two sources of spans, and you can set up either or both:

SourceWhat it tracesSetup
API tracingEach request the Claude API serves: model requests, server tools, MCP connector tools, and Managed Agents turns. Works with any client.A destination in the Claude Console, no code changes
SDK tracingEach request the Claude SDK sends, and each client tool its tool runner runs, nested in your application's own traces.A tracer provider in your application

Set up both to see a request's SDK and API spans in one trace in the Observatory.

Before You Begin

  • A project API key from Confident AI.
  • For API tracing, the admin role in your Claude Console organization.
  • For SDK tracing, a recent version of the Claude SDK (anthropic for Python, @anthropic-ai/sdk for TypeScript).

API Tracing

The Claude API sends spans straight to Confident AI's OTLP endpoint. Add Confident AI as a Custom destination.

  1. Add a destination

    In the Claude Console, open Organization settings → OpenTelemetry and click Add destination. Fill in the following fields:

    Claude Console Add destination dialog with Provider Custom, name Confident AI and OTLP endpoint https://otel.confident-ai.com
    Adding Confident AI as a Custom destination in the Claude Console
    FieldValue
    ProviderCustom
    NameConfident AI
    OTLP endpoint URLhttps://otel.confident-ai.com
    Request headersName x-confident-api-key, value your Confident AI project API key
    Content modeFull content to see prompts and responses and run evals on them, or Metadata only
    WorkspacesThe Claude workspaces whose spans you want in this project

    Enter the base URL without /v1/traces; the Claude API appends it. For an EU project, use https://eu.otel.confident-ai.com. For a self-hosted deployment, use your own otel. host.

    Each destination sends to one Confident AI project. To send different Claude workspaces to different projects, add a destination per project with that project's API key.

  2. Set the content limit

    With Full content, open Advanced settings and set Maximum content size in MB to 0.75. That fits a 200k-token context window of English text and keeps each request well under Confident AI's 4 MB request limit. When a span's content is over the limit, the Claude API shortens it and sets anthropic.content.truncated to true.

  3. Test the destination

    Click Add destination, then click Test in the destination's More actions menu. The Console reports whether the test span was delivered.

    Open the Observatory in your Confident AI project and check that the anthropic.test span arrived.

  4. Send a request

    Send a Messages API request from a workspace that the destination covers, for example in the Console's playground. Within about a minute, the Console's Delivery column shows Healthy and the request's spans appear in the Observatory under the service name claude-platform.

Add the destination with the Admin API instead

The Admin API takes the same settings as the Console, except Provider. Use an Admin API key in ANTHROPIC_API_KEY:

Bash
curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/telemetry_destinations" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: telemetry-destinations-2026-08-11" \
  -H "content-type: application/json" \
  -d '{
    "endpoint_url": "https://otel.confident-ai.com",
    "headers": {"x-confident-api-key": "'"$CONFIDENT_API_KEY"'"},
    "traces": {"content_mode": "content", "max_content_bytes": 750000},
    "workspaces": {"type": "all"}
  }'

See Anthropic's Admin API and CLI for the CLI and SDK versions of this request.

SDK Tracing

The Claude SDK emits its spans through the OpenTelemetry tracer provider your application registers. Register one that exports to Confident AI before the first Claude call.

  1. Install dependencies

    pip install --upgrade anthropic confident-trace
  2. Set your API keys

    Bash
    export CONFIDENT_API_KEY="<your-confident-api-key>"
    export ANTHROPIC_API_KEY="<your-anthropic-key>"
    # Include prompts and responses in the SDK's spans.
    export ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE="content"

    Without ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE, the SDK exports metadata only: identifiers, timing, status, and token counts.

  3. Register the tracer provider

    init() registers a global tracer provider that exports to Confident AI, and the Claude SDK uses it. Pass instrumentations=() so that confident-trace doesn't also instrument the Anthropic client; otherwise each request is traced twice.

    main.py
    from anthropic import Anthropic
    from confident_trace import init, shutdown
    
    init(instrumentations=())
    
    client = Anthropic()
    
    try:
        message = client.messages.create(
            model="claude-opus-5-5",
            max_tokens=1024,
            messages=[{"role": "user", "content": "Hello, Claude"}],
        )
        print(message.content)
    finally:
        shutdown()

    If your application already owns a tracer provider, add Confident AI to it instead; see existing OpenTelemetry provider. For other languages the Claude SDK supports (C#, Go, Java, PHP, and Ruby), register a tracer provider with an OTLP/HTTP exporter as in manual instrumentation.

  4. Run and verify

    Run your application, then open the Observatory in your Confident AI project. The request appears as an anthropic.messages.create span.

Anthropic's SDK tracing guide lists the other options, such as conversation_id for linking calls and tracing streams and self-hosted sandboxes.

Connect API Spans to Your Traces

With both API and SDK tracing set up, call the Claude SDK inside one of your own spans. Your span contains the SDK's span, which contains the API's spans, and Confident AI shows them as one trace. The SDK passes the trace context to the Claude API in the W3C traceparent header.

main.py
from confident_trace import span

with span("answer_question"):
    message = client.messages.create(
        model="claude-opus-5-5",
        max_tokens=1024,
        messages=[{"role": "user", "content": question}],
    )

Without the SDK, copy the current span's trace context into the request's traceparent header; see Anthropic's connect API spans to your own traces. Requests to Claude Platform on AWS always start their own traces.

What Gets Captured

The spans use the GenAI semantic conventions, so Confident AI reads them without extra setup:

  • Model and token usage from gen_ai.request.model and gen_ai.usage.*, for token usage and cost.
  • Prompts and responses from gen_ai.system_instructions, gen_ai.input.messages, and gen_ai.output.messages, with Full content only.
  • Tool uses from gen_ai.tool.name and gen_ai.tool.call.arguments.
  • Managed Agents threads from gen_ai.conversation.id, which holds the session thread ID and groups a session's turns into a thread.

A request's token usage appears on more than one span: the SDK's anthropic.messages.create span, the API's anthropic.messages.create span, and each anthropic.model_request span under it. To count each token once in your own queries, follow Anthropic's counting tokens.

Troubleshooting

  • Delivery shows Failing with status 401: the x-confident-api-key header is missing or wrong, or the key belongs to another region. A confident_eu_ key needs the EU endpoint.
  • Delivery shows Failing with status 404: remove /v1/traces from the OTLP endpoint URL.
  • Delivery shows Failing with status 429: the project reached its trace storage usage limit.
  • No API spans: check that the destination is enabled and covers the workspace where the request ran.
  • Spans have no prompts or responses: set Content mode to Full content, or ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE=content for the SDK. Organizations with a HIPAA, FERPA, or K-12 data-handling restriction with Anthropic export metadata only.
  • Each request appears twice: a request's SDK span and API span are both named anthropic.messages.create; the API's has the service name claude-platform. If you see two SDK spans, another library also traces the Claude SDK. Turn off one of them, for example with init(instrumentations=()) or ANTHROPIC_OPEN_TELEMETRY=false.

See Anthropic's delivery and health for retries, timeouts, and when the Claude API disables a destination.

Need help wiring this into your stack?Bring traces and evals into the tools your team already usesTalk to an expert

Last updated on

Built byConfident AI