Skip to main content
Dome exposes Guardrails as LangChain Runnable objects through GuardrailRunnable. A runnable accepts a string or a dictionary with a query key, scans it, and returns a dictionary of the Guardrail result that the rest of the chain can branch on.

Install

LangChain support needs no extra, as described in Install Dome. Install Dome next to your LangChain packages:

Create Runnable Objects

Build the Guards you want, following Configure Guardrails, then take the Guardrail objects from the Dome instance:
Each runnable returns the Guardrail result as a dictionary. The keys used most often are flagged, guardrail_response_message for the original or sanitized content, and original_query.

Build a Guarded Chain

GuardrailRunnable is compatible with LangChain Expression Language, so you can compose it with prompts, models, and parsers:
Chains that contain Guardrail Runnable objects also support ainvoke().

Branch on a Guardrail Decision

The chain above sends the blocked message to the model whenever the input Guardrail triggers. Use RunnableBranch to take a different path instead:
GuardrailRunnable also accepts a dictionary with prompt and response keys, which it converts into a structured payload for Detectors that need both sides of an exchange.

Next Steps

Configure Guardrails

Define the Guards behind each runnable

Use Guardrails

Scan patterns outside LangChain
Last modified on August 12, 2026