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# Setup OTel via our convenience functiontracer_provider =register( 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(tracer_provider=tracer_provider)
To test, run the following code and observe your traces in Arize.