Instrument OpenAI Assistants
Recipe — instrument OpenAI / Assistants. Pointer to the SDK samples.
Last updated
Was this helpful?
Recipe — instrument OpenAI / Assistants. Pointer to the SDK samples.
Canonical samples:
samples/integrations/openai_traced.py — manual trace upload around an OpenAI completion
samples/integrations/openai_instrumented.py — zero-code auto-instrumentation via instrument_openai(), @trace, span()
pip install 'layerlens[providers-openai]'The OpenAI provider adapter emits one event per chat or embedding call: model.invoke (with parameters, token counts, latency, response_id, system_fingerprint, full messages); cost.record (USD computed from pricing table); tool.call (one per tool when present); policy.violation (on SDK error). Streaming responses emit a single consolidated model.invoke on completion.
Capture configs: CaptureConfig.minimal(), .standard(), or .full(). Circuit breaker opens after 10 consecutive sink failures (60s cooldown, silent drop while open).
Last updated
Was this helpful?
Was this helpful?