Skip to main content

Adding Models

This section explains the steps to add Google Vertex AI models and configure the required access controls.
1

Navigate to Google Vertex Models in AI Gateway

From the TrueFoundry dashboard, navigate to AI Gateway > Models and select Google Vertex.
Navigating to Google Vertex Provider Account in AI Gateway

Navigate to Google Vertex Models

2

Add Google Vertex Account and Authentication

Give a unique name to your Google Vertex account. This will be used to refer to the models later. Add collaborators to your account, this will give access to the account to other users/teams. Learn more about access control here.
Required IAM RoleThe Google Cloud identity used by the gateway (a service account, whether referenced by a key, by GKE Workload Identity, or by Workload Identity Federation) must have the Agent Platform User role (roles/aiplatform.user, formerly Vertex AI User), which includes the aiplatform.endpoints.predict permission required by the gateway.Step 1 — Create a service account and grant it Vertex AI accessNo matter which authentication method you choose below, the gateway ultimately authenticates as a Google Cloud IAM service account. Create that service account once and grant it Vertex AI access. (For the reusable, provider-agnostic version of these steps — including an AWS IAM ARN variant — see Create a custom service account.)
roles/aiplatform.user (the Agent Platform User role, formerly Vertex AI User) is the simplest grant. If your organization requires least privilege, create a custom IAM role containing only the aiplatform.endpoints.predict permission and bind it in place of roles/aiplatform.user.
Step 2 — Connect the service account using an authentication methodThe gateway supports three authentication methods. Pick the one that matches your deployment.1. Using Service Account JSON KeyThis method works for all deployment types (GKE, EKS, AKS, on-premises, or the SaaS Gateway).Create a JSON key for the service account from Step 1:
When adding the provider account in TrueFoundry, select Service account key file as the authentication type and paste the contents of $GSA_NAME-key.json into the Service account key JSON field (or store it as a secret and reference it). See the official guide on creating and managing service account keys for rotation and lifecycle management.2. Using Workload Identity Federation (Keyless, Cross-Cloud)Workload Identity Federation (WIF) lets the gateway authenticate to Google Cloud without service account keys, even when running outside of GKE — for example, on Amazon EKS, Azure AKS, or on-premises Kubernetes clusters. It works by exchanging a short-lived Kubernetes service account token for a Google Cloud access token through Google’s Security Token Service.
Workload Identity Federation is the recommended approach for production deployments running outside of GKE. It eliminates long-lived service account keys while supporting any Kubernetes environment, and it also works on the SaaS version of the AI Gateway.
Prerequisites
  • A Google Cloud project with Vertex AI enabled, and the service account from Step 1 (already granted roles/aiplatform.user).
  • The Kubernetes service account used by the gateway must have permission to issue TokenRequest resources for itself. The TrueFoundry-provided Helm chart configures this RBAC automatically.
The steps below reuse the service account from Step 1 ($GSA_EMAIL). Set the additional inputs:
a. Create a Workload Identity Pool
b. Create a Workload Identity ProviderThe --issuer-uri must be the OIDC issuer URL of your Kubernetes cluster. The --attribute-condition restricts which Kubernetes service accounts can use this provider.
c. Allow the federated identity to impersonate the service accountGrant roles/iam.workloadIdentityUser so the Kubernetes service account (via the pool) can impersonate the service account you created in Step 1:
To allow all service accounts in a namespace (instead of a single one), bind on the namespace attribute with principalSet instead:
d. Generate the credential configuration JSON
This produces a JSON file with "type": "external_account" describing the identity pool, audience, and STS token-exchange endpoints. It is not a private key.
Which --credential-source-type should I use?
  • --credential-source-type=programmatic (used above) generates a config with no credential source — the gateway mints a fresh Kubernetes service account token itself via the TokenRequest API and supplies it during the STS exchange. This is the recommended setup for the TrueFoundry gateway and relies on the TokenRequest RBAC noted in the prerequisites (the Helm chart configures it automatically).
  • --credential-source-file=<path> --credential-source-type=text (used in the reference Create a custom service account guide and the EKS walkthrough FAQ) instead reads a static projected token mounted in the pod (e.g. /var/run/secrets/kubernetes.io/serviceaccount/token). Use this variant if your deployment mounts a projected service-account token rather than minting one on demand.
Both produce a valid external_account config — pick the one that matches how the gateway pod obtains its Kubernetes token.
These steps mirror the reusable Create a custom service account guide. For a complete step-by-step walkthrough of setting up Workload Identity Federation from an EKS cluster, see the FAQ: How do I set up Workload Identity Federation for an EKS cluster?
Configure in TrueFoundryWhen adding or editing the Vertex AI provider account:
  1. Select Workload Identity Federation file as the authentication type.
  2. Paste the contents of the generated credential-config.json into the Key file content field, or store it as a secret and reference it.
Resumable file uploads (used for some batch and fine-tuning workflows that upload files to Google Cloud Storage via signed URLs) are not yet supported with Workload Identity Federation. If you rely on those flows, use a Service Account JSON key instead.
3. Using GCP Workload Identity on GKE (Self-Hosted Gateway only)When running the gateway inside Google Kubernetes Engine (GKE), you can rely on GKE’s built-in Workload Identity, which lets a Kubernetes service account (KSA) act as a Google Cloud IAM service account (GSA) automatically through the GKE metadata server.
GKE Workload Identity is GKE-specific. Pods using the configured KSA authenticate as the associated GSA when accessing Google Cloud APIs, with no extra configuration on the gateway side.
To set up GKE Workload Identity, follow the official Google Cloud documentation: Configure Workload Identity on GKE.When adding the Vertex AI provider account in TrueFoundry, leave the authentication section empty — the gateway will automatically pick up GKE Workload Identity credentials via Application Default Credentials (ADC).
GCP Workload Identity (GKE ADC) does not work on the SaaS version of the Gateway, and it only works when the gateway runs inside a GKE cluster. For all other environments, use Workload Identity Federation or a Service Account JSON key.
Google Vertex account configuration form with fields for name, project ID, service account JSON, and region

Add Vertex Provider Account

3

Configure Project ID and Region

Provide your Google Cloud Project ID and a default Region for all models under this account. You can override the region for individual models later.Project ID
  • You can find your Project ID in the top-right corner of your Google Cloud Console.
Google Cloud Console header showing project ID location in the dropdown menu

Finding your Project ID in Google Cloud Console

Region
  • Specify a default region for all models under this account. You can override this region for individual models later.
4

Add Models

You can either select available models from the list or add them manually by clicking + Add Model. When adding a model manually, the Model ID format depends on the provider.
Select a Gemini model from the list or add it manually.
  • Model ID Format: google/<vertex-model-id>
  • Example: google/gemini-1.5-pro
You can find the Model ID in the Google Cloud Console.
Google Cloud Console showing Gemini model details with model ID highlighted

Find Gemini Model ID in Google Console

Select a Claude model from the list or add it manually.
  • Model ID Format: anthropic/<vertex-model-id>
  • Example: anthropic/claude-3-5-sonnet-v2@20241022
Google Cloud Console showing Anthropic Claude model details with model ID highlighted

Find Anthropic Model ID in Google Console

Select a Mistral model from the list or add it manually.
  • Model ID Format: mistralai/<vertex-model-id>
  • Example: mistralai/mistral-large-2411@001
Google Cloud Console showing Mistral AI model details with model ID highlighted

Find Mistral Model ID in Google Console

When adding any model manually, you can specify a Region to override the default one set at the account level.

Inference

After adding the models, you can perform inference using an OpenAI-compatible API via the Playground or by integrating it with your own application.
Code Snippet and Try in Playgroud Buttons for each Google Vertex model

Infer Model in Playground or Get Code Snippet

Supported APIs

Once your Vertex provider account is configured, the following API surfaces are available through the gateway. The table below summarizes each endpoint alongside platform feature support (tracing, cost tracking).
Legend:
  • Supported by Provider and Truefoundry
  • Supported by Provider, but not by Truefoundry
  • Provider does not support this feature
Vertex’s chat completions endpoint is the most widely used — it supports streaming, tools, multimodal input (images, audio, video, PDF), structured JSON outputs & extended thinking. The gateway translates OpenAI-compatible requests into Vertex’s native generateContent API based on the model family. Full provider capability matrix: Chat Completions API.
Python
Set stream=True and iterate over delta chunks. Defensively check that chunk.choices is non-empty and delta.content is not None.
Python
Advertise a tool, hand the model’s tool_calls back as a tool role message, then request the final response.
Python
Gemini models support image inputs via the image_url content part. The detail parameter (low / high / auto) translates to Vertex’s native mediaResolution setting.
Python
Gemini models accept audio files inline via image_url content parts with a mime_type hint. This is unique to Gemini — Bedrock and direct OpenAI chat models do not accept audio as chat input.
Python
Gemini models accept video files via image_url content parts with mime_type: video/mp4. The gateway fetches the URL server-side, so you can pass any publicly reachable MP4. This is unique to Gemini.
Python
Gemini models accept PDFs via the file content type with base64 encoding.
Python
Gemini supports two structured-output modes via response_format:
  • JSON object{"type": "json_object"} — guarantees valid JSON, no schema
  • JSON schema{"type": "json_schema", "json_schema": {...}} — enforces a schema (additionalProperties: False and strict: True are recommended)
Python
Gemini 2.5 Pro and 2.5 Flash support extended thinking, on by default. Use reasoning_effort (low/medium/high) — the gateway translates it to Vertex’s native thinking-budget parameter. Gemini 3+ models additionally return thinking_blocks with signatures for multi-turn continuity.
Python
For Gemini 3+, always echo thinking_blocks exactly as returned when continuing a conversation. Blocks with missing or modified signature fields are rejected by Vertex.
Vertex’s Gemini TTS models (gemini-2.5-flash-tts, gemini-2.5-flash-preview-tts, gemini-2.5-pro-preview-tts) generate audio from text. The gateway exposes them via the OpenAI-compatible /audio/speech endpoint. Full docs: Text-to-Speech.
Model gating: Before you call the Text to Speech API, add TTS-preview model to your Vertex provider account. When adding a model, select Text to Speech as the model type.
Python
Vertex exposes two embedding families through /embeddings:
  • Text embeddings (text-embedding-004, text-embedding-005) — accept a task_type parameter via extra_body that tunes the vector for the downstream task (RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY, SEMANTIC_SIMILARITY, CLASSIFICATION, CLUSTERING).
  • Multimodal embeddings (multimodalembedding@001) — accept text, image, and/or video in the same request and return separate vectors per modality.
Full docs: Embed API.
Python
multimodalembedding@001 returns separate vectors per modality under embedding (text) and image_embedding. Useful for cross-modal retrieval — e.g. find the image whose embedding is closest to a text query.
Python
Supported embedding models on Vertex include text-embedding-004, text-embedding-005, and multimodalembedding@001. Add them to your provider account from the model picker.
Vertex exposes Imagen and Gemini image-generation models via the OpenAI-compatible /images/generations endpoint. Full docs: Image Generation.
Python
Supported text-to-image models include imagen-4.0-generate-001, imagen-3.0-generate-002, and Gemini image models such as gemini-3-pro-image-preview.
Pricing varies by model family. Imagen models are billed per image at a flat rate. Gemini image models are billed per token, where higher-resolution / HD outputs consume more tokens. Pick the family that matches your cost profile.
Vertex’s image edit only supports inpainting with a mask — unlike OpenAI, the mask is required. Use imagen-3.0-capability-001 (Imagen’s edit-specific variant).
Python
Image Variation (client.images.create_variation) is not supported — Vertex Imagen only supports generation and inpainting.
Vertex batch jobs are GCS-backed — the gateway uploads JSONL to a Cloud Storage bucket on your provider account, creates a Vertex batch prediction job, and fetches results from GCS. Full docs: Batch Predictions.
Vertex batch prerequisites:
  • GCS bucket — must be in the same region as your Vertex model
  • Service account / federated identity — with roles/storage.objectAdmin on the bucket
  • Workload Identity Federation caveat — does not yet support resumable uploads. Use a Service Account JSON key for batch.

Workflow Steps

The batch process follows these steps:
  1. Upload: Upload JSONL file → Get file ID (a URL-encoded gs://... URI)
  2. Create: Create batch job → Get batch ID
  3. Monitor: Check status until complete
  4. Fetch: Download aggregated results from the gateway’s /batches/{id}/output endpoint

Step-by-Step Examples

Client setup with batch-specific headers. The bucket and region headers tell the gateway where to stage the JSONL on GCS, and x-tfy-provider-model is the bare Vertex model id (no provider prefix).
Python
Build and upload the input JSONL.
Python
Vertex doesn’t enforce a strict per-batch minimum like Bedrock — you can submit a small batch for testing.
Python
Poll batches.retrieve() until completed. batch.id may come as URL-encoded; unquote() once before retrieve so the OpenAI SDK doesn’t double-encode the path.
Python
Vertex returns the payload as a single-line JSON array (not JSONL) — parse it once, then iterate.
Python
Vertex’s Files API stores uploads in Google Cloud Storage on your behalf. Upload, retrieve metadata, and retrieve content are supported. List and delete are NOT supported — the GCS backend doesn’t expose those operations. Full docs: Files API.
Python
files.list() and files.delete() is not supported by Vertex — the GCS backend doesn’t expose them. Plan lifecycle management via GCS bucket policies and lifecycle rules instead of through the gateway.
Vertex’s Files API only accepts purpose="batch" for batch uploads or purpose="fine-tune" (with the x-tfy-file-purpose: fine-tune header) for tuning uploads. Plain text or non-conforming JSONL will fail validation.
Vertex supports supervised fine-tuning of Gemini models. The lifecycle:
  1. Prepare JSONL training data (one example per line)
  2. Upload via the Files API with purpose="fine-tune" and the x-tfy-file-purpose: fine-tune header
  3. Submit a fine-tune job; poll for completion
  4. Use the resulting fine-tuned model id in subsequent inference calls
Full docs: Fine-tuning.
Fine-tuning incurs real GCP charges. See the Vertex tunable model list.
Python

FAQs

No. You can set a default region at the account level and override it for each individual model if needed. This allows you to use models from different regions with a single provider account.
  • Service Account JSON Key — Works everywhere (any cloud, on-prem, SaaS Gateway). Simplest to set up, but requires you to manage and rotate a long-lived secret.
  • Workload Identity Federation — Recommended for production. Keyless, works on any Kubernetes cluster (EKS, AKS, GKE, on-prem) and on the SaaS Gateway. Requires a one-time setup of a Workload Identity Pool in Google Cloud.
  • GCP Workload Identity (GKE) — Only available when the self-hosted gateway runs inside a GKE cluster. Keyless and zero-config on the gateway side, but does not work on the SaaS Gateway or outside of GKE.
Both are keyless authentication mechanisms, but they target different environments.GCP Workload Identity is a GKE-only feature. The GKE metadata server automatically maps a Kubernetes service account to a Google Cloud IAM service account. The gateway picks this up through Application Default Credentials (ADC) when no auth data is configured. It does not work on the SaaS Gateway or outside of GKE.Workload Identity Federation is a broader Google Cloud feature that works across any Kubernetes cluster (EKS, AKS, on-prem, and GKE) and on the SaaS Gateway. It requires you to provide an external_account credential configuration JSON (generated via gcloud iam workload-identity-pools create-cred-config). The gateway exchanges a short-lived Kubernetes service account token for a Google Cloud access token through Google’s Security Token Service.
This example walks through the full setup of Workload Identity Federation to let a TrueFoundry service account running on Amazon EKS authenticate to Google Cloud. Replace the pool names, project IDs, OIDC issuer URI, namespaces, and service account names with your own values.Step 1 — Create a Workload Identity Pool
Step 2 — Create a Workload Identity ProviderThe --issuer-uri must be the OIDC issuer URL of your EKS cluster. You can find it in the AWS EKS console or via aws eks describe-cluster. The --attribute-condition restricts which Kubernetes service accounts can use this provider.
Step 3 — Create a Google Cloud Service Account
Step 4 — Grant the Service Account the Required RoleGrant the Agent Platform User role (formerly Vertex AI User, or whichever role your workload needs) to the service account:
Step 5 — Allow the Federated Identity to Impersonate the Service AccountGrant the roles/iam.workloadIdentityUser role so the Kubernetes service account (via the workload identity pool) can impersonate the Google Cloud service account:
Optionally, to allow all service accounts in a namespace (instead of a single one), use principalSet:
Step 6 — Generate the Credential Configuration FileThis is the file you will paste into TrueFoundry when configuring the Vertex AI provider account.
The generated credential-configuration.json file is what you provide in TrueFoundry under Workload Identity Federation file when adding the Vertex AI provider account.
Gemini is generally recommended for individual developers and prototyping use cases, while Vertex AI is recommended for production and enterprise use cases.Vertex AI offers everything available in the Gemini API and more, including:
  • More secure auth using service accounts instead of API keys
  • A Model Garden that includes multiple third-party models
  • Access to provisioned throughput
You can read more about this here: