import requests
def is_safe(user_message):
r = requests.post(
"https://prompt-firewall-api.onrender.com/analyze",
headers={"X-API-Key": "your-key"},
json={"message": user_message}
)
return r.json()["status"] == "PASSED"
if is_safe(user_input):
reply = ask_your_ai(user_input)
else:
reply = "I cannot process that request."
async function isSafe(userMessage) {
const res = await fetch(
"https://prompt-firewall-api.onrender.com/analyze",
{
method: "POST",
headers: {
"X-API-Key": "your-key",
"Content-Type": "application/json"
},
body: JSON.stringify({ message: userMessage })
}
);
const data = await res.json();
return data.status === "PASSED";
}
if (await isSafe(userInput)) {
reply = await askYourAI(userInput);
} else {
reply = "I cannot process that request.";
}
curl -X POST https://prompt-firewall-api.onrender.com/analyze -H "X-API-Key: your-key" -H "Content-Type: application/json" -d '{"message": "user input here"}'
{
"status": "PASSED",
"reason": "No threats detected. Safe to forward to AI.",
"latency_ms": 84
}
using System.Net.Http;
using System.Text;
using System.Text.Json;
async Task<bool> IsSafe(string userMessage) {
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "your-key");
var body = JsonSerializer.Serialize(new { message = userMessage });
var content = new StringContent(body, Encoding.UTF8, "application/json");
var res = await client.PostAsync(
"https://prompt-firewall-api.onrender.com/analyze", content
);
var json = await res.Content.ReadAsStringAsync();
var data = JsonSerializer.Deserialize<JsonElement>(json);
return data.GetProperty("status").GetString() == "PASSED";
}