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

Claude Agent SDK integration is packaged as a separate extra.
pip install 'lmnr[claude-agent-sdk]'
2

Set up your environment variables

Store your API keys in a .env file or export them as environment variables.
export LMNR_PROJECT_API_KEY=your-laminar-project-api-key
export ANTHROPIC_API_KEY=your-anthropic-api-key
3

Initialize Laminar

Initialize Laminar at the start of your application or file.
import asyncio

from claude_agent_sdk import ClaudeSDKClient
from lmnr import Laminar, observe

Laminar.initialize()

@observe()
async def main():
    async with ClaudeSDKClient() as client:
        await client.query(
            "Explain to me with examples, how memoization speeds up recursive "
            "function calls. Use the Fibonacci sequence as an example."
        )
        async for msg in client.receive_response():
            print(msg)

if __name__ == "__main__":
    asyncio.run(main())
4

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