---
title: "Anthropic SDK"
description: "Set up Blyp tracing for direct Anthropic SDK messages.create() calls."
canonical_url: "https://www.blyp.dev/docs/ai/anthropic-sdk"
markdown_url: "https://www.blyp.dev/docs/ai/anthropic-sdk.md"
last_updated: "2018-10-20"
x_farming_labs_generated_preamble: true
agent:
  task: "Wrap an Anthropic SDK client so Blyp emits normalized traces for messages.create calls."
  outcome: "Anthropic calls emit ai_trace records with model, timing, usage, and request correlation."
  appliesTo:
    package:
      - "@blyp/core"
      - "@anthropic-ai/sdk"
  prerequisites:
    - "An Anthropic client and API key already work without Blyp."
  files:
    - "blyp.config.ts"
    - "src/lib/anthropic.ts"
  commands:
    - "pnpm add @blyp/core @anthropic-ai/sdk"
  sideEffects:
    - "Configured capture fields may persist model input or output content."
  verification:
    - "Run one messages.create call and confirm a single ai_trace record is emitted."
  rollback:
    - "Use the original Anthropic client instead of the wrapped client."
  failureModes:
    - symptom: "No trace is emitted."
      resolution: "Call messages.create on the wrapped client and flush Blyp before a short-lived process exits."
---

# Anthropic SDK
URL: /docs/ai/anthropic-sdk
LLM index: /llms.txt
Description: Set up Blyp tracing for direct Anthropic SDK messages.create() calls.
Related: /docs/ai/tracing, /docs/ai/privacy-and-capture, /docs/configuration

<!-- farming-labs:agent-contract:start -->
## Agent Contract

Task: Wrap an Anthropic SDK client so Blyp emits normalized traces for messages.create calls.
Outcome: Anthropic calls emit ai_trace records with model, timing, usage, and request correlation.

### Applies To

- Package: `@blyp/core`, `@anthropic-ai/sdk`

### Prerequisites

- An Anthropic client and API key already work without Blyp.

### Files

- `blyp.config.ts`
- `src/lib/anthropic.ts`

### Commands

- `pnpm add @blyp/core @anthropic-ai/sdk`

### Side Effects

- Configured capture fields may persist model input or output content.

### Verification

- Run one messages.create call and confirm a single ai_trace record is emitted.

### Rollback

- Use the original Anthropic client instead of the wrapped client.

### Failure Modes

- No trace is emitted. — Recovery: Call messages.create on the wrapped client and flush Blyp before a short-lived process exits.
<!-- farming-labs:agent-contract:end -->

# Anthropic SDK

Install the Anthropic peer, wrap the already-working client with `wrapAnthropic()`, and use only the
wrapped client. Verify one `messages.create()` call produces an `ai_trace`. Keep content capture off
unless retention is explicitly permitted; if traces are missing, confirm the wrapper is on the
executed client and flush before process exit.

Use `@blyp/core/ai/anthropic` when you want direct Anthropic SDK instrumentation without going through the Vercel AI SDK abstraction.

## Install

Install the Anthropic SDK in the app that uses the traced client:

```bash
bun add @anthropic-ai/sdk
```

## `wrapAnthropic()`

```ts
import Anthropic from "@anthropic-ai/sdk";
import { wrapAnthropic } from "@blyp/core/ai/anthropic";

const anthropic = wrapAnthropic(
  new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY }),
  {
    operation: "summarize_ticket",
  }
);

await anthropic.messages.create({
  model: "claude-sonnet-4-5",
  max_tokens: 512,
  messages: [
    { role: "user", content: "Summarize this support ticket" },
  ],
});
```

`wrapAnthropic()` covers:

- `messages.create()`

It emits one normalized `ai_trace` record per traced call with provider, model, operation, usage, finish reason, timing, and best-effort tool-call events.

## Shared controls

Use [AI Privacy & Capture](/docs/ai/privacy-and-capture) for the shared `capture`, `exclude`, and `limits` controls.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
