Set the ANTHROPIC_API_KEY environment variable to authenticate calls made using the SDK.
Copy
export ANTHROPIC_API_KEY=[your_key_here]
In a python file, setup the AnthropicInstrumentor and configure the tracer to send traces to Arize.
Copy
# Import open-telemetry dependenciesfrom arize_otel import register_otel, Endpoints# Setup OTEL via our convenience functionregister_otel( endpoints = Endpoints.ARIZE, space_id ="your-space-id", # in app space settings page api_key ="your-api-key", # in app space settings page project_name ="your-project-name", # name this to whatever you would like)# Import openinference instrumentor to map Anthropic traces to a standard formatfrom openinference.instrumentation.anthropic import AnthropicInstrumentor# Turn on the instrumentorAnthropicInstrumentor().instrument()
To test, run the following code and observe your traces in Arize.