n8n owns triggers, connectors, and canvas ops. ValGuard owns the rule that decides whether an LLM node's output may become the next node's input. Point the OpenAI credential (or an HTTP Request node) at ValGuard, then branch on the validation result.
When you need this
A support workflow classifies tickets, then an IF node routes on urgency. The model returns "high" as a string. Your Code node expects an integer 1–5. Without a gate, the branch mis-fires or throws. With ValGuard, an enum or range rule fails first. You re-ask once, then block and escalate with a rule ID in the log.
Architecture
flowchart LR
T[n8n trigger] --> L[HTTP Request or LLM node]
L --> VG[ValGuard proxy]
VG --> M[Upstream model]
M --> VG
VG -->|pass| N[Next n8n node]
VG -->|block| E[IF: escalate or ticket]
The trust boundary is the ValGuard proxy. Rules run there before the next n8n node sees the completion. Non-LLM nodes stay outside that boundary.
Setup (recommended pattern)
- Create a ValGuard agent (for example
support-triage) and attach schema or enum rules for the fields your IF nodes read. - Start that agent in shadow mode. Confirm would-block rates on real traffic before you enforce.
- Set environment variables your n8n instance can read:
export VG_PROXY=https://api.valguard.ai
export VG_API_KEY=vg_live_...
export VG_AGENT=support-triage
- Point the LLM node's OpenAI-compatible credential at
$VG_PROXY/v1, with your ValGuard API key. Or use an HTTP Request node as below. - Add an IF (or Switch) node on HTTP status or
X-VG-Validation-Status. Route failures to a human queue or ticket.
Code and config
HTTP Request node body (same shape as curl):
curl -s "$VG_PROXY/v1/chat/completions" \
-H "Authorization: Bearer $VG_API_KEY" \
-H "X-VG-Agent: $VG_AGENT" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [
{"role": "system", "content": "Return JSON only: {\"team\",\"urgency\",\"confidence\"}"},
{"role": "user", "content": "Billing dispute, card charged twice"}
]
}'
n8n HTTP Request settings:
- Method:
POST - URL:
{{$env.VG_PROXY}}/v1/chat/completions - Headers:
Authorization: Bearer {{$env.VG_API_KEY}},X-VG-Agent: {{$env.VG_AGENT}},Content-Type: application/json - Body: the JSON payload above
Then IF on status 200 and validation pass, else escalate.
On validation failure
| Outcome | What n8n should do |
|---|---|
| Pass | Continue to the next node with the model JSON |
| Re-ask | ValGuard may retry the model once within your plan limit; treat the final response as the source of truth |
| Block | Status and headers signal failure; IF routes to human queue; include rule IDs from the block envelope in the ticket |
| Shadow | Rules evaluate and log; traffic is not blocked; use this before enforce |
Prefer branching on validation headers or a known block shape. Do not parse free-text error strings as your only signal.
Latency
Rule packs evaluate in microseconds inside the engine. A guarded request through the HTTP layer adds about 0.36 ms p50 on measured hardware with a mocked upstream. The model call still adds hundreds of milliseconds.
Block and re-ask rules buffer the full reply before ValGuard emits it. Token-by-token streaming to the n8n node applies when rules are warn, log, or shadow. See methodology and Trust.
Correlating IDs
Store your canvas run id next to ValGuard response headers:
X-Request-Id/X-Trace-Idon the ValGuard response- Optional inbound
traceparentif your stack already emits W3C trace context
Store those ids on the n8n execution or ticket so audit rows line up with the canvas run.
What this does not cover
- Non-LLM n8n nodes (Sheets, Slack, CRM) are not validated by ValGuard.
- ValGuard does not replace n8n's connector catalog, schedules, or inbound triggers.
- Fluent false claims with no rule signature still pass.
- Side effects that never go through an LLM call never see a rule.
- Outbound
http/webhooksteps from a ValGuard playbook send JSONPOSTonly: no custom headers or credentials, 10s timeout, 1 MiB response cap. Protect n8n webhooks with an unguessable path or IP allowlist if you call them from a playbook.
Deployment
Default is hosted SaaS. There is no local or open-source ValGuard runtime. Enterprise customers can self-host in a VPC or on-prem under a license. Evaluate with shadow mode on Free or any paid plan. Details: Trust and pricing.
Related
- Orchestration: when to use a ValGuard playbook vs n8n
- ValGuard + LangGraph
- ValGuard + OpenAI Agents SDK
- MCP security for tool-call gates
- Quickstart
FAQ
Does ValGuard replace n8n? No. Keep n8n for triggers and connectors. Add ValGuard where an LLM output can route work or trigger a side effect.
Can I call ValGuard from a Code node instead? Yes. Any HTTP client that can POST to /v1/chat/completions works. Prefer the LLM credential or HTTP Request node so ops can see the call on the canvas.
What if ValGuard is unreachable? The request fails. ValGuard does not skip rules and pass traffic through. Build the fallback in n8n if the feature must survive an outage. See Trust.
How do I export the rules later? Playbooks export as JSON (valguard-playbook-template/1), optionally with validators. Per-agent validator lists are available through the API. There is no org-wide policy file yet.
Next step
Wire your first agent with the quickstart, then run shadow mode rollout before you enforce on the canvas.