AI governance and assurance · LLM guardrails · policy engine

LLM guardrails architecture: input and output guard layers, policy engine, PII redaction, grounding checks and audit

A layered guardrail pattern around an LLM application: authenticate and screen the request, redact personal data, retrieve only what the user may see, call the model, then validate grounding and policy on the way out, with every step logged for audit.

A reference architecture from EITSAA, not a named client system. Service limits, prices and product features change, so confirm current details before you commit to a design.

  • OWASP Top 10 for LLM Applications
  • NIST AI RMF Generative AI Profile
  • Voluntary AI Safety Standard
  • ISO/IEC 42001
  • ACSC Essential Eight
  • Privacy Act and APPs

Architecture

Architecture diagram. Tinted boundaries show regions, accounts, networks and trust zones. Numbered arrows match the flow below.
LLM guardrails architecture: input and output guard layers, policy engine, PII redaction, grounding checks and audit architectureUsers and applications to AI gateway: request. AI gateway to Policy engine: authorise. Policy engine to Input filter: screen. AI gateway to PII redaction: redact. PII redaction to Retrieval index: retrieve. PII redaction to Approved LLM: prompt. Approved LLM to Grounding check: answer. Grounding check to Output filter: verify. Output filter to Audit and tracing: logApplicationGuardrail layer · private networkInput controlsOutput controlsModel and knowledgeUsers andapplicationsAuthenticated callersAI gatewayAuthn, quotas, rate limitsPolicy engineUse case, data class, modelInput filterInjection and topic checksPII redactionDetect, mask, tokeniseRetrieval indexDocument-level access controlApproved LLMPinned version, in-regionGrounding checkClaims versus sourcesOutput filterPolicy, PII, format validationAudit and tracingMasked, immutable1request2authorise3screen4redact5retrieve6prompt7answer8verify9logPlatform servicesIdentityprovider (SSO)Monitoring andalertsAudit logKey management(KMS)
  • People and clients
  • Network and edge
  • Security and identity
  • AI and ML
  • Monitoring, audit and analytics
  • Request or data flow
  • Asynchronous or optional
  • Boundary: region, account, network or trust zone

Request and data flow

  1. A user or application calls the gateway with a workload or user identity. Requests without valid identity or quota are rejected.

  2. The policy engine decides whether this caller may use this use case with this data class and model, and sets limits for tokens, steps and spend.

  3. The input filter screens for injection patterns, harmful content and out-of-scope topics, and treats retrieved content as data.

  4. The request passes through PII detection so that personal and confidential data is masked or tokenised unless the policy allows it to go to the model.

  5. Retrieval queries the index with the caller's entitlements, so only documents the user may see can enter the prompt.

  6. The prompt, built from a versioned system prompt and minimal context, is sent to the approved, pinned model in the permitted region.

  7. The answer returns to the guardrail layer rather than directly to the user. A grounding check compares claims with retrieved sources, requires citations and abstains when support is weak.

  8. The output filter applies content and format policy, removes anything that should not leave, and restores tokenised values where permitted.

  9. Prompts, retrieved context references, filter decisions and costs are written to a masked, immutable audit trail with trace identifiers.

Components and why they were chosen

ComponentWhat it doesWhy this choice
AI gateway (API gateway with an AI proxy such as LiteLLM, Azure API Management or Amazon API Gateway)Single entry with identity and quotas.Every app inherits the same controls.
Policy engine (OPA, Cedar)Policy as code on use case, data class and model.Versioned and testable.
Guardrail services (Amazon Bedrock Guardrails, Azure AI Content Safety, NeMo Guardrails, Llama Guard)Input and output classification.Defence in depth around the model.
PII detection (Amazon Comprehend, Microsoft Presidio, Purview)Detect and mask personal data.Reduces leakage risk and privacy exposure.
Retrieval index with access controlAuthorised retrieval only.Prevents oversharing.
Audit store (object storage with retention lock)Immutable traces.Evidence and investigation.

Design decisions and trade-offs

Where to enforce

Central gateway plus library checks in apps.

Why. Consistency with defence in depth.

Trade-off. Gateway latency and a shared dependency.

Filter strictness

Tier-based thresholds measured against false positives.

Why. Balances safety and usefulness.

Trade-off. Needs tuning and appeals.

Model-based or rule-based checks

Combine deterministic rules with classifier models.

Why. Rules are predictable, models catch variants.

Trade-off. Classifiers add cost and can be evaded.

Redaction method

Tokenise reversible values and mask the rest.

Why. Preserves utility without exposing data.

Trade-off. Token vault becomes sensitive.

Fail open or closed

Fail closed for high tiers, degrade gracefully for low.

Why. Matches the consequence of failure.

Trade-off. Closed failure reduces availability.

Well-architected pillars

Security

Defence in depth across input, retrieval, model and output, with least privilege and treatment of content as untrusted.

Reliability

Gateway deployed across zones with timeouts, fallbacks and tested fail-closed behaviour.

Performance

Run independent checks in parallel and cache policy decisions. Budget latency per layer.

Cost optimisation

Classifier calls and extra tokens have a cost. Tier checks by risk and sample low-risk traffic.

Operational excellence

Version and test policies, review blocked-request samples and tune with evidence.

Sustainability

Use small classifier models and cache repeated checks.

Network, identity and data

Networking

The guardrail layer runs inside a private network. Model, retrieval and logging endpoints are reached by private connectivity in the permitted Australian region. Applications cannot call model providers directly.

Identity and least privilege

Callers are authenticated with SSO or workload identity. The user's entitlements flow to retrieval. Guardrail services use scoped roles, and secrets are held in a managed vault.

Data and encryption

Classify data before it reaches the layer. Mask personal information in logs and keep tokens in a restricted vault. Set retention for prompts and outputs by class and records obligations.

Security and compliance mapping

ControlHow this design addresses it
Prompt injection and insecure output handlingInput screening, untrusted-content handling and output validation address OWASP LLM01 and LLM05.
Sensitive information disclosurePII redaction and access-controlled retrieval address OWASP LLM02 and privacy obligations.
Unbounded consumptionRate, token and spend limits address OWASP LLM10.
Event loggingMasked, immutable traces support investigation and audit. Essential Eight.
Testing and monitoringGuardrail effectiveness is tested and monitored, supporting the Guidance for AI Adoption.

Mappings show how the design supports each control. They are not certifications, and EITSAA does not claim IRAP assessment or compliance for any reference architecture.

Failure modes, targets and scaling

  • Target RTOFollows the application. Typically under one hour for the gateway with multi-zone deployment.
  • Target RPONear zero for policy and configuration in version control. Audit records are replicated.
  • Scaling and limitsSized by requests per second and the cost of the most expensive check.
Failure modeMitigation
Filter blocks legitimate workMeasure false positives, offer an appeal path and tune by tier.
Novel injection bypasses the filterLayered controls, tool least privilege and regular red-teaming.
Redaction misses an identifierTest with seeded data, use multiple detectors and mask logs.
Grounding check rejects correct answersCalibrate on labelled samples and allow abstention with escalation.
Guardrail service is unavailableFail closed for high tiers, degrade to a safe fallback and alert.

Observability and runbooks

  • Block, redact and abstain rates by rule.
  • Injection attempts and blocked exfiltration.
  • Groundedness scores on sampled traffic.
  • Latency by layer and cost per request.

Cost drivers and levers

Classifier calls, extra tokens, gateway compute and log storage.

  • Tier checks by risk.
  • Cache repeated decisions.
  • Use small models for classification.
  • Sample low-risk traffic for scoring.

Implementation and fit

Phased approach

  1. Introduce the gateway with identity, quotas and logging.
  2. Add PII redaction and access-controlled retrieval.
  3. Add input and output filters and grounding checks, tested against an evaluation set.
  4. Add policy as code, red-team regression and monitoring dashboards.

Anti-patterns to avoid

  • Relying on the system prompt as the only control.
  • Filtering input but not output.
  • Passing model output directly to a database or shell.
  • Logging raw prompts with personal data.
  • Never measuring false positives.

When to use it

  • Customer, staff or citizen-facing LLM applications.
  • Any application that sends organisational data to a model.

When not to

  • A personal experiment with no organisational data.
  • Systems where a deterministic workflow would do the job.

More in ai governance and assurance

Related insights

Discuss this architecture

Tell us your systems, constraints and timeline. We reply within one business day, and the initial conversation is free.