Framework Integrations¶
FastAIAgent ships two flavours of integration:
-
SDK auto-tracing — patches the OpenAI / Anthropic SDKs so every
chat.completions.create()andmessages.create()call lands in the local trace store with full token / cost / payload data. Use when your code calls the provider SDK directly. -
Universal agent harness — wraps LangChain / LangGraph, CrewAI, and PydanticAI agents with FastAIAgent's observability, eval, guardrails, prompt registry, and KB. Use when your agent is built in one of those frameworks and you want the same Local UI surface without rewriting.
Beyond these, any in-process OpenTelemetry / OpenInference / OpenLLMetry
instrumentor can be captured and rendered richly with a single opt-in call —
fastaiagent.enable_otel_capture(). See
Capture any OTel / OpenInference framework.
Pick your starting point¶
- I have an existing LangGraph / CrewAI / PydanticAI agent → start with Universal harness — overview, then read the framework-specific guide.
- I'm calling the OpenAI / Anthropic SDK directly → keep reading this page.
Connecting to the control plane¶
Tracing works out of the box; linking those traces to an agent on the
Enterprise plane needs a name. Pass name= to with_guardrails(...) (or use
agent_name(...)) so the root span carries agent.name, and call
register_agent() so the plane has an agent with that name to match. See
Connecting foreign agents to the control plane.
Universal harness — per framework¶
Borrowing SDK primitives — any runtime¶
The harness above traces your framework. The other half is enforcement and
scoring: run plane-authored guardrails and platform scorers inside a runtime
that isn't fa.Agent, and emit the results as standard OpenInference spans on
the exporter you already have — no second exporter, no rewrite.
See Guardrails & evals without the runtime.
OpenAI SDK auto-tracing¶
Traces all openai.chat.completions.create() calls.
import fastaiagent.integrations.openai as openai_integration
openai_integration.enable()
import openai
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
# Trace lands at .fastaiagent/local.db; view with `fastaiagent ui`
What's captured per call:
gen_ai.system:"openai"gen_ai.request.model: model namegen_ai.usage.input_tokens/gen_ai.usage.output_tokensgen_ai.request.messages/gen_ai.response.content- Tool calls + finish reason
- Latency
Anthropic SDK auto-tracing¶
import fastaiagent.integrations.anthropic as anthropic_integration
anthropic_integration.enable()
import anthropic
client = anthropic.Anthropic()
client.messages.create(
model="claude-haiku-4-5",
max_tokens=128,
messages=[{"role": "user", "content": "Hello"}],
)
Same span shape as the OpenAI integration — gen_ai.system="anthropic"
and the rest mirrors.
Disabling¶
Each integration's disable() restores the originals (best-effort —
some surfaces, like LangChain's configure-hook registry, don't expose
a public unregister; the integration's idempotency flag stops the
handler from creating new spans regardless).
Trace export¶
Every traced call goes to the same local SQLite store, regardless of which integration produced it. Use the standard FastAIAgent trace export tooling — see the Trace export docs.