Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.fact0.io/llms.txt

Use this file to discover all available pages before exploring further.

LangChain

Fact0 ships a LangChain callback that records every chain, tool, and LLM call as a telemetry span, with optional audit events for sensitive actions.

Install

pip install fact0 langchain

Quick example

from langchain_openai import ChatOpenAI
from fact0.integrations.langchain import Fact0CallbackHandler
import fact0

client = fact0.Client(api_key="alk_live_...")

handler = Fact0CallbackHandler(
    client=client,
    agent_id="research-bot",
    audit_sensitive_actions=True,
)

llm = ChatOpenAI(model="gpt-4o", callbacks=[handler])
response = llm.invoke("Summarize Q3 results")

What gets captured

Callback eventTelemetryAudit (when audit_sensitive_actions=True)
LLM start/endMODEL_INVOCATION span
Tool start/endTOOL_CALL spanagent.tool.call
Chain start/endexecution lifecycleagent.run.start / agent.run.end

Configuration

handler = Fact0CallbackHandler(
    client=client,
    agent_id="support-bot",
    execution_metadata={"tenant": "acme", "env": "prod"},
)
OptionPurpose
agent_idStable agent identifier shown in the dashboard
execution_metadataTags applied to every execution from this handler
audit_sensitive_actionsAlso write agent.tool.call audit events