Add Qualifire Guardrails to an n8n Flow (Option A: HTTP Request node)
This guide shows how to wrap your LLM agent (or any text-producing step) with Qualifire’s real-time evaluation & hallucination detection using a single HTTP Request node. It covers output guardrails (post-generation) and an optional input guardrail (pre-generation).Prefer a “drop-in model” experience? See Qualifire’s OpenAI-compatible node for n8n.
For the API reference, see the Evaluate endpoint.
Prerequisites
- An n8n instance (self-hosted or Cloud).
- A Qualifire API key.
- Your LLM/agent step already producing a response (e.g., OpenAI Chat node, custom function, etc.).
Add your API key to n8n
{{$env.VAR_NAME}}.
Flow Overview
- Output guardrail: Agent → HTTP Request (Qualifire Evaluate) → IF (gate) → Continue or Fallback
- Input guardrail (optional): User → HTTP Request (Qualifire Evaluate) → IF (gate) → Agent
Step-by-Step: Output Guardrail with HTTP Request
Configure request basics
Set the following:
- Method:
POST - URL:
https://proxy.qualifire.ai/api/evaluation/evaluate - Send:
JSON
Add headers
Toggle the fx button to enter expressions where needed.
Content-Type: application/jsonX-Qualifire-API-Key: {{$env.QUALIFIRE_API_KEY}}
Set the request body
Click fx on Body and paste:
If you prefer a raw JSON template, wrap dynamic fields with
{{ JSON.stringify(...) }} and don’t add extra quotes around the expression.Gate the result with an IF node
Add an IF node after the HTTP node to block or allow the response. Use an expression that fails “closed” (treats unknown/error as flagged):
- True (flagged): route to a Fallback (e.g., “I can’t answer that,” human handoff, or a safer re-ask path).
- False (clean): continue to your normal response path.
Optional: Input Guardrail (pre-generation)
Place the same HTTP Request pattern before your agent and pass only the user input (or a short context window) inmessages. For example:
Observability Tips
- In the HTTP node, use Resolve expressions to preview the final JSON payload before running.
Troubleshooting
401/403 Unauthorized
401/403 Unauthorized
Broken JSON
Broken JSON
Use the object expression approach (as shown). Avoid double-stringifying the body.
Empty env value
Empty env value
Confirm the env var is set in the n8n process environment (e.g., passed to the Docker container).
Over-blocking
Over-blocking
Narrow your gate by checking specific detectors, labels, or scores. You can whitelist certain
type/name in evaluationResults.