Working examples for the nullrun Python SDK.
Each example is a self-contained, runnable file. The intent is to show the smallest possible change to add enforcement to a common agent framework.
pip install nullrun
export NULLRUN_API_KEY=nr_live_...Get an API key from the NullRun dashboard.
nullrun.init(api_key=...) patches the underlying HTTP transport and any
imported agent framework (openai, openai-agents, langgraph,
autogen, …) automatically. You get cost tracking without changing your
call sites; @protect is the gate layer (budget / kill / pause) that
runs before the call.
For frameworks that ship an extra, you can install with the matching
optional dependency (nullrun[langgraph], nullrun[agents], etc.).
| File | Framework | What it shows |
|---|---|---|
raw_openai_basic.py |
raw OpenAI | @protect on a single LLM call |
openai_agents_basic.py |
OpenAI Agents SDK | @protect on a multi-step agent run |
langgraph_basic.py |
LangGraph | Auto-instrumented StateGraph |
cost_cap_demo.py |
any | Hard budget cap that halts the agent |
export NULLRUN_API_KEY=nr_live_...
python examples/raw_openai_basic.pyAll examples are read-only — they do not modify org state, policies, or
keys on your account. They do emit track events to the gateway
(auto-instrumented HTTP traffic from init()), so a cost_attribution
or examples tag in the dashboard will pick them up.
PRs welcome. Keep each example under 80 lines. No external state beyond the NullRun API key.