Python의 wrap_anthropic 메서드를 사용하면 Anthropic client를 래핑하여 자동으로 trace를 로깅할 수 있습니다 — decorator나 function 래핑이 필요하지 않습니다! wrapper를 사용하면 tool call과 multimodal content block을 포함한 message들이 LangSmith에서 깔끔하게 렌더링됩니다. wrapper는 @traceable decorator 또는 traceable function과 원활하게 작동하며, 동일한 애플리케이션에서 두 가지를 모두 사용할 수 있습니다.
wrap_anthropic을 사용하는 경우에도 trace가 LangSmith에 로깅되려면 LANGSMITH_TRACING 환경 변수가 'true'로 설정되어야 합니다. 이를 통해 코드를 변경하지 않고도 tracing을 켜고 끌 수 있습니다.또한, LANGSMITH_API_KEY 환경 변수를 API key로 설정해야 합니다 (자세한 내용은 Setup 참조).LangSmith API key가 여러 workspace에 연결되어 있는 경우, LANGSMITH_WORKSPACE_ID 환경 변수를 설정하여 사용할 workspace를 지정하세요.기본적으로 trace는 default라는 이름의 project에 로깅됩니다. trace를 다른 project에 로깅하려면 이 섹션을 참조하세요.
import anthropic
from langsmith import traceable
from langsmith.wrappers import wrap_anthropic

client = wrap_anthropic(anthropic.Anthropic())

# You can also wrap the async client as well
# async_client = wrap_anthropic(anthropic.AsyncAnthropic())

@traceable(run_type="tool", name="Retrieve Context")
def my_tool(question: str) -> str:
    return "During this morning's meeting, we solved all world conflict."

@traceable(name="Chat Pipeline")
def chat_pipeline(question: str):
    context = my_tool(question)
    messages = [
        { "role": "user", "content": f"Question: {question}\nContext: {context}"}
    ]
    messages = client.messages.create(
      model="claude-sonnet-4-20250514",
      messages=messages,
      max_tokens=1024,
      system="You are a helpful assistant. Please respond to the user's request only based on the given context."
    )
    return messages

chat_pipeline("Can you summarize this morning's meetings?")

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I