POST
/
v1
/
rai
/
policies
curl --request POST \
  --url https://rai-prod.studio.lyzr.ai/v1/rai/policies \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "name": "<string>",
  "description": "<string>",
  "allowed_topics": {
    "enabled": true,
    "topics": [
      "<string>"
    ]
  },
  "banned_topics": {
    "enabled": true,
    "topics": [
      "<string>"
    ]
  },
  "keywords": {
    "enabled": true,
    "keywords": [
      "<string>"
    ]
  },
  "toxicity_check": {
    "enabled": true,
    "threshold": 123
  },
  "prompt_injection": {
    "enabled": true,
    "threshold": 123
  },
  "secrets_detection": {
    "enabled": true,
    "action": "<string>"
  },
  "pii_detection": {
    "enabled": true,
    "types": {},
    "custom_pii": [
      {
        "label": "<string>",
        "replacement": "<string>",
        "action": "<string>"
      }
    ]
  },
  "user_id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z"
}'
{
  "_id": "<string>",
  "name": "<string>",
  "description": "<string>",
  "allowed_topics": {
    "enabled": true,
    "topics": [
      "<string>"
    ]
  },
  "banned_topics": {
    "enabled": true,
    "topics": [
      "<string>"
    ]
  },
  "keywords": {
    "enabled": true,
    "keywords": [
      "<string>"
    ]
  },
  "toxicity_check": {
    "enabled": true,
    "threshold": 123
  },
  "prompt_injection": {
    "enabled": true,
    "threshold": 123
  },
  "secrets_detection": {
    "enabled": true,
    "action": "<string>"
  },
  "pii_detection": {
    "enabled": true,
    "types": {},
    "custom_pii": [
      {
        "label": "<string>",
        "replacement": "<string>",
        "action": "<string>"
      }
    ]
  },
  "user_id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z"
}

POST /v1/rai/policies
Create a new Responsible AI (RAI) policy.

Description

This endpoint allows creating a new RAI policy including configuration for topics, keywords, toxicity checks, prompt injection protection, and PII/secrets detection.

Request

Headers

  • x-api-key: API key for authentication (required)
  • Content-Type: application/json

Request Body

{
  "name": "string",
  "description": "string",
  "allowed_topics": {
    "enabled": false,
    "topics": []
  },
  "banned_topics": {
    "enabled": false,
    "topics": []
  },
  "keywords": {
    "enabled": false,
    "keywords": []
  },
  "toxicity_check": {
    "enabled": true,
    "threshold": 1
  },
  "prompt_injection": {
    "enabled": true,
    "threshold": 1
  },
  "secrets_detection": {
    "enabled": true,
    "action": "mask"
  },
  "pii_detection": {
    "enabled": true,
    "types": {},
    "custom_pii": [
      {
        "label": "string",
        "replacement": "string",
        "action": "redact"
      }
    ]
  },
  "user_id": "string",
  "created_at": "2025-05-16T10:55:33.101Z",
  "updated_at": "2025-05-16T10:55:33.101Z"
}

Response

200 OK

{
  "_id": "string",
  "name": "string",
  "description": "string",
  "allowed_topics": {
    "enabled": false,
    "topics": []
  },
  "banned_topics": {
    "enabled": false,
    "topics": []
  },
  "keywords": {
    "enabled": false,
    "keywords": []
  },
  "toxicity_check": {
    "enabled": true,
    "threshold": 1
  },
  "prompt_injection": {
    "enabled": true,
    "threshold": 1
  },
  "secrets_detection": {
    "enabled": true,
    "action": "mask"
  },
  "pii_detection": {
    "enabled": true,
    "types": {},
    "custom_pii": [
      {
        "label": "string",
        "replacement": "string",
        "action": "redact"
      }
    ]
  },
  "user_id": "string",
  "created_at": "2025-05-16T10:55:33.116Z",
  "updated_at": "2025-05-16T10:55:33.116Z"
}

422 Unprocessable Entity

{
  "detail": [
    {
      "loc": ["string", 0],
      "msg": "string",
      "type": "string"
    }
  ]
}

Curl Example

curl -X 'POST'   'https://rai-prod.studio.lyzr.ai/v1/rai/policies'   -H 'accept: application/json'   -H 'x-api-key: sk-default-Bk19s6ZUGIBoBkJNdkJ8YfcPLwULRXcH'   -H 'Content-Type: application/json'   -d '{...}'

Authorizations

x-api-key
string
header
required

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.