/docs/integrations/wrap_anthropic

Anthropic

Drop-in wrapper for the Anthropic SDK. Captures Claude calls — including tool use, thinking blocks, and stop reasons — as llm steps.

Setup

from anthropic import Anthropic
	from theta_observability import TraceClient
	from theta_observability.integrations import wrap_anthropic

client = TraceClient()
ant = wrap_anthropic(Anthropic(), client)

with client.trace(name="ask-claude") as t:
    ant.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=512,
        messages=[{"role": "user", "content": "Summarize this trace"}],
    )

Captured fields

  • Model, system prompt, messages, tools, max_tokens, temperature.
  • Response content blocks, including text, tool_use, and thinking.
  • Token usage by category (input, output, cache_creation, cache_read).
  • Stop reason and stop sequence.

Prompt caching

Cache creation and cache read tokens are captured separately so you can compare the cost impact of your cache strategy across releases.