How Lakera Guard with LiteLLM screens chat traffic at the gateway
A team routing model calls through a self-hosted LiteLLM proxy and needs a layer that screens prompts for prompt attacks and content risks before they reach a model provider. The supported way to add that layer is the lakera_v2 guardrail configured in LiteLLM, which sends request text to Lakera Guard and acts on its verdict. Plan around one limit from the start: this integration applies only to the /v1/chat/completions endpoint. It does not cover the Responses API, /v1/messages, MCP or A2A traffic. Any application that calls another endpoint will pass through the gateway unscreened by Lakera, so the scope of the guardrail must match the endpoints your callers actually use.
Before you configure anything, inventory every path into the gateway. List which applications, coding tools and chat clients send traffic to /v1/chat/completions, and which use the Responses API, Anthropic-style messages or MCP tool calls. For the second group, decide whether Lakera screening is still needed through another control, such as a different guardrail, a network restriction or a change to the calling application. Also confirm the exact LiteLLM release you run and check the current lakera_v2 documentation for that version, because guardrail settings and supported request fields can change between releases. Ask Lakera, through your account team, which Lakera Guard API options and data handling terms apply to your tenant and region before any production prompts are sent.
Treat the chat-only boundary as a finding to record, not a footnote. In the security review, state which endpoints are covered, which are not, and which compensating controls apply to the uncovered paths. Test with prompts that resemble known prompt attacks on a covered endpoint and on an uncovered one, so the evidence shows the difference in behavior rather than relying on the documentation alone. Keep these test results with the guardrail configuration so auditors and internal reviewers can trace what was screened and what was not.
What you need before configuring the Lakera Guardrail in LiteLLM
The Lakera guardrail runs inside the LiteLLM proxy, so the gateway itself has to be in a supported state before any guardrail is added. The cards below cover the gateway version and data stores, the Lakera account, network paths, and how the two secrets are stored. Confirm current Lakera endpoint and account details with Lakera and the LiteLLM Lakera docs before you start.
Supported LiteLLM proxy version
Pin the proxy to a release on a supported minor line before you add guardrails. LiteLLM maintains support for the four most recent stable minor versions for both open source and Enterprise deployments, and the GitHub releases page lists v1.105.1, published October 14, 2026, as the latest release in the supplied sources. Check the release notes for the lakera_v2 guardrail behavior in the version you choose, since guardrail settings can change between releases.
LiteLLM releasesPostgreSQL and Redis backing stores
PostgreSQL is the primary supported database and is required for virtual keys, so teams that scope Lakera to keys or teams need it in place. Redis 7.0 or newer is required once more than one proxy instance runs, because it holds shared rate limits, router state and cache. Size both stores for your expected traffic and confirm that the proxy can reach them from every replica before you test guardrail behavior.
LiteLLM production guideLakera Guard API credential
Create a Lakera Guard API key under the account that will own the guardrail, and decide who can rotate it. Ask Lakera which endpoint and region your account uses and whether your plan covers the content categories you intend to screen. Record the account owner, the key's creation date and the rotation schedule in your own register so the credential can be traced when a security review asks where the guardrail calls go.
Outbound access from the proxy to Lakera
The proxy must reach the Lakera Guard API over HTTPS on every replica, so the egress rule has to allow that destination from the proxy's subnet. In restricted networks, confirm the exact hostname and region with Lakera and allow it through the firewall or proxy. Prompt text leaves your environment on each guarded request, so the network team and the data owner should approve that flow before go-live.
Master key in a secret manager
LITELLM_MASTER_KEY must start with sk- and should live in a secret manager, not in a config file or a pod spec in plain text. The master key administers virtual keys, teams and guardrail settings, so limit who can read it and log each retrieval. Inject it into the proxy at runtime and keep it out of Git-managed configuration that the guardrail definition is stored in.
Lakera key handling in configuration
Store the Lakera API key in your secret manager and reference it from the proxy's environment rather than writing it into the guardrail entry in the config file. Confirm which environment variable or parameter name the lakera_v2 guardrail reads in the LiteLLM Lakera docs for your release. Use separate Lakera keys for development and production so that a test configuration cannot reduce production screening or exhaust its quota.
LiteLLM Lakera docsConfiguring the lakera_v2 guardrail step by step
This sequence takes the lakera_v2 guardrail from a stored credential to a verified request path on one test key. Each step ends with a check, so the team confirms the guardrail runs on chat completions before it applies to production traffic.
Store the Lakera API key as a secret
The platform team places the Lakera credential in the secret manager the gateway already uses, or in the environment variable store that the LiteLLM proxy reads at startup. The key stays out of the configuration file and out of version control. Confirm with your Lakera account owner which key type and project the gateway should use before creating it. This step is done when the proxy starts with the key resolved from the secret store, and a search of the repository and proxy logs finds no plaintext value.
Define the lakera_v2 guardrail in the proxy configuration
Add a guardrail entry to the proxy configuration with a name your teams will recognize, the guardrail type set to
lakera_v2, and the API key reference from the previous step. Keep the file in the same Git repository as the rest of the gateway settings so changes go through review. Check the exact field names against the LiteLLM Lakera integration page before you commit, because field names can change between LiteLLM releases. This step is done when the proxy starts and lists the guardrail in its guardrail list.Choose pre_call, during_call or monitor mode
Set the mode that fits the risk and the latency tolerance of this route.
pre_callscreens the request before it reaches the model and blocks it on a match.during_callruns alongside the model call.monitorrecords findings without blocking. Many teams begin in monitor mode to see what would be flagged, then move to a blocking mode once the findings are understood. Record the chosen mode and the accountable owner in the change ticket. This step is done when the restart log or config check shows the selected mode for this guardrail.Attach the guardrail to a test key
Create a virtual key scoped to a test team and a limited set of models, then attach the
lakera_v2guardrail to that key through its guardrails setting. Confirm the exact setting name in the virtual keys documentation for your release. Using a dedicated test key keeps production traffic unchanged during the trial. This step is done when the key's details list the guardrail name and a test request made with that key shows guardrail activity in the proxy logs.Send test prompts to chat completions
Send one benign prompt and one prompt-attack test string from your security team's approved test set to
/v1/chat/completionsthrough the proxy, using the test key. Label both as test traffic in your records. Withpre_call, the attack prompt should return an error from the proxy and should never reach the provider, so check the provider's usage records for it. Withduring_call, the check runs in parallel with the model call, so the provider may still receive the request. The benign prompt should return a normal completion. This step is done when both results match expectations.Confirm the monitor event and request path
In monitor mode, confirm that the flagged test prompt appears as a logged event with the guardrail name and that the request was still completed. Then confirm the coverage limit: send one request to an endpoint outside chat completions, such as the Responses API, and check that the guardrail does not run on it. Knowing this gap before rollout keeps teams from assuming protection on routes it does not cover. This step is done when the log entries match each test case and the coverage results are written into the rollout record.
How a chat request passes through the Lakera check
The request starts at the client, which sends a chat completions call to the LiteLLM proxy inside the trust boundary. In pre_call mode the proxy sends the prompt to Lakera Guard and waits for a verdict before any model call, so a flagged request never reaches the provider. In during_call mode the Lakera check runs in parallel with the model call. Check the endpoint first: only /v1/chat/completions traffic goes through this path, while Responses API, /v1/messages, MCP and A2A calls bypass it.
Chat completions path through the LiteLLM proxy and the Lakera Guard check.
Choosing pre_call, during_call or monitor mode for Lakera
In pre_call mode, LiteLLM sends the prompt to Lakera before it calls the model provider. If Lakera flags the request, the gateway can stop it, so the provider never receives the flagged content. This is the mode that enforces the control most directly. A blocked request does not invoke the model, and the caller gets an error it can handle. The cost is latency: every request waits for the screening result before the model call starts, whether the request is allowed or blocked.
- Strongest enforcement: flagged prompts never reach the provider, which matters when provider data handling is part of your review.
- Clean cost record: blocked requests do not generate provider charges, so spend reflects only traffic that reached a model.
- Added wait on every request: the full screening round trip sits in front of the model call.
- Failure behavior: confirm what the gateway does when the Lakera service is slow or unreachable, and set that behavior on purpose.
- Caller handling: applications must handle the blocked-request error, or users will see failures they cannot act on.
Measure the added latency with your own prompts and expected traffic before you choose this mode for a user-facing route.
In during_call mode, the Lakera check runs alongside the model call, so the screening wait overlaps with the provider's processing time. The caller's wait is set by the slower of the two steps, which usually means less added latency than pre_call. The trade-off is that the model call may already be in progress or complete when Lakera returns a block decision. The request can still be stopped or withheld from the caller, but the provider may already have processed and billed it.
- Lower added latency: the screening wait overlaps with the provider call, so the overall response time is usually shorter.
- Provider cost on blocked calls: a request blocked mid-flight may still be billed by the provider, so blocked traffic has a cost.
- Output exposure: confirm whether any model output can reach the caller before the block decision arrives.
- Provider capacity: blocked requests still consume provider quota and capacity.
- Test the blocked path: run flagged prompts through a staging key and compare billed tokens with a
pre_callrun.
Before you choose this mode for prompt attacks, confirm in LiteLLM's Lakera documentation and a test run exactly how a block is returned to the caller.
In monitor mode, LiteLLM sends prompts to Lakera and records what it finds, but it does not stop any request. Security and platform teams use this mode to see how often prompt attacks and content risks appear in their own traffic before they decide on enforcement. Caller experience and provider spend stay as they were, and the findings go to logs for review. The mode produces evidence, not protection.
- Evidence without impact: findings show the volume and type of risky prompts without changing user outcomes.
- False positive review: check flagged business prompts before anything is blocked, so legitimate work is not disrupted later.
- Screening calls still happen: each request still goes to Lakera, so confirm its data handling terms and any cost attached to those calls.
- Logs need an owner: findings only help if someone reviews them and keeps them under your logging retention policy.
- Not a control: a flagged prompt still reaches the model in this mode, so do not present monitor mode as enforcement in your evidence.
Agree in advance which review outcomes will move a route to a blocking mode, and write that decision rule into the pilot plan.
Most rollouts move through the modes in sequence: monitor during a pilot, then a blocking mode once the team trusts the findings. The right order depends on the risk of each workload, the users who reach it and whether the team can support blocked-request handling. Because LiteLLM applies guardrails per team, key or model, you can enforce on one route while another stays in monitor mode. The integration covers only the chat completions endpoint, so routes that use other endpoints need a separate plan.
- Pilot in monitor: run on a limited set of keys and review findings over a period agreed before the pilot starts.
- Enforce high-risk routes first: start blocking where exposure is greatest, such as routes that accept external content.
- Use pre_call for hard controls: choose it when provider exposure must be prevented and the added latency is acceptable.
- Use during_call for latency-sensitive routes: choose it when the block outcome is acceptable and the billing trade-off is understood.
- Record the mode per route: note the chosen mode, owner and review date so auditors can trace each control.
Confirm which mode each route uses, who approves a change to it, and that every route in scope calls the chat completions endpoint, because a mode change alters the control.
Mapping LiteLLM requests and keys to Lakera screening
This table shows which parts of a LiteLLM request reach Lakera, which keys, teams and models decide whether a call is screened, and which outcome fields a security team can review. Read it as a checklist for scoping the guardrail, then confirm field-level detail in the Lakera and LiteLLM documentation for your versions. The main takeaway is that screening only covers traffic the guardrail is attached to and sent to the chat completions endpoint.
| Item | What the integration exposes | What to confirm before go-live |
|---|---|---|
| Endpoint in scope | Requests to the chat completions endpoint only | Whether Responses API, messages, MCP and A2A traffic needs a separate control |
| Message content sent to Lakera | Chat messages from the chat completions payload | Exactly which message roles and tool content fields are forwarded |
| Virtual key scope | Keys attached to the guardrail receive screening | How keys without the guardrail are treated and how to audit that gap |
| Team scope | Team-level guardrail assignment decides which team traffic is screened | Whether team assignment is available in your edition and version |
| Model scope | Guardrail can be limited to requests for chosen models | Model names used in config match the names callers send |
| Mode per request path | Pre-call, during-call or monitor behavior applies to matched calls | Which mode each team and environment uses and who approved it |
| Blocked request outcome | Blocked calls return an error to the caller and are logged | The exact error shape and whether callers handle it |
| Logged outcome fields | Guardrail result and request metadata appear in LiteLLM logs | Which Lakera result fields are stored and for how long |
Hardening the Lakera integration and its credentials
The Lakera guardrail adds a dependency on an external service and a credential that can screen every chat request. The controls below cover where that credential lives, who can change the guardrail, what prompt content gets logged, and what happens when Lakera cannot answer.
Store the Lakera key in a secret manager
The Lakera API key lets anyone who reads the proxy configuration call the service under your account. Keep it out of config.yaml and out of environment files committed to source control, and reference it from a secret manager your platform team already operates. LiteLLM Enterprise lists integrations with AWS, Azure, Google, HashiCorp Vault and CyberArk, so confirm which of these your edition supports for guardrail credentials and how rotation is applied without restarting the proxy.
Limit which keys and teams get the guardrail
A guardrail attached globally screens all traffic, including low-risk internal tools. Decide which virtual keys, teams and models must pass through Lakera, and test that a request from an out-of-scope key is not screened by accident. Confirm with LiteLLM how guardrail attachment works on keys and teams in your version, and whether team-level guardrails are available in your edition, before you rely on that scoping for compliance evidence.
Least privilege on proxy configuration
Anyone who can edit the guardrail block can switch mode, remove the guardrail or change its default_on setting without a code review. Separate who can deploy configuration changes from who can use the admin UI, give the Lakera key a read-only path to pods, and record every change to the guardrail definition through your change process. Ask LiteLLM which admin roles and audit log events are available in the edition you plan to run.
Decide what prompt content is logged
Screened prompts often contain personal data, and the guardrail request and the normal request log can both store them. Review which logging callbacks run alongside Lakera, whether request and response bodies are written to the database or to an external sink, and how long those records stay. Set retention in line with your privacy and records policies and confirm that the content is masked or excluded where required. Test with synthetic prompts before real traffic is routed.
Choose fail-open or fail-closed behavior
If Lakera times out or returns an error, the gateway either lets the request continue unscreened (fail-open) or rejects it (fail-closed). Fail-open keeps applications available but leaves prompt attacks unchecked for that window. Fail-closed protects data but turns a vendor outage into an application outage. Document the choice per workload, set timeouts and alerting on guardrail errors, and test both paths in staging before production traffic depends on either.
Test the guardrail after every change
Each change to the Lakera key, the mode, the attachment scope or the LiteLLM version can silently change what gets screened. Keep a fixed set of benign and attack prompts, run them through the chat completions endpoint for each affected key and team, and confirm that blocked requests return the expected error and that logs show the guardrail ran. Repeat the check after every upgrade of the LiteLLM proxy.
Where Lakera does not screen traffic
The Lakera guardrail in LiteLLM (lakera_v2) screens only the /v1/chat/completions endpoint. It does not screen traffic sent to the Responses API, /v1/messages, MCP servers or A2A agents. Any request that reaches the gateway through one of those paths passes without Lakera Guard checks, so a policy that says prompts are screened for attacks is only true for chat completions calls. Treat the guardrail as coverage for one endpoint and plan separate controls for the others before you describe the gateway as screened.
Start with an inventory. List every application, SDK, developer tool, chat client and agent that sends traffic through the gateway, and record the endpoint each one calls, the team and virtual key it uses, and whether it sends tool outputs or file content. Gateway logs and the model and route fields on requests can show which paths are in use. Ask each owning team to confirm its endpoints, because coding tools and agent frameworks often switch to the Responses API or Anthropic-style messages format without a visible configuration change. Record the result as the basis for the policy, and repeat the check whenever a new client is onboarded or a team upgrades its SDK.
For paths the guardrail does not cover, decide what replaces it. Options include restricting those routes to specific keys through model access settings, applying a different guardrail that supports the path (confirm its endpoint support with the vendor or the LiteLLM documentation before you rely on it), blocking the path until a control exists, or accepting the gap in writing with the risk owner. Test each decision with a known attack payload sent through every path, and keep the results with the guardrail configuration so that auditors and security reviewers can see what was tested and what was not.
Common Lakera Guard failures in LiteLLM and how to fix them
This table lists the failures teams most often hit when running Lakera Guard as a LiteLLM guardrail, with the likely cause and the fix for each. Read it when a guardrail seems to skip traffic, blocks legitimate prompts, slows requests or stops working after a change. Most failures trace back to endpoint scope, mode choice or configuration handling rather than to the model itself.
| Symptom | Likely cause | Fix |
|---|---|---|
| Guardrail does not run on Responses API calls | The lakera_v2 integration only supports the /v1/chat/completions endpoint, not the Responses API, /v1/messages, MCP or A2A. | Route those calls through a chat completions path that is screened, or add a separate control for the unsupported endpoints. Document the gap in your risk assessment. |
| Benign prompts are blocked | Lakera flags text it reads as an attack, often on security-related content, quoted documents or unusual formatting, and the guardrail is set to block. | Review the flagged request in logs, tune the policy or application context, and consider monitor mode while you measure false positives before enforcing. |
| Added latency in pre_call mode | Screening runs before the model call, so each request waits for the Lakera check to return. | Measure the added delay under realistic load. If latency is unacceptable and risk allows, evaluate during_call mode, accepting that the model may start before a block takes effect. |
| Requests fail or hang when Lakera times out | The external service is slow or unreachable, and the gateway's handling of that failure depends on the guardrail configuration. | Confirm the timeout and failure behavior with your configuration and LiteLLM documentation, test it by simulating an unreachable endpoint, and set the policy your risk owners approved. |
| Guardrail stops working after a restart | The Lakera API credential is missing from the environment or secret store the restarted gateway reads, often because it was set only in a shell session. | Store the credential in the secret manager your deployment uses, reference it from configuration, and confirm after each restart that the guardrail loads. |
| Monitor mode logs show findings but no alerts fire | Monitor mode records detections in logs only. Nothing notifies anyone unless you connect the logs to alerting. | Route guardrail log events to your logging or SIEM tool, define an alert threshold, and assign an owner who reviews the findings on a set schedule. |
| Guardrail appears inconsistent across teams or models | The guardrail is attached at a different scope for some keys or models, or a policy override was added without review. | List which keys, teams and models the guardrail applies to, confirm inheritance, and test each scope with a known attack prompt before relying on it. |
Questions buyers ask about running Lakera Guard with LiteLLM
What drives the cost of running Lakera Guard with LiteLLM?
The main cost drivers are the number of guardrail points you configure, how many endpoints and teams must be covered, and how much of the LiteLLM gateway already exists in your environment. Lakera Guard is a separate service with its own commercial terms, so its usage fees come from your Lakera contract, not from DeployOpen or LiteLLM. Effort on the DeployOpen side depends on the existing gateway setup, the number of guardrail policies, and the testing you need before go-live. Ask for a quote that separates one-time build and test work from any recurring support or retainer, and that states which Lakera fees, if any, are assumed to sit under your existing contract.
How long does configuring and testing Lakera Guard with LiteLLM take?
Duration depends on scope, so no fixed timeline applies across engagements. A single guardrail on one chat completions route with a test plan is a much smaller job than rolling out pre_call and during_call modes across several teams and models with monitor-mode tuning. Timing should be set out in the written scope before work starts, including the test cycles, the change window for the gateway configuration, and the point at which monitor-mode findings are reviewed. Ask for the milestones and the dependencies on your Lakera account access and your gateway environment.
What does our team need to provide before the work starts?
You need to provide the working LiteLLM proxy, or agree on its deployment, plus access to the configuration you manage for it. You also need a Lakera Guard API key or account access for the environment, an agreed list of the models and chat completions routes in scope, and the teams or keys that should be covered. Security or compliance reviewers should state which prompt attack and content risks matter for your use cases, and who decides how blocked requests and monitor-mode findings are handled. Confirm with Lakera and your own environment whether the API endpoint, region and data handling terms meet your requirements.
Can an internal team set up Lakera Guard with LiteLLM alone?
Yes, a team with LiteLLM proxy experience and access to a Lakera account can configure the lakera_v2 guardrail without outside help, since the integration is a configuration change on the gateway. The harder parts are deciding the mode for each route, designing tests for prompt attacks, and reviewing what gets logged when a request is blocked or flagged. Teams without someone who owns gateway configuration, security testing and logging review usually find that the test and evidence work takes longer than the configuration itself. Compare that effort with a fixed-scope quote, and be clear about who will maintain the setup after handover.
Does the Lakera contract cover the cost of the guardrail calls?
Your Lakera contract governs Lakera Guard usage fees, rate limits and data terms, and the integration does not change those commercial terms. Configuring the guardrail in LiteLLM does not create a separate Lakera subscription, but every screened request may count toward your Lakera usage, so check the metering basis before rollout. Ask your Lakera representative how calls are counted for chat completions requests and whether monitor mode, which still calls the service, is billed the same way as blocking mode. Share the expected traffic volume with your contract owner so the usage estimate reflects your environment.
Does Lakera Guard screen the Responses API, messages or MCP traffic through LiteLLM?
No. The LiteLLM Lakera integration, guardrail lakera_v2, supports only the /v1/chat/completions endpoint. It does not screen the Responses API, /v1/messages, MCP or A2A traffic. If your applications use those paths, prompts on them will not pass through Lakera Guard, so you need another control for those routes or a design that routes them through supported endpoints. Confirm the endpoints your clients actually call before you rely on this guardrail for a policy requirement.
How does the LiteLLM edition affect team-level guardrails for Lakera Guard?
Team-level guardrails and logging are part of LiteLLM Enterprise, so if you need Lakera Guard applied to some teams but not others, you should confirm that your edition supports it. The open-source edition is licensed under MIT for most of the code, while Enterprise features sit under the license in the enterprise directory. Under the Enterprise license, you can attach guardrails per team, which matters if different business units need different modes. Ask the LiteLLM team to confirm current edition features against your required configuration before you finalize the design.
Which mode should we pick first: pre_call, during_call or monitor?
Start with monitor mode on a limited set of routes to learn what Lakera flags in your real traffic, then move to pre_call blocking where you need requests stopped before the model call. The during_call mode runs in parallel with the model call, which can reduce added latency but means a flagged request may already have reached the provider. Review the trade-off between latency and enforcement with your security owner, and document the choice per route. Your written scope should state which mode applies to each endpoint and the criteria for promoting a route from monitor to blocking.
How DeployOpen scopes and delivers the Lakera Guard integration
DeployOpen approaches Lakera Guard with LiteLLM as a fixed-scope piece of work inside your own infrastructure. We agree in writing which chat completions routes are covered, which guardrail modes apply and how results are tested and handed over, then build and document the integration so your team can run it.
How we scope
- Inventory which applications call the LiteLLM gateway through the chat completions endpoint and which need screening.
- Confirm which other endpoints carry traffic that Lakera Guard will not cover, and agree how those are handled.
- Agree in writing which guardrail modes apply, and which teams, keys or models the guardrail attaches to.
How we build
- Configure the lakera_v2 guardrail in your LiteLLM config and store the Lakera API credential in your secret manager.
- Test pre_call, during_call and monitor modes against your own sample prompts and expected block and allow outcomes.
- Document the decision for each route, including what happens to traffic outside the chat completions endpoint.
How we hand over
- Deliver the configuration as code, the test cases and results, and the coverage map showing which routes are screened.
- Walk your platform and security teams through how to change modes, add scope and read guardrail logs.
- Record open risks, such as unscreened endpoints, so the owners can decide on compensating controls.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, LiteLLM upgrades and continuous testing are available as a retainer.
- Confirm with Lakera and your own environment which service terms, data handling and regional settings apply before go-live.

