create_ai_guard_rail

ArtificialIntelligenceApi.create_ai_guard_rail(role_id, guard_rail_create_request, content_type=None, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)

Create an AI guard rail

Creates a Bedrock guard rail and Amorphic metadata. Requires GuardRailName and Description. Maximum 100 guard rails. The creator receives owner access.

Parameters:
  • role_id (str) – Role identifier used for authorization. Missing this header returns AUTH-1001. Create also requires ai.fullaccess. (required)

  • guard_rail_create_request (GuardRailCreateRequest) – Configuration for the new guard rail. (required)

  • content_type (str)

  • _request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

  • _request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.

  • _content_type (str, Optional) – force content-type for the request.

  • _headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.

  • _host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.

Return type:

GuardRailCreateResponse

Returns:

Returns the result object.

Request and Response Examples

HTTP: POST /ai/guard-rails

Request

Configuration for the new guard rail.

Request / response example

{
  "GuardRailName": "example-guardrail",
  "Description": "Example guardrail for content filtering and safety",
  "IsCrossRegionEnabled": true,
  "Tier": "STANDARD",
  "Scope": "global",
  "BlockedMessage": "This content has been blocked by the guardrail",
  "GroundingThreshold": 0.8,
  "RelevanceThreshold": 0.7,
  "EnableContextualGroundingCheck": true,
  "SensitiveInformationFilters": {
    "PiiTypesToFilter": [
      {
        "Type": "EMAIL",
        "Action": "BLOCK"
      },
      {
        "Type": "PHONE",
        "Action": "ANONYMIZE"
      }
    ],
    "CustomRegexFilters": [
      {
        "RegexName": "CreditCardPattern",
        "Pattern": "\\d{4}-\\d{4}-\\d{4}-\\d{4}",
        "Action": "BLOCK"
      }
    ]
  },
  "CustomWordFilters": {
    "BlockWords": [
      "inappropriate",
      "spam"
    ],
    "EnableProfanityFilter": true
  },
  "FiltersConfig": [
    {
      "Type": "HATE",
      "InputStrength": "MEDIUM",
      "OutputStrength": "HIGH"
    }
  ],
  "DeniedTopics": [
    {
      "TopicName": "Violence",
      "TopicDefinition": "Content related to violence or harmful activities",
      "ExamplePhrases": [
        "how to hurt someone",
        "violent actions"
      ]
    }
  ]
}

Success (HTTP 200)

Guard rail created. Message is Guard rail created successfully.

Request / response example

{
  "Message": "Guard rail created successfully.",
  "GuardRailId": "3k2h1example",
  "GuardRailName": "example-guardrail"
}

Errors

Documented error codes: IPV-1004, IPV-1018, IPV-1001, AI-1004.

HTTP 400

Invalid name (IPV-1004), duplicate name (IPV-1018), missing required fields (IPV-1001), max 100 guard rails reached, invalid component/policy, or AICore not enabled (AI-1004).

GuardRailName fails the 3-50 character pattern

{
  "Message": "IPV-1004 - GuardRailName must be 3-50 alphanumeric, hyphen and underscore characters only."
}

GuardRailName already exists

{
  "Message": "IPV-1018 - Invalid parameter - GuardRail Name, parameter value already exists, use different value."
}

AICore is not enabled

{
  "Message": "AI-1004 - AI services for feature: Guard Rails - AICore are not currently enabled in the application. Please contact the administrator to enable it."
}

HTTP 500

Internal server error during guard rail creation.