Skip to content

LangFlow Integration

MendGuardrailsComponent is a native LangFlow node that validates text against Mend AI guardrails inline inside any visual flow — no custom code required.


Install

pip install mend-guardrails langflow   # or: pip install mend-guardrails lfx

How to load the component

LangFlow discovers components from a directory pointed to by the LANGFLOW_COMPONENTS_PATH environment variable. The directory must contain category sub-folders, each with an __init__.py.

/app/custom_components/          ← LANGFLOW_COMPONENTS_PATH
  └── processing/
        ├── __init__.py
        └── mend_guardrails.py   ← copy or symlink guardrails/integrations/langflow.py

processing/__init__.py:

from .mend_guardrails import MendGuardrailsComponent

__all__ = ["MendGuardrailsComponent"]

Start LangFlow:

LANGFLOW_COMPONENTS_PATH=/app/custom_components langflow run

Docker:

docker run -d \
  --name langflow \
  -p 7860:7860 \
  -v ./custom_components:/app/custom_components \
  -e LANGFLOW_COMPONENTS_PATH=/app/custom_components \
  -e MEND_KEY=<your-key> \
  langflowai/langflow:latest

Typical flow topology

Place the node on either side of the LLM — or both:

Chat Input
    ↓
Mend Guardrails  (Direction = input)
    ↓
OpenAI / LLM node
    ↓
Mend Guardrails  (Direction = output)
    ↓
Chat Output
  • The input node catches prompt injection, jailbreak attempts, and PII before the LLM sees the user's message.
  • The output node catches harmful content and PII in the model's reply before returning it to the user.

Component reference

Inputs

Field Default Description
Input Text — Text to validate. Connect from a Chat Input or LLM output node.
Direction input input: check user prompt. output: check LLM response.
Block on Violation true When enabled, stop the flow on a violation. When disabled, log and pass through.
Mend Key (advanced) — Secret key. Falls back to the MEND_KEY environment variable.

Output

A single Validated Text output port that emits the original text unchanged when all guardrails pass. Connect it to the next node exactly like any other text output.


Next steps

  • Observability — attach an on_guardrail_event callback or OTel handler to the MendGuardrailsComponent for audit logging and tracing.
  • Examples — complete working code examples.