Availability
For how guardrails work, refer to Guardrails.
Providers
All providers examine tool results.
External providers follow the outbound network policy. To allow a provider on an internal address, turn on Allow internal host on the filter.
For a ready-made prompt injection classifier that runs as an HTTP classifier, use the Wolf Defender guardrail.
Built-in Pattern Library
The built-in pattern library runs in the AI Studio process. It does not need an external service. It uses checks in addition to regular expressions, to reduce false positives:- Payment card numbers must pass the Luhn check.
- IBANs must pass the mod-97 check.
- US Social Security numbers must be in an issued range.
- UK National Insurance numbers must use a valid prefix.
- NHS numbers must have a correct check digit.
- Generic secrets must have the entropy of a secret.
injection.exfil_instruction matches an order to send the conversation, the system prompt, or all secrets to an http or https URL. injection.instruction_override also matches “forget everything above” or “disregard the above” when an order to disclose data follows.
The
injection category is a set of heuristics, not a classifier. It finds well-known phrases and encoding tricks. Use it as a baseline, for example in an air-gapped deployment. For real prompt-injection detection, add a classifier provider, such as Lakera Guard, Azure AI Content Safety, or Amazon Bedrock Guardrails.
For this reason, the library finds fewer paraphrased attacks in tool results. A client can put its own text in a tool result to avoid the stricter patterns. For robust coverage of indirect injection, add a classifier provider with tool-result scanning on.
The
secrets.connection_string and secrets.basic_auth_url patterns ignore a password that is a placeholder or a mask, such as $DB_PASSWORD, <password>, or ****.
The same pattern library is available to filter scripts through the tyk.detect and tyk.redact functions. The script templates Built-in library: block credentials and Built-in library: redact personal data show how to use them. The template Built-in library: scan tool results quarantines tool results. Refer to Script Templates.
HTTP Classifier
Use the HTTP classifier to connect your own classifier or NER service. Examples are a self-hosted Llama Prompt Guard 2 or LLM Guard model. Set these connection fields:- Endpoint URL (required): AI Studio sends a
POSTrequest to this URL. - API key: AI Studio sends it in the
Authorization: Bearerheader. - Auth header: a different header name for the key, for example
X-API-Key. - Reads trusted prompt templates: select it only when your service supports trusted prompt templates.
request or response), the detector names, a redact flag, and the text segments. Each segment has an index, a role, and the text. The request also contains metadata, such as the request ID, the vendor, and the model. It never contains credentials.
Segments from agent traffic have more fields:
- A tool result has the role
tool,kindset totool_result, and thetool_nameandtool_call_id. - A tool call has the role
assistant,kindset totool_call, and the tool name and call ID. Itscontextcontains the user’s goal, and the system prompt when the filter includes it. - A tool definition has the role
system,kindset totool_definition, and the tool name.
flagged:truewhen the service flags the text.findings: a list. Each finding has a detector name, a category, a score, a segment index, and an optional span. The span is the UTF-8 byte range of the finding in the segment text. The second opinion uses the span to show the judge the text around the finding.rewritten(optional): the rewritten text of each segment, when AI Studio asks for redaction.
Unix Socket Endpoint
A classifier on the same host as the gateway can listen on a Unix domain socket. It then needs no network access. Set the endpoint tounix:///run/guard/guard.sock. Set the connection field path to the HTTP path, if it is not /.
AI Studio refuses a socket that GUARDRAIL_UNIX_SOCKET_ALLOWLIST does not list:
- The list is empty by default. Add the exact socket paths, or directories that end in
/. - AI Studio checks the list when you save the filter, and again before each call.
- Each Edge Gateway needs the socket mounted and its own allowlist.
- The AI Studio and Edge Gateway images run as UID 65532. The classifier must create the socket so that this user can connect to it.
Microsoft Presidio
Detectors are Presidio entity types. The threshold is the recognizer score from 0 to 1. The default is 0.5. Connection fields:- Analyzer URL (required): the base URL of
presidio-analyzer. - Anonymizer URL: the base URL of
presidio-anonymizer. If you do not set it, AI Studio redacts the text from the analyzer spans. - Language: the ISO 639-1 language code. The default is
en.
PHONE_NUMBER recognizer finds North American numbers best. It can miss international formats, such as +44 7700 900123. If you must detect international numbers, add a custom recognizer in Presidio, or add a built-in pattern library guardrail with pii.phone_international.
Lakera Guard
This provider uses Lakera Guard v2. The detectors areprompt_attack, pii, moderated_content, unknown_links, and custom. To select one subtype only, type its name in Add detector, for example pii/email. The policy of your Lakera project decides which detectors run.
Connection fields:
- API key: the Lakera Guard API key. A self-hosted Guard does not need it.
- Endpoint: the default is
https://api.lakera.ai/v2/guard. Use it to set the EU or Asia host, or a self-hosted Guard. - Project ID: the Lakera project whose policy applies.

budget.max_pieces limits the calls for one request.
Azure AI Content Safety
The detectors areprompt_attack (Prompt Shields) and the moderation categories Hate, Sexual, SelfHarm, and Violence. Each moderation category has a severity threshold from 0 to 6, with a default of 4. AI Studio flags the text when the severity is at or above the threshold.
AI Studio splits text that is longer than 10,000 characters.
Connection fields are Endpoint (required), Subscription key (required), and Blocklists. Blocklists is a comma-separated list of blocklist names. This provider cannot redact, so use Block or Log only.
Prompt Shields gets user text as the user prompt, to find direct attacks. It gets a tool result, a tool call, or a tool definition as a document, to find indirect attacks.
Azure AI Language PII
The detectors are Azure PII categories, such asPerson, PhoneNumber, Email, and CreditCardNumber, or all. The threshold is the confidence from 0 to 1. The default is 0.5.
Connection fields are Endpoint (required), Subscription key (required), Language (default en), and Domain. Set Domain to phi to detect protected health information.
Amazon Bedrock Guardrails
This provider calls the BedrockApplyGuardrail operation for a guardrail that you define in Amazon Bedrock. It works with all LLMs, not only with models that Bedrock hosts. The detectors select which assessments count:
content: content filters, including prompt attackstopic: denied topicsword: word filterssensitive_information: PII entities and custom regular expressions. This detector supports redaction.grounding: contextual grounding
DRAFT), AWS region, Access key ID, and Secret access key. You must set the first three. If you do not set the access keys, the gateway uses its own AWS credentials from the environment.
AI Studio makes one ApplyGuardrail call for each message and each tool result. Bedrock assesses a tool result as input text. As with Lakera Guard, the cost goes up with the number of messages that the cache cannot answer.
Alerts
Available from Tyk AI Studio 2.3.0. Webhooks are an Enterprise feature. The Log and raise event action (alert) lets the traffic through, the same as Log only. It also raises an event on the topic guardrail.alert.<name>. A webhook can subscribe to this topic. You can set this action on the filter, on tool results, tool calls, and tool definitions, and on an exception.
- The event name has 2 to 64 characters: lowercase letters, digits,
-, or_. It starts with a letter or a digit. It must be unique across all guardrail filters and exceptions. - The form shows the topic and a Create a webhook for this event link.
- The alert contains no flagged text by default.
- AI Studio raises the alert after it stores the compliance event.
Outcome Events
Available from Tyk AI Studio 2.3.0. AI Studio raises an outcome event each time a guardrail changes traffic. You do not configure these events:
Webhooks and AI Studio plugins can subscribe to these topics. To get all three, use
guardrail.outcome.*. The event contains the filter, the App, the detector, the action, and the reason code, but never the flagged text. A shadow filter raises no outcome events.
Evidence
Available from Tyk AI Studio 2.3.0.Compliance Events and Metrics
Each match records one compliance event for each detector. The event type isguardrail. and the detector name, for example guardrail.pii.email, guardrail.secrets.aws_access_key, or guardrail.prompt_attack. The event never contains the matched text, unless the filter adds an excerpt. For the event fields, refer to Compliance Events.
AI Studio also records these event types:
A block increments
aistudio_policy_blocks_total, the same as a block from a script filter. Guardrails also export these metrics:
segment_kind is text, tool_result, tool_call, tool_definition, or mixed.
Environment Variables
These environment variables apply on AI Studio and on Edge Gateways:
For the Edge Gateway, refer to GUARDRAIL_* and NATIVE_API_* in the Edge Gateway environment variables.