← Blog

Route Vertex Model Armor Calls to the Template Location

Parminder Singh
Parminder Singh··6 min read
Summarize with AI

A Model Armor template is a regional or multi-regional policy resource. Every prompt and response screening call must use a Model Armor service endpoint that matches the location in the template resource name. This guide turns that contract into a route map, startup validation, failure policy, and release test for Vertex AI applications.

Platform & Architectureai-securityllm-securitycloud-securityarchitecturepolicy-enforcementzero-trust
Route Vertex Model Armor Calls to the Template Location

A Model Armor call has two location fields that must agree. The template resource name contains projects/PROJECT_ID/locations/LOCATION/templates/TEMPLATE_ID, while the request goes to modelarmor.LOCATION.rep.googleapis.com. Google requires a regional or multi-regional service endpoint matching the template location. A global host or a mismatched location turns a content-screening control into a routing error before any filter can inspect the payload.

I would encode that pair in one immutable route object. Asking application code to assemble the host and template name independently is an avoidable production defect.

TL;DR

  • Bind the Model Armor service host and full template resource name in one versioned route object.
  • Require the host location to equal the locations/LOCATION segment in the selected template.
  • Reject unknown template aliases before sending a prompt to Vertex AI, and apply an explicit fail-closed or approved degraded policy on screening errors.
  • Test prompt and response calls against every production region, then retain the resolved host and template name in the decision record.

The template location selects the service host

Google's template management guide says Model Armor template operations must use a regional or multi-regional endpoint matching the template's location. The documented host shape is modelarmor.LOCATION.rep.googleapis.com. The same guide marks the global endpoint, modelarmor.googleapis.com, as unsupported for template management and prompt or response sanitization.

Treat that statement as a route invariant. A deployment entry for us-central1 should contain the full service origin and full template resource name. Application code selects the entry by an approved route key such as vertex-us-prod and rejects either location from a caller.

A useful route record contains:

  • Route key and environment
  • Model Armor origin
  • Full prompt template resource name
  • Full response template resource name, if separate
  • Vertex AI destination and location
  • Failure disposition
  • Configuration version

The Vertex AI gateway patterns guide gives the larger request path. This article owns the narrower template-to-host binding.

One route object prevents location drift

Keep template selection on the trusted server side. A client should submit an application operation and approved model choice. The gateway resolves those inputs to a route object and refuses raw overrides for the Model Armor host, project, location, or template ID.

At process startup, parse each template resource name and compare its location segment with the configured Model Armor origin. Also verify that the Vertex destination belongs to an allowed route. The Model Armor and Vertex locations may follow different product constraints, so store each explicitly. Avoid deriving one from the other unless your architecture requires co-location and tests enforce it.

The resulting request blueprint is short:

  • Method: POST
  • Origin: https://modelarmor.LOCATION.rep.googleapis.com
  • Prompt path: /v1/projects/PROJECT_ID/locations/LOCATION/templates/TEMPLATE_ID:sanitizeUserPrompt
  • Response path: /v1/projects/PROJECT_ID/locations/LOCATION/templates/TEMPLATE_ID:sanitizeModelResponse
  • Authentication: Google Cloud OAuth bearer token from the approved workload identity
  • Media type: application/json

Google's sanitize user prompt reference defines the template resource path used by the prompt operation.

Template aliases belong in controlled configuration

Human-readable aliases such as customer-chat-prod help operators, but the runtime needs a deterministic mapping to a complete resource name. Store that mapping in reviewed configuration. Include the configuration digest or version in every screening record.

A deployment should fail startup when an alias is missing, duplicated, or points to a malformed resource. It should also fail when the host says europe-west4 and the template says locations/us-central1. This check catches the gray-screen incident where every request returns a location error after an otherwise clean release.

My blunt opinion is that a template ID in an environment variable is too little configuration for a security control. It hides the project and location, which are exactly the fields an investigator needs when a call reaches the wrong policy.

Separate prompt and response aliases are useful when the two directions need different filters or thresholds. Record both resolved names. The per-route AI policies guide explains how a route can carry distinct decisions without collapsing them into one generic safety flag.

Cross-project templates need explicit IAM

The application project and template project can differ. Google's prompt and response sanitization guide says a caller from another project needs an IAM policy binding in the project that hosts the template. The guide names roles/modelarmor.user for the calling user or service account.

Keep the IAM binding separate from the route map. The route map answers which template this operation may use. Google Cloud IAM answers whether the workload principal may call Model Armor in the hosting project.

For each cross-project route, retain:

  • Caller service account email
  • Workload identity source
  • Template project ID
  • Granted role or custom-role identifier
  • Approved template alias
  • Last successful authorization test

A broad project role can make several templates callable. The gateway still needs an allowlist that binds each authenticated application route to its approved template. Model Armor supplies screening policy. Natural-person identity policy remains the enterprise gateway's job.

Failure handling must precede Vertex delivery

Prompt screening sits before the Vertex AI call. A route that requires screening should stop when Model Armor times out, rejects authentication, reports an unknown template, or returns a malformed result. The application can expose a stable internal error code while retaining the provider response and resolved route fields in restricted evidence.

Response screening sits after Vertex inference and before delivery to the user or agent. A response-screening failure therefore needs its own disposition. Hold the model output, return an approved error, or enter a tightly defined review path. Sending the unscreened response because inference already consumed tokens defeats the output control.

Define retry behavior per failure class. Authentication errors and template-location mismatches require configuration repair. Quota and transient service errors may permit bounded retries with the same operation ID. A content match is a completed screening decision, so automatic replay adds cost without changing the content.

The safe idempotent LLM retries guide covers ambiguous provider outcomes. Model Armor retries should preserve the selected template, host, payload digest, attempt count, and original caller context.

Release tests prove the complete route

Run a matrix across every production route. Each row should name the application route, Model Armor host, prompt template, response template, Vertex destination, and expected failure posture. Exercise real authenticated calls in an approved test environment.

The minimum fixtures are:

  • Benign prompt followed by a benign response
  • Prompt that produces a configured filter match
  • Model response that produces a configured filter match
  • Host location changed while the template name remains fixed
  • Unknown template alias
  • Caller lacking access to the template project
  • Model Armor timeout before Vertex inference
  • Model Armor timeout after inference but before response delivery

Inspect one permitted and one held decision in the audit store. The record should show the authenticated workload, enterprise caller context supplied by the application, resolved route key, exact template resources, service origin, provider result, local disposition, and policy version. A green health check against the global Google API domain proves very little. The production test must call the regional host and exact template resource used by the route.

DeepInspect

DeepInspect can enforce the route selection on authenticated HTTP traffic deliberately routed between a user or agent and a Vertex AI endpoint. The application supplies trusted identity context. DeepInspect can bind that context to an approved Model Armor route, reject caller-supplied host or template overrides, and record the resolved policy fields with the allow or block decision.

Model Armor remains responsible for the screening result returned by its configured template. Identity-bound policy requires the separate caller context and route decision enforced by DeepInspect. Local inference, direct Vertex calls, STDIO traffic, and any HTTP path that bypasses the proxy remain outside DeepInspect's enforcement boundary.

Book a technical deep dive at deepinspect.ai.

Frequently asked questions

Must the Model Armor endpoint match the template location?

Yes. Google's template management documentation requires a regional or multi-regional Model Armor endpoint matching the template's location. Build the complete host and resource pair in controlled configuration, then reject mismatches at startup and during release validation.

Can an application use the global Model Armor endpoint?

Google's current guide marks modelarmor.googleapis.com as unsupported for template management and prompt or response sanitization. Use the documented regional or multi-regional modelarmor.LOCATION.rep.googleapis.com host for these operations.

Can one application project call a template in another project?

Yes, when the caller has the required IAM access in the template-hosting project. Google documents granting roles/modelarmor.user to the external user or service account. The gateway should also restrict which application route may select that template.

Should prompt and response screening use the same template?

They can, but the route should support separate template resources because input and output policies may diverge. Resolve both names before the request starts, store both in the decision evidence, and test each direction independently.