LangChain
Guard LangChain chains and agents with a drop-in callback handler.
Install
Python
pip install veldrixai langchain
Callback handler
Attach the VeldrixAI callback to any chain or agent. It evaluates each LLM output as it is produced and logs the verdict to your audit trail.
Python
from veldrixai.adapters.langchain import VeldrixCallbackHandler
handler = VeldrixCallbackHandler(api_key="vx-live-...", block_on_verdict=["BLOCK"])
chain.invoke({"input": user_query}, config={"callbacks": [handler]})
Blocking on verdict
With block_on_verdict=["BLOCK"] the handler raises when an output is blocked, halting the chain so the unsafe text never reaches the next step or the user. Catch the exception to return a safe fallback.
Prefer background evaluation for high-throughput chains where you want logging without added latency; switch to blocking only on the user-facing final step.
Was this page helpful?