Skip to main content
The SDK provides seamless instrumentation for the OpenAI Python client.

Setup

Enable instrumentation with a single function call. This automatically tracks all subsequent calls to both OpenAI and AsyncOpenAI clients.
A single instrument() call instruments both synchronous and asynchronous clients. You don’t need to call it twice.

Usage

Once instrumented, use the OpenAI client as you normally would. The SDK automatically captures all call data.

Synchronous

Asynchronous

Streaming

Streaming responses are supported for both sync and async. The trace is recorded once the stream completes.

Sync Streaming

Async Streaming

Captured Data

The integration automatically records:
FieldDescription
gen_ai.systemopenai
gen_ai.request.modelModel name (e.g., gpt-4)
gen_ai.promptInput messages
gen_ai.completionResponse content
gen_ai.usage.prompt_tokensPrompt token count
gen_ai.usage.completion_tokensCompletion token count
durationRequest latency