Skip to main content

Overview

Claude Agent SDK is a framework for calling Claude Code from your own code. It abstracts away the underlying process management and calls to the model API.

What Laminar captures

  • The entire structure of the Claude Agent SDK function calls, including connect, query, and receive_messages.
  • LLM prompts and responses sent to the model.
  • Tool calls and their results.
  • Latencies, token counts, and token costs.

Getting started

1

Installation

Ensure you are using @lmnr-ai/lmnr version 0.7.10 or higher.
npm install @lmnr-ai/lmnr@latest @anthropic-ai/claude-agent-sdk
# or
pnpm add @lmnr-ai/lmnr@latest @anthropic-ai/claude-agent-sdk
2

Set up your environment variables

Export your API keys as environment variables.
export LMNR_PROJECT_API_KEY=your-laminar-project-api-key
export ANTHROPIC_API_KEY=your-anthropic-api-key
3

Wrap the query function

import { query as origQuery } from '@anthropic-ai/claude-agent-sdk';
import { Laminar } from '@lmnr-ai/lmnr';

// Initialize Laminar
Laminar.initialize();

// Wrap the original query function
const query = Laminar.wrapClaudeAgentQuery(origQuery);

async function run() {
  const result = await query({
    prompt: "Scan the current directory for TODOs and create a summary markdown file."
  });

  console.log(result);
}
run();

View the traces in Laminar

Go to the Laminar dashboard, and you will see the traces for the Claude Agent SDK. Example trace: Claude Agent SDK Trace