Anthropic for Effect

Adds instrumentation for the Anthropic SDK. (default)

Import name: Sentry.anthropicAIIntegration

This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read this.

The anthropicAIIntegration adds instrumentation for the @anthropic-ai/sdk SDK to capture agent tracing gen_ai spans, recording model, token usage, latency, and (when enabled) inputs and outputs.

Copied
Sentry.init({
  dsn: "___PUBLIC_DSN___",
  // Tracing must be enabled for agent tracing to work
  tracesSampleRate: 1.0,
  integrations: [Sentry.anthropicAIIntegration()],
});

By default, tracing support is added to the following Anthropic SDK calls:

  • messages.create() - Create messages with Claude models
  • messages.stream() - Stream messages with Claude models
  • completions.create() - Create completions (legacy)
  • beta.messages.create() - Beta messages API

Streaming and non-streaming requests are automatically detected and handled appropriately.

  • @anthropic-ai/sdk: >=0.19.2 <1.0.0

Type: boolean (optional)

Records inputs to Anthropic SDK calls (such as prompts and messages).

Defaults to true if dataCollection.genAI.inputs is true, which is the default.

Type: boolean (optional)

Records outputs from Anthropic SDK calls (such as generated text and responses).

Defaults to true if dataCollection.genAI.outputs is true, which is the default.

Copied
Sentry.init({
  dsn: "___PUBLIC_DSN___",
  tracesSampleRate: 1.0,
  integrations: [
    Sentry.anthropicAIIntegration({
      recordInputs: false,
      recordOutputs: false,
    }),
  ],
});
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").