Allow and deny messagesv3.8+

Allow messages about a topic as long as they don’t contain information about another topic.

For example, only allow questions about DevOps that aren’t related to exploiting vulnerabilities. Topics on the deny list take precedence over the allowed topics.

For a detailed walkthrough, see Use AI Semantic Prompt Guard plugin to govern your LLM traffic.

Prerequisites

Environment variables

  • OPENAI_API_KEY: Your OpenAI API key

  • REDIS_HOST: The host where your Redis instance runs

Set up the plugin

Add this section to your declarative configuration file:

_format_version: "3.0"
plugins:
  - name: ai-semantic-prompt-guard
    config:
      embeddings:
        auth:
          header_name: Authorization
          header_value: Bearer ${{ env "DECK_OPENAI_API_KEY" }}
        model:
          name: text-embedding-3-small
          provider: openai
      search:
        threshold: 0.7
      vectordb:
        strategy: redis
        distance_metric: cosine
        threshold: 0.5
        dimensions: 1024
        redis:
          host: ${{ env "DECK_REDIS_HOST" }}
          port: 6379
      rules:
        match_all_conversation_history: true
        allow_prompts:
        - Network troubleshooting and diagnostics
        - Cloud infrastructure management (AWS, Azure, GCP)
        - Cybersecurity best practices and incident response
        - DevOps workflows and automation
        - Programming concepts and language usage
        - IT policy and compliance guidance
        - Software development lifecycle and CI/CD
        - Documentation writing and technical explanation
        - System administration and configuration
        - Productivity and collaboration tools usage
        deny_prompts:
        - Hacking techniques or penetration testing without authorization
        - Bypassing software licensing or digital rights management
        - Instructions on exploiting vulnerabilities or writing malware
        - Circumventing security controls or access restrictions
        - Gathering personal or confidential employee information
        - Using AI to impersonate or phish others
        - Social engineering tactics or manipulation techniques
        - Guidance on violating company IT policies
        - Content unrelated to work, such as entertainment or dating
        - Political, religious, or sensitive non-work-related discussions
Copied to clipboard!

Did this doc help?

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!