Integrations
Claude Agent SDK (JS/TS)
Trace Anthropic's Claude Agent SDK in TypeScript with Muster via OpenInference instrumentation.
The Claude Agent SDK is Anthropic's open-source framework for building AI agents in TypeScript. Muster captures every agent step, tool call, and model completion through the OpenInference Claude Agent SDK instrumentation.
Setup
1. Install dependencies
npm install @anthropic-ai/claude-agent-sdk @arizeai/openinference-instrumentation-claude-agent-sdk @langfuse/otel @opentelemetry/sdk-node2. Configure environment
process.env.ANTHROPIC_API_KEY = "sk-ant-...";
process.env.LANGFUSE_PUBLIC_KEY = "pk-lf-...";
process.env.LANGFUSE_SECRET_KEY = "sk-lf-...";
process.env.LANGFUSE_BASE_URL = "https://app.getmuster.io";3. Initialize OpenTelemetry
import { NodeSDK } from "@opentelemetry/sdk-node";
import { LangfuseSpanProcessor, isDefaultExportSpan } from "@langfuse/otel";
import { ClaudeAgentSDKInstrumentation } from "@arizeai/openinference-instrumentation-claude-agent-sdk";
import * as ClaudeAgentSDKModule from "@anthropic-ai/claude-agent-sdk";
const ClaudeAgentSDK = { ...ClaudeAgentSDKModule };
const instrumentation = new ClaudeAgentSDKInstrumentation();
instrumentation.manuallyInstrument(ClaudeAgentSDK);
const sdk = new NodeSDK({
spanProcessors: [
new LangfuseSpanProcessor({
shouldExportSpan: ({ otelSpan }) =>
isDefaultExportSpan(otelSpan) ||
otelSpan.instrumentationScope.name ===
"@arizeai/openinference-instrumentation-claude-agent-sdk",
}),
],
instrumentations: [instrumentation],
});
sdk.start();4. Run an agent
const { query } = ClaudeAgentSDK;
for await (const message of query({
prompt: "What is the capital of France? Answer in a single sentence.",
options: {
model: "claude-sonnet-4-5",
},
})) {
if (message.type === "assistant") {
console.log(message.message.content);
}
}
await sdk.shutdown();5. View the trace
