Skip to main content
POST
/
v1
/
rai
/
policies
Create Policy
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"
}
'
import requests

url = "https://rai-prod.studio.lyzr.ai/v1/rai/policies"

payload = {
"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"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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'
})
};

fetch('https://rai-prod.studio.lyzr.ai/v1/rai/policies', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://rai-prod.studio.lyzr.ai/v1/rai/policies",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://rai-prod.studio.lyzr.ai/v1/rai/policies"

payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"allowed_topics\": {\n \"enabled\": true,\n \"topics\": [\n \"<string>\"\n ]\n },\n \"banned_topics\": {\n \"enabled\": true,\n \"topics\": [\n \"<string>\"\n ]\n },\n \"keywords\": {\n \"enabled\": true,\n \"keywords\": [\n \"<string>\"\n ]\n },\n \"toxicity_check\": {\n \"enabled\": true,\n \"threshold\": 123\n },\n \"prompt_injection\": {\n \"enabled\": true,\n \"threshold\": 123\n },\n \"secrets_detection\": {\n \"enabled\": true,\n \"action\": \"<string>\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"types\": {},\n \"custom_pii\": [\n {\n \"label\": \"<string>\",\n \"replacement\": \"<string>\",\n \"action\": \"<string>\"\n }\n ]\n },\n \"user_id\": \"<string>\",\n \"created_at\": \"2023-11-07T05:31:56Z\",\n \"updated_at\": \"2023-11-07T05:31:56Z\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://rai-prod.studio.lyzr.ai/v1/rai/policies")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"allowed_topics\": {\n \"enabled\": true,\n \"topics\": [\n \"<string>\"\n ]\n },\n \"banned_topics\": {\n \"enabled\": true,\n \"topics\": [\n \"<string>\"\n ]\n },\n \"keywords\": {\n \"enabled\": true,\n \"keywords\": [\n \"<string>\"\n ]\n },\n \"toxicity_check\": {\n \"enabled\": true,\n \"threshold\": 123\n },\n \"prompt_injection\": {\n \"enabled\": true,\n \"threshold\": 123\n },\n \"secrets_detection\": {\n \"enabled\": true,\n \"action\": \"<string>\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"types\": {},\n \"custom_pii\": [\n {\n \"label\": \"<string>\",\n \"replacement\": \"<string>\",\n \"action\": \"<string>\"\n }\n ]\n },\n \"user_id\": \"<string>\",\n \"created_at\": \"2023-11-07T05:31:56Z\",\n \"updated_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://rai-prod.studio.lyzr.ai/v1/rai/policies")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"allowed_topics\": {\n \"enabled\": true,\n \"topics\": [\n \"<string>\"\n ]\n },\n \"banned_topics\": {\n \"enabled\": true,\n \"topics\": [\n \"<string>\"\n ]\n },\n \"keywords\": {\n \"enabled\": true,\n \"keywords\": [\n \"<string>\"\n ]\n },\n \"toxicity_check\": {\n \"enabled\": true,\n \"threshold\": 123\n },\n \"prompt_injection\": {\n \"enabled\": true,\n \"threshold\": 123\n },\n \"secrets_detection\": {\n \"enabled\": true,\n \"action\": \"<string>\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"types\": {},\n \"custom_pii\": [\n {\n \"label\": \"<string>\",\n \"replacement\": \"<string>\",\n \"action\": \"<string>\"\n }\n ]\n },\n \"user_id\": \"<string>\",\n \"created_at\": \"2023-11-07T05:31:56Z\",\n \"updated_at\": \"2023-11-07T05:31:56Z\"\n}"

response = http.request(request)
puts response.read_body
{
  "_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"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
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
name
string
description
string
allowed_topics
object
banned_topics
object
keywords
object
toxicity_check
object
prompt_injection
object
secrets_detection
object
pii_detection
object
user_id
string
created_at
string<date-time>
updated_at
string<date-time>

Response

Successful Response

_id
string
name
string
description
string
allowed_topics
object
banned_topics
object
keywords
object
toxicity_check
object
prompt_injection
object
secrets_detection
object
pii_detection
object
user_id
string
created_at
string<date-time>
updated_at
string<date-time>