openai SDK ships no first-party OTel: use OpenInference’s auto-instrumentation. Pick your language in the code blocks below; the choice persists across the page.
1. Install
Already have OpenInference + an OTLP exporter wired up? Skip. No setup yet?2. Wire OpenInference + OTLP exporter pointing at Agnost
Already have OpenInference (or any OTel TracerProvider) running? Append Agnost as an additional span processor on the existing provider:3. Pass userId / sessionId per call
using_attributes (Python) and setUser / setSession (TS) propagate via OTel context, landing as user.id / session.id on every span the OpenAI SDK emits inside the block.
TypeScript version compatibility
Pin matching majors: version mismatches throwdoes not provide an export named 'APIPromise' at import time:
openai | @arizeai/openinference-instrumentation-openai |
|---|---|
^6.7.0 | ^4.0.0 |
^4.95.0 – ^5.x | ~2.3.1 |
