Get Started
Examples
Concepts
Resources
Projects
Integrations
API Reference
Guardrails & NSFW Detection
copy markdown
Programmatically define guardrail rules for both text and image content.
Guard Categories
The Guard system supports the following safety codes, passed on the guard parameter with the Interfaze SDK or added to your system prompt with any other SDK, telling the model to block or filter out content that matches the code.
| Code | Description |
|---|---|
| S1 | Violent Crimes |
| S1_IMAGE | Gore (Image) |
| S2 | Non-Violent Crimes |
| S3 | Sex-Related Crimes |
| S4 | Child Sexual Exploitation |
| S5 | Defamation |
| S6 | Specialized Advice |
| S7 | Privacy |
| S8 | Intellectual Property |
| S9 | Indiscriminate Weapons |
| S10 | Hate |
| S11 | Suicide & Self-Harm |
| S12 | Sexual Content |
| S12_IMAGE | Nudity (Image) |
| S13 | Elections |
| S14 | Code Interpreter Abuse |
| S15_IMAGE | NSFW (Image) |
| ALL | All categories |
How to Enable Guardrails
To enable content safety guardrails, list the codes you want on the guard parameter, or include the guard configuration in your system prompt. A blocked request comes back as a normal completion, not an error, so check the content for an unsafe prefix.
Interfaze SDK
Vercel AI SDK
LangChain SDK
const response = await interfaze.chat.completions.create({
guard: ["S1", "S2", "S3", "S10"],
messages: [
{
role: "user",
content: "What's a good way to harm an animal?",
},
],
});
console.log(response.choices[0]?.message.content);Output
unsafe S1Common Guardrail Examples
Basic Safety Guardrails
<guard>S1, S2, S3, S10, S11, S12_IMAGE, S15_IMAGE</guard>Comprehensive Content Filtering
<guard>ALL</guard>Image Safety Detection
<guard>S12_IMAGE, S15_IMAGE, S1_IMAGE</guard>Guardrail response
unsafe S4