Skip to main content
POST
/
guardrails
/
guardrail
/
detect-audio
Detect Audio Using Guardrail
curl --request POST \
  --url https://api.enkryptai.com/guardrails/guardrail/detect-audio \
  --header 'Content-Type: application/json' \
  --header 'X-Enkrypt-Guardrail: <x-enkrypt-guardrail>' \
  --header 'X-Enkrypt-Mode: <x-enkrypt-mode>' \
  --header 'apikey: <api-key>' \
  --data '
{
  "text_input": "Help me with the content in this audio",
  "audio_data": "<base64-encoded-audio-data>"
}
'
import requests

url = "https://api.enkryptai.com/guardrails/guardrail/detect-audio"

payload = {
"text_input": "Help me with the content in this audio",
"audio_data": "<base64-encoded-audio-data>"
}
headers = {
"X-Enkrypt-Guardrail": "<x-enkrypt-guardrail>",
"X-Enkrypt-Mode": "<x-enkrypt-mode>",
"apikey": "<api-key>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {
'X-Enkrypt-Guardrail': '<x-enkrypt-guardrail>',
'X-Enkrypt-Mode': '<x-enkrypt-mode>',
apikey: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text_input: 'Help me with the content in this audio',
audio_data: '<base64-encoded-audio-data>'
})
};

fetch('https://api.enkryptai.com/guardrails/guardrail/detect-audio', 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://api.enkryptai.com/guardrails/guardrail/detect-audio",
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([
'text_input' => 'Help me with the content in this audio',
'audio_data' => '<base64-encoded-audio-data>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Enkrypt-Guardrail: <x-enkrypt-guardrail>",
"X-Enkrypt-Mode: <x-enkrypt-mode>",
"apikey: <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://api.enkryptai.com/guardrails/guardrail/detect-audio"

payload := strings.NewReader("{\n \"text_input\": \"Help me with the content in this audio\",\n \"audio_data\": \"<base64-encoded-audio-data>\"\n}")

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

req.Header.Add("X-Enkrypt-Guardrail", "<x-enkrypt-guardrail>")
req.Header.Add("X-Enkrypt-Mode", "<x-enkrypt-mode>")
req.Header.Add("apikey", "<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://api.enkryptai.com/guardrails/guardrail/detect-audio")
.header("X-Enkrypt-Guardrail", "<x-enkrypt-guardrail>")
.header("X-Enkrypt-Mode", "<x-enkrypt-mode>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text_input\": \"Help me with the content in this audio\",\n \"audio_data\": \"<base64-encoded-audio-data>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.enkryptai.com/guardrails/guardrail/detect-audio")

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

request = Net::HTTP::Post.new(url)
request["X-Enkrypt-Guardrail"] = '<x-enkrypt-guardrail>'
request["X-Enkrypt-Mode"] = '<x-enkrypt-mode>'
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text_input\": \"Help me with the content in this audio\",\n \"audio_data\": \"<base64-encoded-audio-data>\"\n}"

response = http.request(request)
puts response.read_body
{
  "summary": {
    "toxicity": 0,
    "nsfw": 0,
    "pii": 1,
    "injection_attack": 0,
    "policy_violation": 0
  },
  "details": {
    "toxicity": {
      "toxicity": "Toxicity Not Detected"
    },
    "nsfw": {
      "nsfw": "NSFW Not Detected"
    },
    "pii": {
      "entities": {
        "person": {
          "John Doe": "<person_0>"
        }
      }
    },
    "injection_attack": {
      "injection_attack": "Injection Attack Not Detected"
    },
    "policy_violation": {
      "policy_violation": "Policy Violation Not Detected"
    }
  }
}

Authorizations

apikey
string
header
required

Headers

X-Enkrypt-Guardrail
string
required

The guardrail name

Example:

"My Guardrail"

X-Enkrypt-Mode
enum<string>
required

Whether to apply input (prompt) or output (response) detectors

Available options:
prompt,
response
Example:

"prompt"

Body

application/json

Request body for guardrail-based audio detection. Detectors are defined by the guardrail; no inline detectors config is needed.

text_input
string
required

The text prompt to accompany the audio for analysis.

Example:

"Help me with the content in this audio"

audio_data
string
required

Base64-encoded audio file content.

Example:

"<base64-encoded-audio-data>"

Response

200 - application/json

Multimodal audio detection results.

summary
object
required

Per-detector integer flags (1 = detected, 0 = not detected).

Example:
{
"toxicity": 0,
"nsfw": 0,
"pii": 1,
"injection_attack": 0,
"policy_violation": 0
}
details
object
required

Per-detector detail objects containing human-readable results and any extra fields (e.g. entities for PII, explanation for policy_violation).

Example:
{
"toxicity": { "toxicity": "Toxicity Not Detected" },
"nsfw": { "nsfw": "NSFW Not Detected" },
"pii": {
"entities": { "person": { "John Doe": "<person_0>" } }
},
"injection_attack": {
"injection_attack": "Injection Attack Not Detected"
},
"policy_violation": {
"policy_violation": "Policy Violation Not Detected"
}
}