Skip to content

LlamaIndex

Install:

shell
pip install "nullrun[llama-index]"
llama_index_chat.py
import nullrun
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai import OpenAI

nullrun.init(api_key="nr_live_...")

llm = OpenAI(model="gpt-4o-mini")
resp = llm.chat([ChatMessage(role="user", content="Hello")])

Patched via nullrun.instrumentation.llama_index.patch_llama_index, which monkey-patches the LLM class to wrap each chat / complete call so the SDK sees the raw usage. The vendor import is wrapped in try/except ImportError, so installing only this extra group does not crash on init().

Test coverage

Per NullRun's testing policy (see the SDK README), LlamaIndex patches have a dedicated end-to-end test (tests/test_llama_index_patch.py) covering the decorator plus behaviour.

See also