Scan text for prompt injection
curl --request POST \
--url https://api.example.com/v1/prompt-injection/text \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": "<string>",
"only": [
"<string>"
],
"exclude": [
"<string>"
]
}
'import requests
url = "https://api.example.com/v1/prompt-injection/text"
payload = {
"content": "<string>",
"only": ["<string>"],
"exclude": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({content: '<string>', only: ['<string>'], exclude: ['<string>']})
};
fetch('https://api.example.com/v1/prompt-injection/text', 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.example.com/v1/prompt-injection/text",
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([
'content' => '<string>',
'only' => [
'<string>'
],
'exclude' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.example.com/v1/prompt-injection/text"
payload := strings.NewReader("{\n \"content\": \"<string>\",\n \"only\": [\n \"<string>\"\n ],\n \"exclude\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.example.com/v1/prompt-injection/text")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"<string>\",\n \"only\": [\n \"<string>\"\n ],\n \"exclude\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/prompt-injection/text")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"<string>\",\n \"only\": [\n \"<string>\"\n ],\n \"exclude\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"is_safe": true,
"categories": [
{}
],
"request_id": "<string>",
"api_key_id": "<string>",
"request_units": 123,
"billed_request_units": 123,
"reason": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}API Reference
Scan Text for Prompt Injection
POST
/
v1
/
prompt-injection
/
text
Scan text for prompt injection
curl --request POST \
--url https://api.example.com/v1/prompt-injection/text \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": "<string>",
"only": [
"<string>"
],
"exclude": [
"<string>"
]
}
'import requests
url = "https://api.example.com/v1/prompt-injection/text"
payload = {
"content": "<string>",
"only": ["<string>"],
"exclude": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({content: '<string>', only: ['<string>'], exclude: ['<string>']})
};
fetch('https://api.example.com/v1/prompt-injection/text', 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.example.com/v1/prompt-injection/text",
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([
'content' => '<string>',
'only' => [
'<string>'
],
'exclude' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.example.com/v1/prompt-injection/text"
payload := strings.NewReader("{\n \"content\": \"<string>\",\n \"only\": [\n \"<string>\"\n ],\n \"exclude\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.example.com/v1/prompt-injection/text")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"<string>\",\n \"only\": [\n \"<string>\"\n ],\n \"exclude\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/prompt-injection/text")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"<string>\",\n \"only\": [\n \"<string>\"\n ],\n \"exclude\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"is_safe": true,
"categories": [
{}
],
"request_id": "<string>",
"api_key_id": "<string>",
"request_units": 123,
"billed_request_units": 123,
"reason": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Learn more about the risk categories returned by this endpoint in Risk Classifications.
Basic Usage
import { CentureClient } from "@centure/node-sdk";
const client = new CentureClient();
const result = await client.scanText("External data to scan...");
if (!result.is_safe) {
console.log("Detected categories:", result.categories);
}
curl -X POST https://api.centure.ai/v1/prompt-injection/text \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "External data to scan..."
}'
Filtering Categories
You can filter which risk categories to detect using theonly or exclude parameters. These parameters are mutually exclusive.
const result = await client.scanText("External data to scan...", {
only: ["data_exfiltration", "unauthorized_actions"]
});
const result = await client.scanText("External data to scan...", {
exclude: ["behavioral_override_low"]
});
Confidence Filtering
Useminimum_confidence to filter results by confidence level:
const result = await client.scanText("External data to scan...", {
minimum_confidence: "high"
});
Set
minimum_confidence to "high" to reduce false positives by only returning high-confidence detections.Response
When content is flagged as unsafe, the response includes areason field explaining why:
{
"is_safe": false,
"categories": [
{ "code": "data_exfiltration", "confidence": "high" }
],
"reason": "The input attempts to extract system prompt information by asking the model to reveal its instructions.",
"request_id": "req_abc123",
"api_key_id": "key_xyz789",
"request_units": 1,
"billed_request_units": 1,
"service_tier": "standard"
}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Text to scan
Only detect these categories (mutually exclusive with 'exclude')
Exclude these categories from detection (mutually exclusive with 'only')
Minimum confidence level to include in results. Default: 'medium' (include all)
Available options:
medium, high Was this page helpful?
⌘I

