Skip to content
in/guard/out
in/guard/out

Integration

Guardrails & fact-checking for LangChain agents

LangChain gives you middleware hooks, and the ecosystem offers validation libraries to wire into them – per project, per chain, kept in sync by hand. The proxy takes the other route: enforcement moves to the wire, where it covers every chain and agent that talks to a model, including the ones nobody remembered to wrap.

Two touchpoints cover the whole loop. Model calls go through the proxy via the standard base-URL swap on your chat model – PII screening, injection defense, grounding, and tool-call policy run on every request without touching your chains. Tool execution consults the checkpoint API through a callback handler, so the deterministic steps an LLM proxy cannot see – the HTTP call your tool actually makes – are gated by the same policy engine.

>_The model-call side is a constructor argument
llm = ChatOpenAI(
    base_url="https://api.inguardout.com/v1",
    api_key="gr-…",
    model="gpt-4o",
    default_headers={"X-Guardrails-Session-Id": run_id},
)
§01 Setting it up

1. Point the model at the proxy

Set base_url and your proxy key on ChatOpenAI (or any OpenAI-compatible model class). Every LLM call in every chain now runs the pipeline.

2. Add the session header

Pass X-Guardrails-Session-Id per task so the agent’s many requests group into one run – one budget, one reconstructed trace in the Runs view.

3. Gate tools with the callback

Attach the guardrails callback handler so tool executions ask the checkpoint API “may I proceed?” and honor allow / deny / require-approval.

4. Observe, then enforce

Start in FIX mode, review what gets flagged in the dashboard, then flip individual checks to PREVENT per key.

§02 Frequently asked questions

Does this replace LangChain’s built-in guardrail middleware?

It moves the enforcement point. Middleware runs inside each application and must be added to each agent; the proxy runs on the wire and covers all of them uniformly, with cross-run state (budgets, loops, sequences) middleware cannot see. You can run both – they do not conflict.

Does it work with LangGraph?

Yes – LangGraph nodes call models through the same model classes, so the base-URL swap covers them, and graph nodes that execute consequential steps can consult the checkpoint API like any tool.

What about streaming chains?

Streaming is buffered in the current version – guardrails need the complete output to judge it. Chains work unchanged; tokens arrive when the response has passed.

Which checks apply to agent tool calls?

The full agent stack: tool allow/deny with schema validation, permission tiers, action grounding, taint tracking, loop guard, budgets, and optional sequence policies – based on the tool_calls in the model responses crossing the proxy.

§03 Related

Wire it into LangChain in two touchpoints

Swap the base URL on your chat model and add the checkpoint callback - then one run graph covers every chain. We are running a limited demo - sign up and we will get you in as soon as we can.