Applies to:
- Plan -
- Deployment -
Summary
Issue: Traces are not created when callinglitellm.anthropic_messages() or routing through the /anthropic/v1/messages passthrough. Calls to litellm.completion(model="anthropic/claude-...") are traced correctly.
Cause: patch_litellm wraps litellm.completion, acompletion, responses, embedding, and related entrypoints — it does not wrap litellm.anthropic_messages or the /anthropic/v1/messages passthrough route.
Resolution: Use litellm.completion for standard Claude tracing, or use the Anthropic SDK directly with wrap_anthropic if you need native Anthropic Messages API features.
Resolution steps
If you are calling litellm.completion with a Claude model and seeing no spans
Step 1: Verify setup order
patch_litellm() must be called before importing or using litellm. Confirm the following are also in place:
init_logger(project="...")is calledBRAINTRUST_API_KEYis set in your environment
Step 2: Confirm the call pattern
/messages API internally, and the Braintrust wrapper operates at the litellm.completion layer.
If you need native Anthropic Messages API features (extended thinking, prompt caching, etc.)
Step 1: Use wrap_anthropic with the Anthropic SDK directly
litellm.anthropic_messages is not wrapped by patch_litellm. Use this path instead:
If you are building a gate pattern on top of patch_litellm
Step 1: Save original function references before wrapping
patch_litellm patches the litellm module in-place. If you save references after calling patch_litellm, both your original and traced refs point to the already-wrapped function, and the gate has no effect.
Save refs first:
Notes
- Native
anthropic_messageswrapper support inpatch_litellmis not currently available. If this is a requirement, submit a feature request. - Do not use LiteLLM’s
BraintrustLoggercallback for tracing. Usepatch_litellm()orbraintrust.auto_instrument()instead — only function-wrapping preserves span context.