Skip to content

Raw openai SDK

If you use the openai package directly (no LangChain / LlamaIndex / CrewAI on top), install the OpenAI extra:

shell
pip install "nullrun[openai]"
raw_openai_client.py
import nullrun
from openai import OpenAI

nullrun.init(api_key="nr_live_...")
client = OpenAI()
resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello"}],
)

Patched via the httpx transport hook in nullrun.instrumentation.auto — the OpenAI SDK uses httpx under the hood, so the SDK reads the response body, extracts usage.prompt_tokens / usage.completion_tokens, and emits a track_llm event.

nullrun[openai] is for the raw openai SDK — it is not the OpenAI Agents SDK. For agents use nullrun[agents].

See also