Anthropic
Trace Claude via the Anthropic SDK in Python and TypeScript.
Wrap the Anthropic client and every messages.create / messages.stream call is captured as an LLM span — including thinking blocks, tool use, and cache tokens.
Prerequisites
pip install -U "neatlogs[anthropic]" anthropicUsage
import os
import neatlogs
from anthropic import Anthropic
neatlogs.init(api_key=os.environ["NEATLOGS_API_KEY"], workflow_name="anthropic-demo")
client = neatlogs.wrap(Anthropic())
resp = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=256,
messages=[{"role": "user", "content": "In one sentence, what is Claude?"}],
)
print(resp.content[0].text)
neatlogs.flush()
neatlogs.shutdown()wrap() opens a WORKFLOW root for you, so this renders with no extra wrapper. Async clients (AsyncAnthropic) and streaming are handled the same way. AnthropicBedrock is also supported.
Making several calls in one run? Group them into one trace with a
WORKFLOWroot.