The AI Semantic Prompt Guard Policy enforces prompt governance using semantic similarity matching. It compares incoming requests against your configured allow and deny lists, preventing misuse of text completion requests.
You can use a combination of allow and deny rules to maintain integrity and compliance when serving an LLM service using AI Gateway.
By default, the Policy only evaluates the latest message from the user role. To also match earlier turns in a multi-turn conversation, set config.rules.match_all_conversation_history to true. To also match messages from roles other than user, set config.rules.match_all_roles to true.
The matching behavior is as follows:
If any deny prompts are set and the request matches a prompt in the deny list, the caller receives a 403 response.
If any allow prompts are set, but the request matches none of the allowed prompts, the caller also receives a 403 response.
If any allow prompts are set and the request matches one of the allow prompts, the request passes through to the LLM.
If there are both deny and allow prompts set, the deny condition takes precedence over allow. Any request that matches a prompt in the deny list will return a 403 response, even if it also matches a prompt in the allow list. If the request doesn’t match a prompt in the deny list, then it must match a prompt in the allow list to be passed through to the LLM.
A vector database stores and compares vector embeddings—numerical representations of text, prompts, documents, or other content. When you configure semantic features in AI Models or AI Policies, embeddings are generated and stored in the vector database so that incoming requests can be compared against the stored vectors to find semantically similar matches. For example, an incoming prompt is embedded and compared against cached prompt keys, model descriptions, document chunks, or allow/deny lists to determine semantic similarity.
AI Gateway semantic features support the following vector databases:
Using vectordb.strategy: redis and parameters in vectordb.redis:
Valkey: When you configure vectordb.strategy: redis, Kong Gateway queries the server and checks the server name field. If it detects Valkey request, it automatically uses the Valkey-specific driver.
If your AI Policy uses a Redis datastore, you can authenticate to it with a cloud Redis provider. This allows you to rotate credentials without relying on static passwords.
The following providers are supported:
AWS ElastiCache
Azure Managed Redis
Google Cloud Memorystore (with or without Valkey)
Each provider also supports an instance and cluster configuration.
You need:
A running Redis instance on an AWS ElastiCache instance for Valkey 7.2 or later or ElastiCache for Redis OSS version 7.0 or later
Set config.proxy on this entity to route its outbound requests through an HTTP forward proxy. Use this in network-isolated deployments where AI Gateway cannot open direct connections to LLM providers or auxiliary services.
The proxy record is identical for AI Model, AI MCP Server, and supported AI Policy entities. Existing capabilities such as load balancing, health checking, streaming, WebSocket, and HTTP/2 continue to work when the proxy is active.
For the full field reference, traffic flow, and limitations, see Forward proxy support.
Yes, the AI Semantic Prompt Guard Policy supports multilingual input. Support depends on the capabilities of the configured embedding model. The AI Policy sends raw UTF-8 text to an embedding provider supported by AI Gateway (such as Azure, Bedrock, Gemini, Hugging Face, Mistral, or OpenAI). As long as the embedding model supports multiple languages, semantic comparisons and rule enforcement will work as expected without requiring additional policy configuration.
failed to create memorydb instance failed to create index: LIMIT Number of indexes (11) exceeds the limit (10)
Copied!
This means that the hardcoded MemoryDB instance limit has been reached.
To resolve this, create more MemoryDB instances to handle multiple AI Semantic Prompt Guard policy instances.