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 the Guardrail result as a dictionary so downstream components can branch on it.

Install

Install Dome with the dependencies required by the local Detector and OpenAI model used in this example:
  • The langchain-openai package installs langchain-core, which is required by GuardrailRunnable. It also provides the ChatOpenAI integration used below.
  • The local Dome extra installs the model dependencies for the prompt-injection-deberta-v3-base Detector configured in this example (LangChain does not use this extra).
If you use remote inference or Detectors included in the base package, you can install vijil-dome without the local extra. See Install Dome for all available extras.

Create Runnable Objects

Build the Guards you want by following Configure Guardrails, then retrieve the Guardrail objects from the Dome instance:
Each runnable returns the Guardrail result as a dictionary. The most commonly used keys 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 include 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 November 3, 2026