Google Model Armor

Google Cloud Model Armor lets you create safety templates in the Google Cloud console and apply them to LLM traffic. Model Armor sanitizes both user prompts and model responses against your configured policies, blocking content that violates your templates.

Before you begin

  1. Install the agentgateway binary.
  2. Create a Model Armor template in the Google Cloud console.
  3. Note the template ID, project ID, and the region where the template is deployed.
  4. Ensure your agentgateway has GCP credentials configured with permission to call the Model Armor API.

Configure Google Model Armor

Configure the promptGuard policy under policies.ai in your agentgateway configuration. You can apply Model Armor to the request phase, the response phase, or both.

cat <<EOF > config.yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
binds:
- port: 3000
  listeners:
  - routes:
    - backends:
       - ai:
          name: gemini
          provider:
            openAI:
              model: gemini-1.5-flash
      policies:
        backendAuth:
          key: "$GOOGLE_API_KEY"
        ai:
          promptGuard:
            request:
            - googleModelArmor:
                templateId: <your-template-id>
                projectId: <your-project-id>
                location: us-central1
                policies:
                  backendAuth:
                    gcp: {}
            response:
            - googleModelArmor:
                templateId: <your-template-id>
                projectId: <your-project-id>
                location: us-central1
                policies:
                  backendAuth:
                    gcp: {}
EOF
SettingDescription
templateIdThe identifier of the Model Armor template to apply. Find this in the Google Cloud console under Security > Model Armor.
projectIdThe Google Cloud project ID where the Model Armor template is configured.
locationThe region where the Model Armor template is deployed. Defaults to us-central1.
policies.backendAuth.gcpGCP authentication configuration. Agentgateway uses the credentials available in the environment, such as Application Default Credentials.

When a request or response matches a Model Armor policy, agentgateway blocks the interaction and returns an error to the caller.

Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.