Monitor Anthropic’s official Python SDK by wrapping the client once withDocumentation Index
Fetch the complete documentation index at: https://docs.lunary.ai/llms.txt
Use this file to discover all available pages before exploring further.
lunary.monitor(client).
Monitor Anthropic
Wrap
Anthropic or AsyncAnthropic once, then keep using the Anthropic client as usual.Supported surface
The monitored client supports the current Anthropic Messages API surface:
client.messages.create(...)- Raw streaming via
client.messages.create(..., stream=True) client.messages.parse(...)client.messages.stream(...)client.beta.messages.create(...)client.beta.messages.parse(...)client.beta.messages.stream(...)client.beta.messages.tool_runner(...)- The same monitored surface on
AsyncAnthropic
thinking, redacted_thinking, tool_use, tool_result, server_tool_use, and web_search_tool_result, along with token usage and cached input tokens.Typical usage
Structured outputs with Lunary context:Raw streaming and helper streams:Beta tool-runner loops:Anthropic validates the provider-side
metadata object. Use Anthropic-supported fields such as user_id there, and use Lunary’s tags, user_id, and user_props for observability context. For Anthropic beta features that require betas=[...], pass the beta headers exactly as Anthropic documents.