The Policies module defines what AI Gateway does with each request that reaches a route before forwarding it to the LLM Provider, and what it does with the returned response. Each policy is linked to a single route and combines three optional blocks: Prompt Guard (filtering by moderation or regex), Prompt Enrichment (messages injected before the prompt), and Rate Limit (quotas by requests or tokens).
IMPORTANTYou must configure at least one section to save the policy. The form lets you combine Prompt Guard (Request), Prompt Guard (Response), Prompt Enrichment, and Rate Limit in any arrangement, but at least one must be filled in.
Learn how to:
The Policies page lists registered policies with pagination. You can filter by:
Use Search to apply the filter and Clear to reset it.
Columns shown in the table:
In the Actions column of the row you want, click the View icon. The Policy details screen opens in read-only mode, showing:
No field is editable on this screen. To change the policy, click the Edit button in the card header โ see Edit Policy.
Select the target Route. This field is a searchable select. Type part of the endpoint to filter.
Open the policy you want (see View Policy) and, on the Policy details screen, click the Edit button in the card header. The Update Policy form opens with the current data. Change the required fields and click Save.
In the Actions column of the row you want, click the Delete icon. Confirm the operation in the "Do you want to delete policy [policyId]?" dialog.
IMPORTANTDeletion is permanent and cannot be undone. Deleting a policy makes the associated route accept requests without guardrails, prompt enrichment, or rate limiting.
Field | Type | Required | Rules |
|---|---|---|---|
| Route | Searchable select | Yes | Lists registered routes. |
This optional block validates the request before it reaches the LLM provider. It combines three subfeatures: moderation, regex, and custom response.
MODERATION AND REGEX CAN BE COMBINEDModeration and regex can be used together in the same Prompt Guard Request. Filling in one does not disable the other: when both are configured, the request must pass both checks, and the same custom response applies to whichever one blocks it.
Field | Type | Required | Rules |
|---|---|---|---|
| Moderation model | Select | Conditional: required when Moderation API Key is provided | Only value currently available: omni-moderation-latest (OpenAI moderation model). |
| Moderation API Key | Select | Conditional: required when Moderation model is provided | Lists registered API Keys, displayed by the key's Description followed by the provider in parentheses. A key with no Description is displayed by its identifier. |
Field | Type | Required | Rules |
|---|---|---|---|
| Regex action | Select | Conditional: required when Regex patterns have at least one pattern | Values: Reject, Mask. |
| Regex patterns | List of tags | Conditional: required when Regex action is provided | List of regular expressions. |
Custom response returned when the request is rejected by moderation or regex.
Field | Type | Required | Rules |
|---|---|---|---|
| Custom response message | Text | Conditional: see the rules below | Minimum 1 character. |
| Custom response status code | Integer | Conditional: see the rules below | Between 200 and 599. |
The two fields are always filled in together: providing one makes the other required. In addition, the whole Custom response pair becomes required when:
WHEN THE CUSTOM RESPONSE IS OPTIONALThe Custom response pair is optional only when the Prompt Guard Request is limited to a regex with Regex action = Mask, without moderation. In that case the content is masked and the request continues to the provider, so there is no blocking response to return.
This optional block validates the response returned by the provider before returning it to the requester. There is no moderation here, only regex and custom response, with the same pairing logic as the request.
STREAMING RESPONSESFor now, only responses returned without streaming are masked by the expressions configured in this section.
Field | Type | Required | Rules |
|---|---|---|---|
| Response regex action | Select | Conditional: required when Response regex patterns has at least one pattern | Values: Reject, Mask. |
| Response regex patterns | List of tags | Conditional: required when Response regex action is provided | List of regular expressions applied to the returned content. |
Field | Type | Required | Rules |
|---|---|---|---|
| Response custom message | Text | Conditional: required when Response custom status code is provided or when Response regex action = Reject | Minimum 1 character. |
| Response custom status code | Integer | Conditional: required when Response custom message is provided or when Response regex action = Reject | Between 200 and 599. |
This block is optional as a section, but has required internal rules when enabled. When you add at least one message, you must provide at least one complete entry (role + content). Messages are prepended to the original prompt in the order they appear in the list.
Use Add message to add a new Message entry and the delete icon to remove entries.
Field | Type | Required | Rules |
|---|---|---|---|
| Role | Select | Yes (per message) | Available values: system and developer. |
| Content | Long text (textarea) | Yes (per message) | Minimum 1 character. |
AVAILABLE ROLESsystem and developer are the only selectable roles. They are the ones that make sense for instructions prepended to the prompt. If a policy shows a different role when opened for editing, the form flags it with the message This role is no longer supported. Select "system" or "developer". and requires the change before saving.
This optional block limits consumption by time window. When enabled, it requires you to choose exactly one limit type: requests or tokens.
MUTUAL EXCLUSIONThe policy cannot include requestCount and tokenCount at the same time. Choose one of them.
The screen shows a Rate limit type selector with Tokens and Requests buttons that determine which format is used.
Field | Type | Required | Rules |
|---|---|---|---|
| Rate limit type | Toggle (Tokens / Requests buttons) | Conditional: required when Rate Limit is enabled | Choose Tokens or Requests. Mutually exclusive. |
| Rate limit value | Integer | Conditional: required when a Rate limit type is selected | Positive integer. |
| Time unit | Select | Conditional: required when Rate Limit is enabled | Values: Seconds, Minutes, Hours. |
Access to each action in the Policies journey depends on its own permission. Without the corresponding permission, the screen element does not appear โ the interface never shows an unavailable action as disabled.
Permissions are granted in Access Control, on the Roles screen, under the AI Gateway product. The table below lists each one exactly as Access Control displays it.
Permission | Group in AC | Description in AC | Identifier |
|---|---|---|---|
| List Policies | policies | Allows listing Policies | ai-gateway.policies.list |
| View Policy | policies | Allows viewing a Policy | ai-gateway.policies.view |
| Create and Update Policies | policies | Allows creating and editing Policies | ai-gateway.policies.create-update |
| Delete Policies | policies | Allows deleting Policies | ai-gateway.policies.delete |
| List Routes | routes | Allows listing Routes | ai-gateway.routes.list |
| View API Key | api-keys | Allows viewing an API Key | ai-gateway.api-keys.view |
The last two belong to other journeys and are required by specific Policies actions, shown in the next table.
Action | What it unlocks | Required permissions |
|---|---|---|
| List | Policies item in the sidebar menu; listing with table and pagination | List Policies |
| Filter by Route | Route filter field on the listing (the screen's only filter) | List Policies + List Routes |
| View | View icon on the row and the Policy details screen | List Policies + View Policy |
| Create | Create Policy button | List Policies + Create and Update Policies + List Routes |
| Edit | Edit button inside Policy details | List Policies + View Policy + Create and Update Policies + List Routes |
| Delete | Delete icon on the row | List Policies + Delete Policies |
View: the Moderation API Key's (provider) suffix additionally requires View API Key. Without it, the field shows only the bare id.
Create and Edit: List Routes is what feeds the form's Route field with the available routes.
EDITING REQUIRES VIEWINGThe Edit button only exists inside the Policy details screen. Because of that, a user holding Create and Update Policies but not View Policy has no path to edit an existing policy. This is expected platform behavior, not a bug.
We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more