DEVELOPER DOCS

SDK

Framework adapters

On this page

Adapters instrument a framework's own callbacks so you do not hand-write spans. They are additive — no schema change, and they are import-safe when the framework is absent.

LangChain

Shell
pip install 'opexia-trace[adapters-langchain]'
Python
import opexia.trace
from opexia.trace.adapters.langchain import instrument_langchain, get_langchain_handler

opexia.trace.init(...)

# Option A — instrument globally.
instrument_langchain()

# Option B — attach the handler to specific runs.
handler = get_langchain_handler()
chain.invoke({"question": "..."}, config={"callbacks": [handler]})

The adapter extracts token usage from LLM responses and maps retrieved Documents into opexia.sources automatically.

CrewAI

Python
import opexia.trace
from opexia.trace.adapters.crewai import instrument_crewai

opexia.trace.init(...)

crew = Crew(agents=[...], tasks=[...])
n = instrument_crewai(crew)     # returns how many methods were wrapped
crew.kickoff()

Wraps kickoff, per-agent execute_task, and tool calls, producing a fleet-shaped trace consumable by Fleet Monitor.

Set CREWAI_DISABLE_TELEMETRY=true before importing CrewAI. Its own telemetry otherwise competes with the adapter's provider.

Shell
export CREWAI_DISABLE_TELEMETRY=true

Microsoft agent frameworks

Shell
pip install 'opexia-trace[adapters-microsoft]'
Python
from opexia.trace.adapters.microsoft import ...