Skip to main content

Overview

Bifrost Enterprise supports Lakera Guard as a third-party guardrail provider for screening LLM conversations. Lakera owns the project policy and detector decision. Bifrost owns when the policy runs and what happens next: it can block the interaction, record the detection without intervening, or redact supported matches before content continues through the gateway. Bifrost calls Lakera’s POST /v2/guard endpoint with an OpenAI Chat Completions-style messages array. Chat Completions already use this shape; Bifrost normalizes Responses API and ordinary Anthropic Messages text into the same message format before screening.
Streaming output: For output and both rules, Bifrost holds the response until the stream is complete, screens the complete output once, and then blocks, redacts, or releases it. Lakera does not inspect individual response chunks in this integration.

Prerequisites

  • Bifrost Enterprise with guardrails enabled
  • A Lakera API key
  • A Lakera project with a policy assigned to it
  • Bifrost must be able to connect to the Lakera API over HTTPS. If your deployment restricts outbound connections, allow the configured Lakera API host.

Set Up Lakera

  1. Sign in to the Lakera Platform.
  2. Open Policies and create or select the policy you want Bifrost to enforce.
  3. Configure the policy’s detectors and sensitivity.
  4. Open Projects, create or select a project, and assign the policy to it.
  5. Copy the project ID. Bifrost sends this value as project_id on every screening request.
  6. Open API Access and create an API key for Bifrost.
Lakera Policies page showing policies, detector coverage, sensitivity, and assigned projects
Use a separate Lakera project for each application and environment. The project selects the assigned policy, so sharing one project can unintentionally couple policy changes across workloads.
Lakera’s default policy is intentionally strict. Review its enabled detectors and sensitivity before attaching it to production traffic.

How It Works

  1. Create a Lakera provider configuration in Bifrost.
  2. Attach the configuration to a guardrail rule.
  3. Set the rule to run on input, output, or both.
  4. When the rule matches, Bifrost converts the retained conversation into Lakera’s OpenAI-style messages format.
  5. Bifrost sends the messages, Lakera project ID, breakdown request, and Bifrost request metadata to POST /v2/guard.
  6. Lakera evaluates the latest interaction using the earlier messages as context and returns a flagged decision.
  7. Bifrost applies the provider’s configured action.
  8. Bifrost records detector summaries and Lakera’s request UUID in guardrail diagnostics when available.
When action is redact, Bifrost also sends payload: true so Lakera can return supported finding locations:
Both runtime screening and Verify use POST /v2/guard. Verification checks that Bifrost can make a normal screening request with the configured credentials and project, so it can appear in Lakera request logs. There is no separate no-event health-check call.

Configuration Fields

Configure Bifrost

Lakera Guard configuration in Bifrost showing required credentials and redaction controls
  1. Go to Guardrails > Providers.
  2. Select Lakera Guard and click Add Configuration.
  3. Enter a descriptive Name.
  4. Enter the required API Key and Project ID.
  5. Choose the Bifrost enforcement Action.
  6. For redact, choose the Redaction mode and Redaction strategy.
  7. Leave Base URL blank to use https://api.lakera.ai, or enter your Lakera regional or enterprise API base.
  8. Set the timeout, enable the configuration, and click Verify.
  9. Save the configuration and attach it to a rule under Guardrails > Configuration.

Actions And Outcomes

For a blocked request, Bifrost includes the detector summary when Lakera returns one. In LLM Logs, the request is marked Error and shows a message such as Blocked by Lakera Guard: Prompt attack detected (confidence: very likely).

Redaction Behavior

Lakera does not return a complete transformed prompt or response. For supported detectors, it returns finding locations in the optional payload. Bifrost maps those spans back to the original message text and performs the rewrite using the selected redaction strategy and mode. Lakera documents payload locations for PII, profanity, and custom detector regular-expression matches. Other flagged detectors, such as prompt attack, can produce a policy decision without a maskable payload. In redact mode, Bifrost blocks those findings because allowing the original unsafe content would defeat the rule. Bifrost also fails closed if a returned span is missing, malformed, crosses text boundaries, or cannot be mapped safely. This preserves existing block behavior for findings that cannot be transformed correctly.
Lakera’s masking of PII in the Lakera dashboard is separate from Bifrost redaction. Dashboard masking controls how request details are displayed or stored in Lakera; it does not provide transformed content for Bifrost to forward.
For Chat Completions and Text Completions with multiple output choices, Bifrost screens each choice independently. A blocking or unmaskable violation in any choice blocks the complete response. Maskable findings stay aligned with the choice that produced them.

Request Compatibility

The earlier retained messages provide conversation context; Lakera evaluates the latest interaction rather than independently reclassifying every old turn. Use the rule’s max_turns_to_send setting to limit how much conversation history Bifrost includes. For output rules, Bifrost sends the retained request conversation together with the selected model output. Earlier history is context only and is not rewritten during the output pass.

Streaming Behavior

Input screening happens before Bifrost calls the model, including when the client requested streaming output. For output screening, the Lakera provider requires the complete normalized conversation. Bifrost therefore buffers the full model response, calls Lakera once, and then:
  • returns a guardrail intervention if Lakera blocks it;
  • releases the transformed response if Bifrost can redact all findings; or
  • releases the original response when the policy allows it.
This adds end-of-stream guardrail latency and means the client does not receive incremental chunks before the Lakera decision. See Streaming Output Guardrails.

Observability

When available, Bifrost records Lakera diagnostics such as:
  • flagged
  • detected count and detector types
  • policy IDs
  • Lakera request_uuid
  • number of Lakera screening requests, including per-choice output checks
Assessment summaries do not include the original matched text. Use Lakera’s request UUID to correlate Bifrost diagnostics with Lakera logs.

Troubleshooting