Skip to main content

Requirements

Env Variables

Initialize Logger

Initialize MaximAnthropicClient

Make LLM Calls Using MaximAnthropicClient

Maxim-specific Headers

The Anthropic instrumentation supports additional headers via the extra_headers parameter to enhance trace metadata and organization. You can use the following headers:
  • x-maxim-trace-id: Associate LLM calls with a specific trace ID (UUID string). All calls with the same trace ID will be grouped together in a single trace.
  • x-maxim-trace-tags: Add custom tags to traces as a JSON string containing key-value pairs. Useful for filtering and organizing traces.
  • x-maxim-generation-name: Assign a custom name to a specific generation/LLM call within a trace (string).
  • x-maxim-session-id: Associate traces with a specific session ID (string).

Example: Using Extra Headers

Advanced Use Case: Streaming Support

Initialize Maxim SDK and Anthropic Client

Make Streaming Calls

Capture Multiple LLM Calls in One Trace

Initialize Maxim SDK and Anthropic Client
Create a new trace externally
Make LLM calls and use this trace id
Keep adding LLM calls All LLM calls with extra header x-maxim-trace-id: trace_id will add it to the declared trace.

Capture Multi-Turn Conversations

Initialize Maxim SDK and Anthropic Client
Create a new trace externally and add it to a session
Make LLM calls and use this trace id
Create additional traces in the same session To add more conversations to the same session, create new traces with the same session_id:

Resources

Anthropic integration cookbook (GitHub)

Anthropic + Maxim integration Notebook (Colab)