Skip to main content
TL;DR: Wrap any Dome Guardrail in a GuardrailRunnable and drop it into an LCEL chain. It accepts a string or a {"query": ...} dict and returns a dict whose flagged and guardrail_response_message keys drive the rest of the chain.
Dome integrates with LangChain through the GuardrailRunnable wrapper, which turns a Guardrail into a standard LangChain Runnable. No extra install is required beyond LangChain itself, since the integration builds on langchain-core.

Building a Guarded Chain

1

Create the Guardrail Runnables

First build a Dome instance and pull its input and output Guardrails with get_guardrails(), then wrap each one.
GuardrailRunnable accepts an optional enforce argument (default True). When enforce=False, the Guardrail flags content but does not replace it, which is useful for shadow-logging in production.
2

Assemble the Chain

GuardrailRunnable objects are compatible with LCEL. A runnable returns a dict; downstream steps read guardrail_response_message (the sanitized text) and flagged (whether the Guardrail triggered).
The chain passes the input through the input Guardrail, feeds the sanitized text to the prompt and model, then scans the model output through the output Guardrail before returning it. Invoke it with a string or a {"query": ...} dict.
3

Add Branching (Optional)

By default the blocked message flows to the model whenever the input Guardrail triggers. To route around the model instead, use LangChain’s RunnableBranch and key on the flagged field.

Next Steps

LangGraph

Secure a LangGraph Agent with the Trust Runtime

Configure Guardrails

Choose which Guards run
Last modified on July 16, 2026