Bedrock guardrails with LiteLLM: how one guardrail can screen OpenAI, Anthropic and private model traffic
If you run LiteLLM as your AI gateway and want the same Amazon Bedrock guardrail applied to models outside Bedrock, the supported method is the Bedrock ApplyGuardrail API. LiteLLM calls that API with the guardrail's guardrailIdentifier and guardrailVersion, a region, and an optional IAM role to assume. Because the check runs at the gateway rather than inside the model service, the same guardrail can screen traffic bound for OpenAI, a private model you serve yourself, or another provider that LiteLLM routes to. This section explains what that setup needs and where the decisions sit. It does not cover the guardrail policy content itself, which is configured in Bedrock, or the per-team and per-key attachment rules covered elsewhere on this page.
Before you configure anything, decide which guardrail version the gateway will pin. Pinning guardrailVersion to a numbered version keeps screening behavior stable while you test changes in a draft, and it gives your change record a fixed reference. Decide also which AWS region hosts the guardrail, since the gateway must call that region's endpoint, and confirm that the region is acceptable under your data residency commitments. Next, choose the credential path. The gateway can use credentials it already holds, or it can assume an IAM role dedicated to guardrail calls. A dedicated role lets you grant only the bedrock permissions needed to apply the guardrail and makes the calls easy to separate in AWS CloudTrail. Confirm the exact IAM actions and trust policy with the current Bedrock documentation and your own AWS account team, because permission names and policy requirements are AWS decisions, not LiteLLM ones.
Read the LiteLLM Bedrock guardrails documentation before you write the configuration, and check that the LiteLLM version you run supports the settings you need. Then test with a non-production key and a single non-Bedrock model. Send a prompt that the guardrail should block and one it should allow, and confirm which messages are screened and which are not, including responses and streaming output. Verification also needs a network check: the gateway must reach the Bedrock runtime endpoint for your chosen region from its own subnet, and any egress proxy or firewall rule must allow it. Ask your team to record the guardrail ID, version, region and role in configuration as code, so that a later change is reviewed like any other infrastructure change.
How a request passes the LiteLLM gateway and the Bedrock guardrail
A request starts in the calling application inside the client network and reaches the LiteLLM proxy, which runs the input check. The proxy assumes the optional IAM role, then sends the prompt to the Bedrock guardrail through the ApplyGuardrail API in the configured region. Only after the input passes does the proxy call the upstream model, which can be a non-Bedrock provider. The response goes back through the guardrail for output screening before it reaches the client. Check the role permissions, the guardrail version and the region at each hand-off.
The LiteLLM proxy screens input and output with a Bedrock guardrail around any upstream model.
What you need before connecting Bedrock guardrails to LiteLLM
Connecting a Bedrock guardrail to LiteLLM touches your gateway release, your AWS account, IAM, the region and the network path between them. Confirm each item below before you change the gateway configuration, because most failed connections trace back to one of these settings.
Pinned LiteLLM release line
Decide which LiteLLM version the gateway will run and pin it in your deployment, rather than tracking the latest image. Check the LiteLLM releases page and the Bedrock guardrails docs for the release that supports the guardrail configuration you plan to use. Confirm the exact version with your team before you test, because the supported minor versions change over time. Write the chosen version into your change record so upgrades later are deliberate.
Bedrock guardrails docsGuardrail identifier and version
Create the guardrail in the AWS account that will host the screening, then record its guardrail identifier and the numbered version you will reference. Use a numbered version rather than the working draft so that a later edit to the policy does not silently change what the gateway enforces. Confirm which content filters, denied topics and sensitive information rules the guardrail contains, since those determine what LiteLLM will block or mask.
IAM permission for ApplyGuardrail
The principal that LiteLLM uses must be allowed to call the ApplyGuardrail operation on the specific guardrail ARN, not on all resources in the account. Grant only that action and scope it to the guardrail version you reference. Ask your AWS administrator to confirm the policy with a test call before you rely on it in production, because a permission error will appear as a failed request in the gateway logs rather than a clear configuration warning.
Optional role to assume
Decide whether the gateway uses its own credentials directly or assumes a dedicated IAM role for guardrail calls. A dedicated role lets you separate guardrail access from other AWS permissions, and it makes the trust policy and audit trail easier to review. Confirm the trust relationship allows the gateway's identity to assume the role, and that the session duration fits your rotation policy. Record the role ARN with the guardrail details.
Region choice
Pick the AWS region where the guardrail exists and set that region explicitly in the LiteLLM configuration. The region determines where prompt and response text is sent for screening, so check it against your data residency commitments before you go live. Confirm the guardrail is available in the chosen region, and avoid assuming that a model's region and the guardrail's region must match.
Outbound network path from the gateway
The gateway must reach the AWS endpoints for the guardrail service in your chosen region over the network. In restricted or private networks, confirm the egress rules, proxy settings and DNS resolution from every gateway pod or host, not just from one test machine. Test the path from the same runtime the gateway uses, since a firewall rule that allows administrators may still block the workers.
Credential storage for AWS access
Keep AWS credentials or role configuration out of plain configuration files. Store them in your secret manager and inject them at runtime, and confirm who can read them. The LiteLLM production guidance also asks that the master key be kept in a secret manager, so apply the same handling to AWS access. Rotate credentials on the schedule your security team already uses for other workloads.
Configuring a Bedrock guardrail on the LiteLLM proxy, step by step
This sequence takes a Bedrock guardrail from creation in AWS to a verified check on a test model route, so that screening applies to traffic from any model behind the LiteLLM gateway.
Create and version the guardrail in AWS
In the AWS account and region that will host the guardrail, the platform or security team defines the content policies, denied topics, word filters and sensitive information rules in Amazon Bedrock Guardrails. Then they create a numbered version of the guardrail so the gateway pins to a fixed policy rather than a draft. Record the guardrail identifier, the version number and the region. The step is complete when a test call to the ApplyGuardrail API with a prompt that violates a configured rule returns an intervened result in the AWS console or CLI. Confirm current console and API behavior in the AWS documentation for your region.
Set up the IAM role and trust
The platform team creates an IAM identity for the LiteLLM proxy, either an instance or pod role or a dedicated role that the proxy assumes. The permissions policy must allow the ApplyGuardrail action on the specific guardrail ARN, and the trust policy must allow the proxy's identity to assume the role if you use role assumption. Keep the scope narrow so the proxy cannot modify guardrails. The step is complete when a short test run using the same credentials chain, outside LiteLLM, successfully calls ApplyGuardrail for that guardrail and version and is denied for an unrelated resource.
Add the guardrail entry to the LiteLLM configuration
In the proxy configuration file, add a guardrail entry that uses the Bedrock guardrail provider. Set guardrailIdentifier and guardrailVersion to the values recorded in the first step, set the region to match the guardrail, and add the role to assume if the proxy uses one. Store any sensitive values through your secret manager integration rather than in plain text. Choose the guardrail mode (pre_call, during_call or post_call) per the guardrail modes topic. The step is complete when the proxy starts without configuration errors and the guardrail appears in the proxy's list of loaded guardrails.
Attach the guardrail to a test model route
Bind the guardrail to one test model route, ideally a non-production model from a provider other than Bedrock, to show that the ApplyGuardrail call works for any model behind the gateway. Use a test virtual key restricted to that model so the change cannot affect other callers. Confirm the route resolves to the intended provider and that the guardrail is listed on the route. The step is complete when a request to the route returns normally and the proxy logs show the guardrail was invoked for that request.
Verify a blocked prompt and the decision log
Send a prompt through the test route that the guardrail should block, using a clearly synthetic example such as a denied topic from your own policy. The caller should receive the guardrail's blocking response rather than a model answer. Then check the LiteLLM logs for a record of the guardrail decision, and check the AWS side for a matching ApplyGuardrail invocation in the CloudWatch metrics or logs you have enabled. The step is complete when the blocked request, the proxy log entry and the AWS-side evidence all agree on the same request.
Test a permitted prompt and the failure path
Send a benign prompt to confirm that allowed traffic still reaches the model and returns a normal response, which catches over-broad policies early. Then simulate a failure, such as a wrong guardrail version or a role without permission, and observe how the proxy behaves. Confirm with your security owner whether the gateway should fail open or fail closed for this route before production use. The step is complete when both the allowed and failure cases behave as the written decision requires and the results are recorded with the configuration version.
Applying one guardrail across OpenAI, Anthropic, Bedrock and private models
When the target model runs on Amazon Bedrock, the guardrail operates on the same platform that serves the model. The text it screens is the prompt the model receives and the response the model returns, and the guardrail decision is tied to the identifier and version you set in the LiteLLM configuration. Confirm in the documentation for your LiteLLM version whether a Bedrock-hosted model uses the native Bedrock path or the ApplyGuardrail call, because configuration and check placement can differ between the two.
- Input screening: the system text and user messages are evaluated before inference, using the guardrail identifier and version you configured.
- Output screening: the model response is evaluated before it returns to the calling application.
- Region alignment: the region in the LiteLLM settings should match the region where the guardrail was created, so checks run where you expect.
- Role assumption: if you configure an IAM role, confirm the gateway's identity can assume it and that the role is allowed to call the guardrail.
- Version pinning: use a fixed guardrail version rather than a draft, so a policy change cannot take effect without review.
Before relying on this path, send test prompts that should be blocked and confirm the guardrail action appears in the gateway logs.
For OpenAI, Anthropic and other providers called through LiteLLM, the guardrail is applied at the gateway, not inside the provider. LiteLLM translates the caller's request into the provider format, and the Bedrock guardrail evaluates the text in that request and in the provider's reply. The provider never sees a blocked prompt if the check runs before the call, and the caller never receives a response that failed the output check. LiteLLM's Bedrock guardrail documentation describes this use with non-Bedrock models, LiteLLM Bedrock guardrails docs.
- Input seen: the text extracted from the OpenAI-format request after LiteLLM normalizes it, which may differ from the raw payload a client sent.
- Output seen: the text of the provider reply, which the gateway checks before passing it back.
- Request path: each screened request makes an additional call to Bedrock, which adds latency and a separate usage charge on the AWS account.
- Content types: confirm which message parts, tool calls, images and files the guardrail evaluates for each provider format.
- Streaming: confirm whether streamed output is screened as it arrives or only after completion, and what the caller sees when a stream is stopped.
Also confirm how the gateway behaves when the Bedrock call fails or times out, and whether that behavior matches your policy.
Models you serve yourself, for example through vLLM or Ollama inside your network, have no provider-side safety layer, so the gateway guardrail may be the only screening step. The guardrail still sees the prompt and response text, but the check calls an AWS endpoint, which means prompt content leaves your network for screening. That data flow is the first thing to confirm, because it can conflict with a requirement that prompts stay inside a private or air-gapped environment.
- Egress path: confirm the gateway can reach the regional Bedrock endpoint, and whether your network design uses a private endpoint or a public route.
- Data handling: confirm what the guardrail provider retains, and whether your privacy and records obligations allow prompt text to be sent for screening.
- Restricted networks: in an air-gapped or heavily restricted network, the Bedrock check may be unavailable, so plan a fallback such as a built-in or self-hosted check.
- Credentials: the gateway needs AWS credentials or a role for the Bedrock call, so store them in a secret manager and scope them to the guardrail.
- Latency: measure the added time per request on your own model servers, since a local model may respond faster than the screening call.
Before approval, document the data flow for your security and privacy reviewers and confirm that the screening path matches what they have approved.
Mapping LiteLLM configuration fields to Bedrock guardrail settings
This table maps each LiteLLM guardrail setting for Bedrock to the AWS resource or decision it comes from and the team that owns it. Read it before writing the config so the guardrail, its version, the role and the region are agreed across the security and platform teams.
| Setting | Where the value comes from | Who owns it |
|---|---|---|
| guardrailIdentifier | The guardrail ID shown in the Amazon Bedrock console for the guardrail you created, not its display name | Security or AI governance team that authored the guardrail policy |
| guardrailVersion | A numbered published version of that guardrail, or the draft if the docs permit it; pin a published version for production | Security team that approves each published change |
| region | The AWS Region where the guardrail exists, which must match the Bedrock endpoint LiteLLM calls | Platform team, aligned with data residency rules |
| Optional IAM role | An IAM role the gateway assumes to call ApplyGuardrail, with permission scoped to the guardrail resource | Cloud or identity team that writes the trust and permission policies |
| Gateway credentials | The base identity the LiteLLM proxy uses before role assumption, kept in a secret manager rather than in config files | Platform team, with review by the security team |
| Guardrail mode (pre_call, during_call, post_call) | A LiteLLM setting in the guardrail config that controls when screening runs relative to the model call | Application or AI platform owner, with sign-off from security |
| Scope (default_on or per team, key or model) | A LiteLLM setting that decides which traffic the guardrail screens, set in the gateway configuration | AI platform team, with team leads consulted on exceptions |
| Logging and blocked-response behavior | How LiteLLM records guardrail outcomes and what caller sees when content is blocked, set in LiteLLM | Compliance and platform teams together |
Securing the guardrail credentials and the screening path
A Bedrock guardrail is only as trustworthy as the path that calls it. The cards below cover the identity LiteLLM uses to call ApplyGuardrail, where its credentials live, who can route traffic through the screen, what gets logged, and what happens when AWS cannot be reached.
Scope the ApplyGuardrail permission
The gateway's identity needs permission to call the ApplyGuardrail operation on the specific guardrail, not broad Bedrock access. Grant it only the guardrail ARN you configured, and keep model invocation permissions separate so the screening identity cannot call models directly. Review the policy when you add a second guardrail version or region. Ask your AWS team to confirm the exact action names against current IAM documentation before you write the policy.
Bedrock guardrails docsAssume a role instead of using keys
Configure LiteLLM to assume an IAM role for guardrail calls rather than storing a long-lived access key in its configuration. The gateway's own runtime identity, such as a Kubernetes service account or instance profile, then performs the assumption. Long-lived access keys should not appear in the proxy config file. Confirm with your identity team how role trust is scoped, including the external ID and session duration you require.
Keep credentials in a secret manager
Any static credential or the LITELLM_MASTER_KEY used alongside the guardrail should be held in a secret manager and injected at runtime, not committed to Git or baked into images. LiteLLM Enterprise lists AWS Secrets Manager among its supported secret manager integrations, which fits a Bedrock setup. Rotation procedures should be tested, because a rotated key that breaks guardrail calls will silently change what traffic gets screened.
Limit which teams and keys can route
Attaching the guardrail to all traffic is simpler, but many organizations need it only on sensitive teams or models. Restrict routes so that teams without the guardrail cannot reach models that bypass it, otherwise the screen is optional in practice. Virtual keys can be restricted to specific models, which gives a practical control point. Ask your LiteLLM administrators to verify that a key without the guardrail cannot reach an unscreened route.
Log decisions without raw prompts
Guardrail logs should record which guardrail and version ran, the action taken, and the category that triggered, without copying the prompt or response text where policy forbids it. Decide this before go-live, because request logs can capture payloads by default. Confirm with your privacy team which fields may be stored, how long they are kept, and who can read them. Test a blocked request end to end to confirm no raw content appears in the log sinks.
Decide behavior when AWS is unreachable
If the ApplyGuardrail call fails, the gateway either blocks the request (fail closed) or forwards it unscreened (fail open). Fail closed protects data but turns an AWS outage or network fault into a model outage for every team. Write the decision down per guardrail and per data class, and test it by blocking the path to AWS in a staging environment. Ask your AWS and platform teams to document the regional endpoint dependency and the timeout you configure.
How to test that the guardrail actually screens every route
Before the guardrail goes live, the team should test it on every route a caller can reach, not only the chat completions path the team uses most. Build a test plan with known-bad prompts (for example, prompts that contain a card-style number, a fake API key or a classic injection phrase written for your own test set) and benign prompts that should pass untouched. Run each set through each route the gateway exposes, including the endpoints for embeddings and responses if your callers use them. Record the expected outcome per cell of that matrix, then compare what the gateway actually returns against it. Use test data you have approved for this purpose, and confirm in your own environment which guardrail modes and endpoints your LiteLLM version applies the guardrail to, because coverage differs by route and release.
Test streaming and non-streaming calls separately. A guardrail that screens a complete response may behave differently when the model returns tokens incrementally, and some configurations only screen input. For each known-bad prompt, check whether the blocked or masked result reaches the caller as a normal error, a redacted message or a partial stream that has already leaked text before the check runs. Also confirm how the gateway handles a Bedrock guardrail intervention on output, because an output check that never fires is the most common silent gap. Verify output screening directly by sending a benign prompt that is likely to elicit text matching your output test pattern, then confirming the response is intervened. Keep the logs for each test so you can show which requests were screened.
Finally, confirm that no model route bypasses the guardrail. Call a model that should have the guardrail attached and a model that should not, then check the gateway configuration and the request log for each call to see whether the guardrail was applied. Test a key or team that is restricted to a specific model, and a request that names a model alias, because aliases and fallbacks are where a policy attached to one model can be missed. Ask your engineering team to confirm in writing which configuration keys control attachment and fallback behavior in the version you run, and to confirm what happens when the Bedrock call fails, since that decides whether traffic passes unscreened. Repeat the full matrix after every gateway upgrade or guardrail version change.
Common Bedrock guardrail failures in LiteLLM and how to fix them
This table lists the failures teams most often hit when LiteLLM calls the Bedrock ApplyGuardrail API, with the likely cause and the first fix to try for each. Work down the rows in order, since a wrong guardrail version or region is quick to rule out before you inspect IAM or network paths.
| Failure | Likely cause | First fix to try |
|---|---|---|
| Guardrail version mismatch | guardrailVersion points to DRAFT or a version number that was never published, or to a version that was edited after the config was written | Confirm the version in the Bedrock console, then set guardrailVersion to the published version number and redeploy the proxy config |
| Missing ApplyGuardrail permission | The IAM principal used by LiteLLM lacks bedrock:ApplyGuardrail on the guardrail ARN | Add bedrock:ApplyGuardrail scoped to the guardrail ARN and version, then test a single request with a known blocked prompt |
| Role trust errors | The optional IAM role LiteLLM assumes does not trust the principal running the proxy, or the session credentials are not reaching the proxy process | Check the role trust policy for the calling identity, then verify the proxy's runtime identity can call sts:AssumeRole on that role |
| Region mismatch | The region setting differs from the region where the guardrail was created, so the identifier is not found | Compare the guardrail's region in the console with the region in the LiteLLM config and align them |
| Network blocks to AWS endpoints | Egress rules, a proxy, or a private network path block the Bedrock runtime endpoint for the chosen region | From the proxy host or pod, test connectivity to the regional Bedrock runtime endpoint and check security groups, firewall and DNS resolution |
| Guardrail not attached to the tested route | The guardrail is defined in config but not bound to the model, key or team that the test request uses, so no check runs | Send the test through the exact model name and key that carry the guardrail, and confirm the guardrail appears in the request's logs |
| Non-Bedrock model appears unguarded | Callers reach the model through a route that bypasses the gateway, so no ApplyGuardrail call is made | Confirm the caller's base URL points to the LiteLLM proxy and that direct provider keys are not in use |
Questions buyers ask before hiring help with Bedrock guardrails in LiteLLM
What drives the effort and cost of applying Bedrock guardrails in LiteLLM?
The main drivers are the number of routes that need screening, the IAM and network setup between your gateway and AWS, how deep the testing goes, and how mature your existing LiteLLM deployment already is. Each model route needs its own guardrail mapping, so a gateway serving a handful of models with one team is far simpler than one serving many teams, providers and regions. IAM work grows when you assume roles across accounts, and network work grows when the gateway runs in a restricted network that must reach the Bedrock endpoint in your chosen region. If your LiteLLM proxy already has PostgreSQL, Redis and a tested configuration pipeline, the integration is a smaller change. Ask any partner to price these items separately in a written scope, and to state which are one-time work and which recur, such as guardrail version updates and retesting after changes.
How long does a Bedrock guardrail integration with LiteLLM take?
Duration depends on the scope agreed in writing, not on a fixed template. The schedule usually follows the number of routes, the number of teams whose traffic must be screened, whether the IAM role and region settings already exist, and how much testing and evidence the security team requires before go-live. A single-team proof of concept on one model will move faster than a multi-region rollout covering several providers. Ask for the milestones in the written scope, the client decisions each milestone depends on, and what happens if a guardrail version changes mid-project. Any duration quoted before scope is agreed should be treated as a guess.
What must our team provide before an engagement starts?
You will need to provide access to the AWS account where the guardrail lives, or a reviewed plan for the IAM role LiteLLM will assume, along with the region the guardrail uses. You also need a named guardrail owner who can approve policy changes and decide which guardrail version is live. Test data is essential: examples of prompts, responses and tool calls that should be blocked, masked or allowed, drawn from real use cases but sanitized where needed. Finally, provide access to the LiteLLM environment, including the configuration repository, the admin account and the environments where changes are tested. Missing any of these usually delays the work more than the technical integration itself.
Can our own team set up Bedrock guardrails in LiteLLM without a partner?
Yes, if your team already runs LiteLLM in production and has engineers comfortable with AWS IAM, Bedrock and the LiteLLM configuration format. The integration uses the Bedrock ApplyGuardrail API, configured with a guardrail identifier, a guardrail version, a region and an optional IAM role, so the configuration itself is not large. The harder parts are verifying that policies behave as intended for each model route, handling failures without exposing data, and proving the controls to reviewers. Teams with limited LiteLLM or AWS experience often choose a partner for design review and testing while keeping day-to-day configuration in-house. Check the LiteLLM Bedrock guardrails documentation for the current configuration keys before you plan the work.
Does applying a Bedrock guardrail make our AI gateway compliant?
No. A guardrail is a technical control that screens prompts and responses, and it contributes evidence to a compliance program, but it does not certify anything by itself. Only independent auditors and certification bodies issue audit reports, attestations or certifications. DeployOpen prepares systems, configuration records and test evidence for compliance assessments, but it does not issue those assessments. Ask your assessor which controls they expect to see, how they want guardrail configuration and changes logged, and what testing evidence they accept. The guardrail configuration, approval workflow and retest results are the parts that usually matter most in a review.
What breaks most often when Bedrock guardrails are added to LiteLLM?
The most common failures are configuration mismatches and network or permission errors. A guardrail identifier or version that does not match the region set in LiteLLM will fail calls, and an IAM role that lacks permission to invoke the guardrail will block traffic. Teams also miss that the guardrail is applied to non-Bedrock models through the same API, so a model route can be left unscreened if the mapping is incomplete. Another frequent issue is a guardrail version change that alters behavior without anyone retesting affected routes. Build test cases for each route, confirm the failure behavior when Bedrock is unreachable, and record which guardrail version each route uses.
Should we use the same guardrail for every model behind LiteLLM?
Not necessarily. A single guardrail is simpler to govern, but different teams, models and data sensitivity levels may need different policies. The LiteLLM Bedrock integration lets you apply a guardrail to models from other providers, so one policy can cover several routes. Decide which routes must share a policy, which need stricter settings, and who approves changes before configuring anything. Keep a record of which guardrail identifier and version each route uses, because that record is what your security reviewers will ask for first.
How DeployOpen scopes, delivers and supports a Bedrock guardrail integration
DeployOpen treats the Bedrock guardrail as one control in a larger LiteLLM gateway, not as a standalone feature. We scope which models, keys and teams the guardrail covers, build the ApplyGuardrail wiring in your infrastructure, and hand over settings and evidence your security and compliance teams can review.
How we scope
- Engagements are fixed-scope, with the models, teams and keys covered agreed in writing before work starts.
- We confirm which Bedrock guardrail, version and AWS region your data handling rules allow the gateway to call.
- We map the IAM role the gateway will assume and the permissions that role needs, written out before access is granted.
- Scope documents name which non-Bedrock providers the guardrail will screen, so no model is left out by accident.
How we build
- We configure the guardrail identifier and version in the LiteLLM proxy configuration, stored as code under change control.
- We set up IAM role assumption and region settings in your AWS account, then test that the gateway can call ApplyGuardrail.
- We test blocking and masking behavior with prompts that should be caught and prompts that should pass, for each model in scope.
- We check how the guardrail behaves on failure, including timeouts and denied permissions, and document the result.
How we hand over
- You receive the configuration, IAM policy definitions and a record of the test cases and results.
- We document where the guardrail runs in the request path so your security team can review it against its own controls.
- Runbooks cover rotating the guardrail version, changing the IAM role and diagnosing denied or throttled ApplyGuardrail calls.
- Knowledge transfer sessions walk your platform and security staff through the settings they will own after handover.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, scoped separately from the build.
- When the guardrail version or the LiteLLM release changes, we retest the integration before the change reaches production.
- Support scope, response expectations and retest cadence are agreed in the written retainer, not assumed.
- Ask any provider for a quote that states the guardrail, models and environments covered so the comparison is like for like.

