Node.js + Anthropic
examples/node-anthropic shows how to record a non-streaming Anthropic call and save the session to disk.
cd examples/node-anthropiccp .env.example .env.localAdd your Anthropic API key to .env.local:
ANTHROPIC_API_KEY=sk-ant-...pnpm startThe example makes a single messages.create call and writes the session to ./recordings/ as a .flight file.
Code walkthrough
Section titled “Code walkthrough”import Anthropic from "@anthropic-ai/sdk";import { FlightRecorder, wrapAnthropic, type AnthropicClientLike,} from "@ai-flight-recorder/sdk";import { FileTransport } from "@ai-flight-recorder/sdk/node";
const fr = new FlightRecorder({ transport: new FileTransport("./recordings"),});
const client = wrapAnthropic( new Anthropic() as unknown as AnthropicClientLike, fr.recorder,);
fr.startSession({ label: "anthropic-example" });
const message = await client.messages.create({ model: "claude-sonnet-4-5", max_tokens: 1024, messages: [{ role: "user", content: "What is the capital of France?" }],});
console.log(message.content[0]);
fr.endSession();// session saved to ./recordings/<sessionId>.flightThe as unknown as AnthropicClientLike cast is required because Anthropic’s SDK uses strict method overloads. See Adapters for an explanation.