Skip to main content
Monitor Anthropic’s official TypeScript SDK by wrapping the client once with lunary/anthropic.
1

Install both packages

JavaScript

Learn how to set up the JS SDK.
2

Monitor Anthropic

Wrap the Anthropic client once, then keep using the Anthropic SDK as usual.
3

Supported surface

The monitored client supports the current Anthropic Messages API surface:
  • messages.create(...)
  • Raw streaming via messages.create({ stream: true })
  • messages.parse(...)
  • messages.stream(...)
  • beta.messages.create(...)
  • beta.messages.parse(...)
  • beta.messages.stream(...)
  • beta.messages.toolRunner(...)
Tool-runner loops appear in Lunary as one LLM run per underlying Anthropic request. Raw streams and helper streams keep the normal Anthropic SDK lifecycle, and Lunary preserves Anthropic content blocks in the run details, including thinking, redacted_thinking, tool_use, tool_result, server_tool_use, and web_search_tool_result, along with token usage and cached input tokens.
4

Typical usage

Structured outputs with Lunary context:
Helper streams and beta server tools:
Beta tool-runner loops:
Anthropic validates the provider-side metadata object. Use Anthropic-supported fields such as user_id there, and use tags, userId, and userProps for Lunary-only context. For Anthropic beta features that require betas: [...], pass the beta headers exactly as Anthropic documents.