System Instructions & Safety
Steering Behavior & Enterprise Harm Filtering
In enterprise systems, production AI must remain tightly aligned with brand guidelines, regulatory boundaries, and deterministic output formats. Vertex AI provides two foundational primitives for governing model responses: System Instructions and Safety Filters.
System Instructions as Root Constraints
The systemInstruction parameter physically partitions persistent behavioral rules from the volatile conversation stream. Setting system instructions anchors the model's persona, mandates structural requirements (e.g. "Always respond in RFC 8259 JSON"), and establishes defense-in-depth against prompt injection attacks originating from untrusted user inputs.
Configuring Granular Harm Categories
Vertex AI provides 4 primary enterprise safety categories, each adjustable to BLOCK_NONE, BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE, or BLOCK_LOW_AND_ABOVE:
HARM_CATEGORY_HATE_SPEECH: Content targeting protected groups or identity attributes.HARM_CATEGORY_DANGEROUS_CONTENT: Facilitating harm, malware generation, weaponization, or CBRN materials.HARM_CATEGORY_HARASSMENT: Targeted bullying, disparagement, or intimidation.HARM_CATEGORY_SEXUALLY_EXPLICIT: Explicit imagery or sexual content.
import { GoogleGenAI, HarmCategory, HarmBlockThreshold } from "@google/genai";
const ai = new GoogleGenAI({ vertexAI: true, project: "my-gcp-project", location: "us-central1" });
const response = await ai.models.generateContent({
model: "gemini-3.8-flash",
config: {
systemInstruction: "You are a deterministic financial compliance auditor. Analyze claims strictly against GAAP standards.",
safetySettings: [
{
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE
},
{
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
threshold: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE
}
]
},
contents: "Review this risk disclosure draft."
});
console.log(response.text);
Configure strict harm category safety settings and system instructions on a Gemini foundation model call.