Responsible AI

Responsible AI on Google Cloud is the practice of designing, testing, and securing Gemini applications on Vertex AI so model behavior is constrained, inspected, and aligned with policy. In the provided material, it centers on prompt design, safety ratings and thresholds, input and output checks, and layered mitigations against prompt-injection, ReAct, and RAG attacks.

Synthesized across 4 notebooks. See the source pages under Notebooks below for line-level grounding.

This area is practical engineering work, not a single API call: prompts must be explicit, grounded, and scoped, while model outputs must be checked for safety, variability, and hallucination risk.

For security-sensitive Gemini applications, treat user inputs, retrieved documents, links, files, tool calls, and model outputs as untrusted. Use defense in depth with DLP checks, safety filters, schema validation, embeddings-based detection, mission checks, and user consent for dangerous operations.

The notebooks are demonstrations and learning material, so production implementations should replace simple parsers, placeholder endpoints, small datasets, and permissive safety settings with robust validation, policy-driven thresholds, and production-ready agent or RAG libraries.

Canonical workflow

  1. Set up a Google Cloud project, region, authentication, and required APIs such as Vertex AI, Cloud DLP, and Cloud Natural Language where needed.
  2. Choose the appropriate Gemini model and SDK, then configure generation settings for the use case, using low variability for safety comparisons or demonstrations.
  3. Design concise, specific prompts with one task at a time, representative examples when useful, clear source-of-truth grounding, and system instructions for guardrails.
  4. Pre-screen user inputs, links, binaries, files, and retrieved content with validation, DLP, safety checks, and threat-detection patterns before sending them to Gemini.
  5. Generate responses with Gemini on Vertex AI and inspect structured response metadata such as safety_ratings and finish_reason, not just response text.
  6. Post-screen outputs with DLP and safety filters before returning results to users or passing them to tools.
  7. For ReAct, RAG, and tool-using systems, validate tool inputs and outputs with strict schemas and require out-of-band user consent for dangerous operations.
  8. Test prompts and mitigations against safety categories, prompt-injection cases, RAG attacks, and business-policy thresholds before deployment.

Best practices

See Responsible AI - Best Practices for the full distilled guide.

  • Be concise, specific, and well-defined in prompts.
  • Ask one task at a time to reduce ambiguity and output variability.
  • Use system instructions to guardrail the model away from irrelevant or unsafe responses.
  • Convert generative tasks into classification tasks when lower variability is important.
  • Use zero-shot, one-shot, or few-shot prompting based on the goal, with one to five representative examples.
  • Keep example distribution aligned with the real distribution for classification tasks.

Key models & APIs

  • Gemini API on Vertex AI, google-genai SDK, Vertex AI SDK, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-2.0-flash, gemini-2.0-flash-001, google/text-embedding-005, Cloud DLP API, Cloud Natural Language API, Responsible AI safety filters, Gemini safety ratings and thresholds, Vertex AI Search, Agent Builder, LangChain Agents, LangChain RAG

Notebooks (4)

Gemini (4)


Part of the Generative AI Google Brain · Responsible AI - Best Practices