> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enkryptai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate a guardrail and policy for risk mitigation based on summary

> Analyzes red teaming test results and produces a system prompt with safety and compliance guidelines tailored to the risks identified.



## OpenAPI

````yaml POST /redteam/risk-mitigation/guardrails-policy
openapi: 3.0.0
info:
  title: Enkrypt AI APIs
  version: 2.0.0
servers:
  - url: https://api.enkryptai.com
security:
  - apiKeyAuth: []
tags:
  - name: Guardrails
  - name: Code of Conduct
  - name: Endpoints
  - name: Datasets
  - name: Redteam
  - name: Deployments
  - name: AI Proxy
  - name: Leaderboard
  - name: Archived
  - name: MCP Hub
    description: >-
      MCP Hub vulnerability scanning APIs. Submitting scans (the POST endpoints)
      is open to all authenticated callers. The scan **retrieval** APIs — Get
      Scan Job Status, Get Complete Scan Results, List Scans, and Get MCP Hub
      Scan Statistics (the GET endpoints) — are an **enterprise data-license
      feature**: they require your organization to have MCP Hub API access
      enabled by Enkrypt, otherwise they return `403`. Contact us at
      support@enkryptai.com to enable access.
  - name: MCP Registry Servers
  - name: MCP Gateways
  - name: MCP Playground
paths:
  /redteam/risk-mitigation/guardrails-policy:
    post:
      tags:
        - Redteam
      summary: Generate a guardrail and policy for risk mitigation based on summary
      description: >-
        Analyzes red teaming test results and produces a system prompt with
        safety and compliance guidelines tailored to the risks identified.
      operationId: riskMitigationGuardrailsPolicy
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                redteam_summary:
                  $ref: '#/components/schemas/RedteamResultsSummaryResponseFinal'
              required:
                - redteam_summary
      responses:
        '200':
          description: Generated guardrails policy and system prompt.
          content:
            application/json:
              schema:
                type: object
                properties:
                  analysis:
                    type: string
                  guardrails_policy:
                    $ref: '#/components/schemas/GuardrailsDetectorsObject'
                  message:
                    type: string
              examples:
                success:
                  value:
                    analysis: >-
                      The red teaming test results indicate several major
                      categories where the LLM is vulnerable. The highest
                      vulnerability is in the 'cbrn_test' category, which
                      includes Chemistry (98%), Nuclear Science (94%), Biology
                      (92%), and Radiology (84%). These high percentages suggest
                      that the LLM is particularly susceptible to generating or
                      being manipulated into generating content related to
                      chemical, biological, radiological, and nuclear
                      information, which could be potentially dangerous if
                      misused. In the 'harmful_test' category, vulnerabilities
                      are noted in 'Guns & Illegal Substances' (87%) and
                      'Unethical Crimes' (83%). These results indicate a
                      significant risk of the LLM being used to generate or
                      facilitate content related to illegal activities and
                      unethical behavior.
                    guardrails_policy:
                      policy_violation:
                        enabled: true
                        policy_text: >-
                          1. The prompt should not contain any references to
                          chemical, biological, radiological, or nuclear
                          materials or processes unless explicitly verified as
                          safe and educational by a trusted source.


                          2. The assistant should not generate any content that
                          provides instructions, guidance, or detailed
                          information on the synthesis, handling, or use of
                          chemical, biological, radiological, or nuclear
                          materials.


                          3. The prompt should not include any language that
                          could be interpreted as seeking information on the
                          creation, acquisition, or use of firearms or illegal
                          substances.


                          4. The assistant should not generate any content that
                          could be used to facilitate or promote the use,
                          distribution, or manufacturing of firearms or illegal
                          substances.


                          5. The prompt should not contain any language that
                          could be interpreted as seeking information on
                          committing unethical or illegal activities.


                          6. The assistant should not generate any content that
                          could be used to facilitate or promote unethical or
                          illegal activities, including but not limited to
                          crimes, fraud, or any form of harm to individuals or
                          groups.


                          7. The assistant should not generate any content that
                          could be used to bypass or undermine security measures
                          or legal restrictions.


                          8. The prompt should not contain any harmful words or
                          phrases that could incite violence, discrimination, or
                          hatred against individuals or groups.


                          9. The assistant should not generate any content that
                          could be interpreted as endorsing or supporting
                          violence, discrimination, or hatred against
                          individuals or groups.


                          10. The assistant should not generate any content that
                          could be used to exploit or manipulate individuals or
                          groups for malicious purposes.
                    message: Guardrails configuration has been generated successfully
components:
  schemas:
    RedteamResultsSummaryResponseFinal:
      title: RedteamResultsSummaryResponseFinal
      type: object
      properties:
        summary:
          title: RedteamResultsSummaryResponseSummary
          type: object
          properties:
            project_name:
              title: Project Name
              type: string
              example: default
            test_date:
              title: Test Date
              type: string
              format: date-time
            test_name:
              title: Test Name
              type: string
            dataset_name:
              title: Dataset Name
              type: string
            model_name:
              title: Model Name
              type: string
            model_endpoint_url:
              title: Model Endpoint Url
              type: string
              format: uri
            model_source:
              title: Model Source
              type: string
              format: uri
            model_provider:
              title: Model Provider
              type: string
            risk_score:
              title: Risk Score
              type: number
            test_type:
              title: Test Type
              type: array
              items:
                title: Test Type
                type: object
                additionalProperties:
                  title: Test Type
                  type: object
                  properties:
                    success(%):
                      title: Success Percentage
                      type: number
                    total:
                      title: Total
                      type: integer
            nist_category:
              title: NIST Category
              type: array
              items:
                title: NIST Category
                type: object
                additionalProperties:
                  title: NIST Category
                  type: object
                  properties:
                    success(%):
                      title: Success Percentage
                      type: number
                    total:
                      title: Total
                      type: integer
            scenario:
              title: Scenario
              type: array
              items:
                title: Scenario
                type: object
            category:
              title: Category
              type: array
              items:
                title: Category
                type: object
                additionalProperties:
                  title: Category
                  type: object
                  properties:
                    success(%):
                      title: Success Percentage
                      type: number
                    total:
                      title: Total
                      type: integer
                    test_type:
                      title: Test Type
                      type: string
            attack_method:
              title: Attack Method
              type: array
              items:
                type: object
                additionalProperties:
                  title: Attack Method
                  type: object
                  properties:
                    success(%):
                      title: Success Percentage
                      type: number
                    total:
                      title: Total
                      type: integer
      example:
        summary:
          test_date: '2024-12-04T10:15:16.756234+00:00'
          test_name: Test 2
          dataset_name: standard
          model_name: mistralai/Mistral-7B-Instruct-v0.1
          model_endpoint_url: https://api.together.xyz/v1/chat/completions
          model_source: https://platform.openai.com/docs/models
          model_provider: openai
          risk_score: 19.35483870967742
          test_type:
            - bias_test:
                success(%): 75
                total: 8
            - cbrn_test:
                success(%): 0
                total: 3
            - harmful_test:
                success(%): 0
                total: 1
            - insecure_code_test:
                success(%): 0
                total: 8
            - toxicity_test:
                success(%): 0
                total: 11
          nist_category:
            - CBRN Information or Capabilities:
                success(%): 0
                total: 3
            - Dangerous, Violent, or Hateful Content:
                success(%): 0
                total: 1
            - Harmful Bias or Homogenization:
                success(%): 75
                total: 8
            - Information Security:
                success(%): 0
                total: 8
            - Obscene, Degrading, and/or Abusive Content:
                success(%): 0
                total: 11
          scenario: []
          category:
            - Caste and Religion:
                success(%): 95.31
                total: 64
                test_type: bias_test
            - Criminal Planning:
                success(%): 26.67
                total: 30
                test_type: harmful_test
            - EICAR:
                success(%): 20
                total: 5
                test_type: insecure_code_test
            - Evasion:
                success(%): 2.38
                total: 42
                test_type: insecure_code_test
            - Flirtation:
                success(%): 1
                total: 200
                test_type: toxicity_test
            - GTUBE:
                success(%): 0
                total: 5
                test_type: insecure_code_test
            - GTphish:
                success(%): 0
                total: 5
                test_type: insecure_code_test
            - Gender:
                success(%): 54.32
                total: 81
                test_type: bias_test
            - Guns & Illegal Weapons:
                success(%): 16.67
                total: 30
                test_type: harmful_test
            - Hate Speech & Discrimination:
                success(%): 3.33
                total: 30
                test_type: harmful_test
            - Health:
                success(%): 91.67
                total: 72
                test_type: bias_test
            - Identity Attack:
                success(%): 1.5
                total: 400
                test_type: toxicity_test
            - Insult:
                success(%): 1.5
                total: 200
                test_type: toxicity_test
            - Payload:
                success(%): 0.95
                total: 105
                test_type: insecure_code_test
            - Profanity:
                success(%): 7.5
                total: 400
                test_type: toxicity_test
            - Race:
                success(%): 86.89
                total: 122
                test_type: bias_test
            - Regulated or Controlled Substances:
                success(%): 23.33
                total: 30
                test_type: harmful_test
            - Religion:
                success(%): 81.25
                total: 48
                test_type: bias_test
            - Severe Toxicity:
                success(%): 3
                total: 400
                test_type: toxicity_test
            - Sexual Content:
                success(%): 13.33
                total: 30
                test_type: harmful_test
            - Sexually Explicit:
                success(%): 1.25
                total: 400
                test_type: toxicity_test
            - SubFunctions:
                success(%): 4.08
                total: 49
                test_type: insecure_code_test
            - Suicide & Self-harm:
                success(%): 3.33
                total: 30
                test_type: harmful_test
            - Threat:
                success(%): 1
                total: 200
                test_type: toxicity_test
            - TopLevel:
                success(%): 0
                total: 14
                test_type: insecure_code_test
            - biology:
                success(%): 2.5
                total: 200
                test_type: cbrn_test
            - chemistry:
                success(%): 20
                total: 200
                test_type: cbrn_test
            - cybersecurity:
                success(%): 8.5
                total: 200
                test_type: cbrn_test
          attack_method:
            - Basic:
                success(%): 18.77
                total: 2072
            - Iterative:
                success(%): 23.33
                total: 60
            - Single Shot:
                success(%): 4.52
                total: 1460
    GuardrailsDetectorsObject:
      title: GuardrailsDetectorsObject
      type: object
      properties:
        topic_detector:
          type: object
          title: TopicDetector
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              title: Enabled
            topic:
              type: array
              title: Topic
              items:
                type: string
            block_message:
              type: string
              title: Block Message
              description: >-
                Optional custom message returned when this detector triggers a
                block. If not provided, a built-in default message is used.
        nsfw:
          type: object
          title: NSFWDetector
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              title: Enabled
            block_message:
              type: string
              title: Block Message
              description: >-
                Optional custom message returned when this detector triggers a
                block. If not provided, a built-in default message is used.
        toxicity:
          type: object
          title: ToxicityDetector
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              title: Enabled
            block_message:
              type: string
              title: Block Message
              description: >-
                Optional custom message returned when this detector triggers a
                block. If not provided, a built-in default message is used.
        pii:
          type: object
          title: PIIDetector
          required:
            - enabled
            - entities
          properties:
            enabled:
              type: boolean
              title: Enabled
            entities:
              type: array
              title: Entities
              items:
                type: string
                enum:
                  - pii
                  - secrets
                  - ip_address
                  - url
        injection_attack:
          type: object
          title: InjectionAttackDetector
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              title: Enabled
            block_message:
              type: string
              title: Block Message
              description: >-
                Optional custom message returned when this detector triggers a
                block. If not provided, a built-in default message is used.
        keyword_detector:
          type: object
          title: KeywordDetector
          required:
            - enabled
            - banned_keywords
          properties:
            enabled:
              type: boolean
              title: Enabled
            banned_keywords:
              type: array
              title: Banned Keywords
              items:
                type: string
        system_prompt:
          type: object
          title: SystemPromptDetector
          required:
            - enabled
            - index
          properties:
            enabled:
              type: boolean
              title: Enabled
              example: false
            index:
              type: string
              title: Index
              enum:
                - system
              description: Index
              example: system
            block_message:
              type: string
              title: Block Message
              description: >-
                Optional custom message returned when this detector triggers a
                block. If not provided, a built-in default message is used.
        copyright_ip:
          type: object
          title: CopyrightIPDetector
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              title: Enabled
              example: false
            block_message:
              type: string
              title: Block Message
              description: >-
                Optional custom message returned when this detector triggers a
                block. If not provided, a built-in default message is used.
        policy_violation:
          type: object
          title: PolicyAdherenceDetector
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              title: Enabled
            policy_text:
              type: string
              title: Policy Text
              description: Optional policy text to use if not using coc_policy_name
            coc_policy_name:
              type: string
              title: COC Policy Name
              description: >-
                The name of the saved COC policy to use instead of using
                policy_text
            need_explanation:
              type: boolean
              title: Need Explanation
            block_message:
              type: string
              title: Block Message
              description: >-
                Optional custom message returned when this detector triggers a
                block. If not provided, a built-in default message is used.
        bias:
          type: object
          title: BiasDetector
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              title: Enabled
        sponge_attack:
          type: object
          title: SpongeAttackDetector
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              title: Enabled
              example: false
            block_message:
              type: string
              title: Block Message
              description: >-
                Optional custom message returned when this detector triggers a
                block. If not provided, a built-in default message is used.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: apikey

````