{"slug":"use-vertex-ai-with-aperture","title":"Use Vertex AI with Aperture","tags":["tailscale"],"agent_summary":"Last validated: Apr 9, 2026","trigger_phrases":[],"runnable":false,"markdown":"\r\n# Use Vertex AI with Aperture\r\n\r\nLast validated: Apr 9, 2026\r\n\r\nAperture by Tailscaleis currently [in alpha](https://tailscale.com/docs/reference/tailscale-release-stages#alpha).\r\n\r\nConfigure a Vertex AI provider in Aperture so your team can access Google Gemini and Anthropic Claude models through Aperture. This guide walks through creating a Google Cloud service account, generating a key file, and adding the provider to your Aperture configuration.\r\n\r\nAny [LLM client configured to use Aperture](https://tailscale.com/docs/aperture/use-your-tools) can access models served by this provider. Aperture routes requests based on the model name, so you do not need to configure each client separately for Vertex AI.\r\n\r\nIf you need Gemini models without Anthropic support, consider [Vertex AI Express mode](https://tailscale.com/docs/aperture/how-to/use-vertex-ai-express) with API key authentication instead of a service account.\r\n\r\n## [Prerequisites](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#prerequisites)\r\n\r\nBefore you begin, you need:\r\n\r\n- An Aperture instance accessible from your device. Refer to [get started with Aperture](https://tailscale.com/docs/aperture/get-started) if you have not set this up.\r\n- A Google Cloud project with the [Vertex AI API](https://console.cloud.google.com/apis/library/aiplatform.googleapis.com) enabled.\r\n- The [Google Cloud CLI](https://cloud.google.com/sdk/docs/install) (`gcloud`) installed and authenticated.\r\n- Your Aperture hostname (Tailscale's [MagicDNS](https://tailscale.com/docs/features/magicdns) provides short hostnames like `ai` in your tailnet; for example, `aperture.example.ts.net`). If you connect through ts-unplug, use `localhost:<PORT_NUMBER>` instead.\r\n\r\n## [Step 1: Set your Google Cloud project](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#step-1-set-your-google-cloud-project)\r\n\r\nSet the active project for the `gcloud` commands that follow. Replace `<your-project>` with your Google Cloud project ID.\r\n\r\n```shell\r\ngcloud config set project <your-project>\r\n```\r\n\r\n## [Step 2: Create a service account](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#step-2-create-a-service-account)\r\n\r\nCreate a dedicated service account for Aperture to use when calling the Vertex AI API.\r\n\r\n```shell\r\ngcloud iam service-accounts create aperture-vertex \\\r\n  --display-name=\"Aperture Vertex AI\"\r\n```\r\n\r\nThis creates a service account named `aperture-vertex` in your project. Aperture uses this account to authenticate with the Vertex AI API and generate bearer tokens for requests.\r\n\r\n## [Step 3: Grant IAM roles](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#step-3-grant-iam-roles)\r\n\r\nThe service account needs two IAM roles: one to call the Vertex AI API, and one to list available models.\r\n\r\n1. Grant the `aiplatform.user` role, which lets the service account send requests to Vertex AI models:\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n```shell\r\ngcloud projects add-iam-policy-binding <your-project> \\\r\n     --member=\"serviceAccount:aperture-vertex@<your-project>.iam.gserviceaccount.com\" \\\r\n     --role=\"roles/aiplatform.user\"\r\n```\r\n\r\n2. Grant the `serviceUsageConsumer` role, which lets the service account list available models:\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n```shell\r\ngcloud projects add-iam-policy-binding <your-project> \\\r\n     --member=\"serviceAccount:aperture-vertex@<your-project>.iam.gserviceaccount.com\" \\\r\n     --role=\"roles/serviceusage.serviceUsageConsumer\"\r\n```\r\n\r\n\r\n## [Step 4: Generate a JSON key file](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#step-4-generate-a-json-key-file)\r\n\r\nCreate a JSON key file for the service account. Aperture uses this key file to mint bearer tokens for Vertex AI requests.\r\n\r\n```shell\r\ngcloud iam service-accounts keys create aperture-vertex-key.json \\\r\n  --iam-account=aperture-vertex@<your-project>.iam.gserviceaccount.com\r\n```\r\n\r\nThis creates a file named `aperture-vertex-key.json` in your current directory. The file contains the private key and project metadata that Aperture needs to authenticate.\r\n\r\nStore this file securely. You cannot recover the private key if lost, and anyone with access to the file can authenticate as the service account.\r\n\r\n## [Step 5: Base64-encode the key file](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#step-5-base64-encode-the-key-file)\r\n\r\nAperture expects the key file as a base64-encoded string in the provider configuration. Encode the key file and copy the result to your clipboard.\r\n\r\nOn macOS:\r\n\r\n```shell\r\ncat aperture-vertex-key.json | base64 | pbcopy\r\n```\r\n\r\nOn Linux:\r\n\r\n```shell\r\ncat aperture-vertex-key.json | base64 -w 0\r\n```\r\n\r\nUse the encoded string in the next step as the value for the provider's `apikey` field.\r\n\r\n## [Step 6: Configure the Vertex provider in Aperture](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#step-6-configure-the-vertex-provider-in-aperture)\r\n\r\nAdd a Vertex provider to your Aperture configuration using the [Aperture dashboard](https://tailscale.com/docs/aperture). The following example shows the configuration with both Google and Anthropic models enabled.\r\n\r\n```json\r\n{\r\n  \"providers\": {\r\n    \"vertex\": {\r\n      \"baseurl\": \"https://aiplatform.googleapis.com\",\r\n      \"apikey\": \"keyfile::<base64-encoded-key>\",\r\n      \"models\": [\\\r\n        \"gemini-2.5-flash\",\\\r\n        \"gemini-2.0-flash-exp\",\\\r\n        \"claude-opus-4-6\",\\\r\n        \"claude-sonnet-4-5@20250929\",\\\r\n        \"claude-haiku-4-5@20251001\"\\\r\n      ],\r\n      \"compatibility\": {\r\n        \"google_generate_content\": true,\r\n        \"google_raw_predict\": true,\r\n        \"experimental_gemini_cli_vertex_compat\": true\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nReplace `<base64-encoded-key>` with the base64-encoded string from the previous step. The `keyfile::` prefix tells Aperture that the value is a base64-encoded service account key file, not a plain API key. Aperture decodes the key file and extracts the `project_id`, which it uses to rewrite request paths for Vertex AI (for example, filling in the `_aperture_auto_vertex_project_id_` placeholder).\r\n\r\nYou do not need the `authorization` field when using `keyfile::` authentication. Aperture generates OAuth bearer tokens from the key file automatically, bypassing the `authorization` field.\r\n\r\nThe `compatibility` flags control which Vertex AI API formats the provider accepts:\r\n\r\n- `google_generate_content` enables the Vertex AI `generateContent` endpoint for Google-published models such as Gemini.\r\n- `google_raw_predict` enables the Vertex AI raw predict endpoint for third-party models such as Anthropic Claude.\r\n- `experimental_gemini_cli_vertex_compat` rewrites short-form Gemini CLI request paths to full Vertex AI paths and strips unsupported fields from request bodies.\r\n\r\nEnable `google_generate_content` and `google_raw_predict` if your provider serves both Google and Anthropic models. If you serve only one type, enable the corresponding flag. For the full list of compatibility flags, refer to the [provider compatibility reference](https://tailscale.com/docs/aperture/provider-compatibility).\r\n\r\nAfter configuring the provider, [grant model access](https://tailscale.com/docs/aperture/how-to/grant-model-access) to the users or groups that need the Vertex models.\r\n\r\n## [Verify the provider](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#verify-the-provider)\r\n\r\n1. Open the Aperture dashboard and confirm the Vertex provider appears with the expected models.\r\n2. Send a test request through a connected tool, such as Claude Code or another tool configured to use the Vertex provider.\r\n3. Check the Aperture dashboard session list for a new entry corresponding to your request. The session shows the model name, token counts, and timestamp.\r\n\r\nIf the request succeeds and appears in the dashboard, your Vertex provider is configured correctly. If the request fails, refer to the [Aperture troubleshooting guide](https://tailscale.com/docs/aperture/troubleshooting).\r\n\r\n## [Manage service account keys](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#manage-service-account-keys)\r\n\r\nList or revoke service account keys when rotating credentials or decommissioning a provider.\r\n\r\n### [List keys for the service account](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#list-keys-for-the-service-account)\r\n\r\nRun the following command to list all keys associated with the service account:\r\n\r\n```shell\r\ngcloud iam service-accounts keys list \\\r\n  --iam-account=aperture-vertex@<your-project>.iam.gserviceaccount.com\r\n```\r\n\r\nThe output lists all keys for the service account. The `key-id` in the output matches the `private_key_id` field in your JSON key file.\r\n\r\n### [Revoke a key](https://tailscale.com/docs/aperture/how-to/use-vertex-ai\\#revoke-a-key)\r\n\r\nDelete a specific key by its `key-id`:\r\n\r\n```shell\r\ngcloud iam service-accounts keys delete <key-id> \\\r\n  --iam-account=aperture-vertex@<your-project>.iam.gserviceaccount.com\r\n```\r\n\r\nAfter revoking a key, generate a new key file and update the base64-encoded value in your Aperture provider configuration. Requests that use the revoked key fail immediately.\r\n\r\n![Project Logo](https://cdn.brandfetch.io/tailscale.com/fallback/lettermark/theme/dark/h/256/w/256/icon?c=1bfwsmEH20zzEfSNTed)\r\n\r\nAsk AI\r\n\r\nreCAPTCHA\r\n\r\nRecaptcha requires verification.\r\n\r\nprotected by **reCAPTCHA**\r\n","html":"<h1>Use Vertex AI with Aperture</h1>\n<p>Last validated: Apr 9, 2026</p>\n<p>Aperture by Tailscaleis currently <a href=\"https://tailscale.com/docs/reference/tailscale-release-stages#alpha\">in alpha</a>.</p>\n<p>Configure a Vertex AI provider in Aperture so your team can access Google Gemini and Anthropic Claude models through Aperture. This guide walks through creating a Google Cloud service account, generating a key file, and adding the provider to your Aperture configuration.</p>\n<p>Any <a href=\"https://tailscale.com/docs/aperture/use-your-tools\">LLM client configured to use Aperture</a> can access models served by this provider. Aperture routes requests based on the model name, so you do not need to configure each client separately for Vertex AI.</p>\n<p>If you need Gemini models without Anthropic support, consider <a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai-express\">Vertex AI Express mode</a> with API key authentication instead of a service account.</p>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#prerequisites\">Prerequisites</a></h2>\n<p>Before you begin, you need:</p>\n<ul>\n<li>An Aperture instance accessible from your device. Refer to <a href=\"https://tailscale.com/docs/aperture/get-started\">get started with Aperture</a> if you have not set this up.</li>\n<li>A Google Cloud project with the <a href=\"https://console.cloud.google.com/apis/library/aiplatform.googleapis.com\">Vertex AI API</a> enabled.</li>\n<li>The <a href=\"https://cloud.google.com/sdk/docs/install\">Google Cloud CLI</a> (<code>gcloud</code>) installed and authenticated.</li>\n<li>Your Aperture hostname (Tailscale's <a href=\"https://tailscale.com/docs/features/magicdns\">MagicDNS</a> provides short hostnames like <code>ai</code> in your tailnet; for example, <code>aperture.example.ts.net</code>). If you connect through ts-unplug, use <code>localhost:&#x3C;PORT_NUMBER></code> instead.</li>\n</ul>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#step-1-set-your-google-cloud-project\">Step 1: Set your Google Cloud project</a></h2>\n<p>Set the active project for the <code>gcloud</code> commands that follow. Replace <code>&#x3C;your-project></code> with your Google Cloud project ID.</p>\n<pre><code class=\"language-shell\">gcloud config set project &#x3C;your-project>\n</code></pre>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#step-2-create-a-service-account\">Step 2: Create a service account</a></h2>\n<p>Create a dedicated service account for Aperture to use when calling the Vertex AI API.</p>\n<pre><code class=\"language-shell\">gcloud iam service-accounts create aperture-vertex \\\r\n  --display-name=\"Aperture Vertex AI\"\n</code></pre>\n<p>This creates a service account named <code>aperture-vertex</code> in your project. Aperture uses this account to authenticate with the Vertex AI API and generate bearer tokens for requests.</p>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#step-3-grant-iam-roles\">Step 3: Grant IAM roles</a></h2>\n<p>The service account needs two IAM roles: one to call the Vertex AI API, and one to list available models.</p>\n<ol>\n<li>Grant the <code>aiplatform.user</code> role, which lets the service account send requests to Vertex AI models:</li>\n</ol>\n<pre><code class=\"language-shell\">gcloud projects add-iam-policy-binding &#x3C;your-project> \\\r\n     --member=\"serviceAccount:aperture-vertex@&#x3C;your-project>.iam.gserviceaccount.com\" \\\r\n     --role=\"roles/aiplatform.user\"\n</code></pre>\n<ol start=\"2\">\n<li>Grant the <code>serviceUsageConsumer</code> role, which lets the service account list available models:</li>\n</ol>\n<pre><code class=\"language-shell\">gcloud projects add-iam-policy-binding &#x3C;your-project> \\\r\n     --member=\"serviceAccount:aperture-vertex@&#x3C;your-project>.iam.gserviceaccount.com\" \\\r\n     --role=\"roles/serviceusage.serviceUsageConsumer\"\n</code></pre>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#step-4-generate-a-json-key-file\">Step 4: Generate a JSON key file</a></h2>\n<p>Create a JSON key file for the service account. Aperture uses this key file to mint bearer tokens for Vertex AI requests.</p>\n<pre><code class=\"language-shell\">gcloud iam service-accounts keys create aperture-vertex-key.json \\\r\n  --iam-account=aperture-vertex@&#x3C;your-project>.iam.gserviceaccount.com\n</code></pre>\n<p>This creates a file named <code>aperture-vertex-key.json</code> in your current directory. The file contains the private key and project metadata that Aperture needs to authenticate.</p>\n<p>Store this file securely. You cannot recover the private key if lost, and anyone with access to the file can authenticate as the service account.</p>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#step-5-base64-encode-the-key-file\">Step 5: Base64-encode the key file</a></h2>\n<p>Aperture expects the key file as a base64-encoded string in the provider configuration. Encode the key file and copy the result to your clipboard.</p>\n<p>On macOS:</p>\n<pre><code class=\"language-shell\">cat aperture-vertex-key.json | base64 | pbcopy\n</code></pre>\n<p>On Linux:</p>\n<pre><code class=\"language-shell\">cat aperture-vertex-key.json | base64 -w 0\n</code></pre>\n<p>Use the encoded string in the next step as the value for the provider's <code>apikey</code> field.</p>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#step-6-configure-the-vertex-provider-in-aperture\">Step 6: Configure the Vertex provider in Aperture</a></h2>\n<p>Add a Vertex provider to your Aperture configuration using the <a href=\"https://tailscale.com/docs/aperture\">Aperture dashboard</a>. The following example shows the configuration with both Google and Anthropic models enabled.</p>\n<pre><code class=\"language-json\">{\r\n  \"providers\": {\r\n    \"vertex\": {\r\n      \"baseurl\": \"https://aiplatform.googleapis.com\",\r\n      \"apikey\": \"keyfile::&#x3C;base64-encoded-key>\",\r\n      \"models\": [\\\r\n        \"gemini-2.5-flash\",\\\r\n        \"gemini-2.0-flash-exp\",\\\r\n        \"claude-opus-4-6\",\\\r\n        \"claude-sonnet-4-5@20250929\",\\\r\n        \"claude-haiku-4-5@20251001\"\\\r\n      ],\r\n      \"compatibility\": {\r\n        \"google_generate_content\": true,\r\n        \"google_raw_predict\": true,\r\n        \"experimental_gemini_cli_vertex_compat\": true\r\n      }\r\n    }\r\n  }\r\n}\n</code></pre>\n<p>Replace <code>&#x3C;base64-encoded-key></code> with the base64-encoded string from the previous step. The <code>keyfile::</code> prefix tells Aperture that the value is a base64-encoded service account key file, not a plain API key. Aperture decodes the key file and extracts the <code>project_id</code>, which it uses to rewrite request paths for Vertex AI (for example, filling in the <code>_aperture_auto_vertex_project_id_</code> placeholder).</p>\n<p>You do not need the <code>authorization</code> field when using <code>keyfile::</code> authentication. Aperture generates OAuth bearer tokens from the key file automatically, bypassing the <code>authorization</code> field.</p>\n<p>The <code>compatibility</code> flags control which Vertex AI API formats the provider accepts:</p>\n<ul>\n<li><code>google_generate_content</code> enables the Vertex AI <code>generateContent</code> endpoint for Google-published models such as Gemini.</li>\n<li><code>google_raw_predict</code> enables the Vertex AI raw predict endpoint for third-party models such as Anthropic Claude.</li>\n<li><code>experimental_gemini_cli_vertex_compat</code> rewrites short-form Gemini CLI request paths to full Vertex AI paths and strips unsupported fields from request bodies.</li>\n</ul>\n<p>Enable <code>google_generate_content</code> and <code>google_raw_predict</code> if your provider serves both Google and Anthropic models. If you serve only one type, enable the corresponding flag. For the full list of compatibility flags, refer to the <a href=\"https://tailscale.com/docs/aperture/provider-compatibility\">provider compatibility reference</a>.</p>\n<p>After configuring the provider, <a href=\"https://tailscale.com/docs/aperture/how-to/grant-model-access\">grant model access</a> to the users or groups that need the Vertex models.</p>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#verify-the-provider\">Verify the provider</a></h2>\n<ol>\n<li>Open the Aperture dashboard and confirm the Vertex provider appears with the expected models.</li>\n<li>Send a test request through a connected tool, such as Claude Code or another tool configured to use the Vertex provider.</li>\n<li>Check the Aperture dashboard session list for a new entry corresponding to your request. The session shows the model name, token counts, and timestamp.</li>\n</ol>\n<p>If the request succeeds and appears in the dashboard, your Vertex provider is configured correctly. If the request fails, refer to the <a href=\"https://tailscale.com/docs/aperture/troubleshooting\">Aperture troubleshooting guide</a>.</p>\n<h2><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#manage-service-account-keys\">Manage service account keys</a></h2>\n<p>List or revoke service account keys when rotating credentials or decommissioning a provider.</p>\n<h3><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#list-keys-for-the-service-account\">List keys for the service account</a></h3>\n<p>Run the following command to list all keys associated with the service account:</p>\n<pre><code class=\"language-shell\">gcloud iam service-accounts keys list \\\r\n  --iam-account=aperture-vertex@&#x3C;your-project>.iam.gserviceaccount.com\n</code></pre>\n<p>The output lists all keys for the service account. The <code>key-id</code> in the output matches the <code>private_key_id</code> field in your JSON key file.</p>\n<h3><a href=\"https://tailscale.com/docs/aperture/how-to/use-vertex-ai#revoke-a-key\">Revoke a key</a></h3>\n<p>Delete a specific key by its <code>key-id</code>:</p>\n<pre><code class=\"language-shell\">gcloud iam service-accounts keys delete &#x3C;key-id> \\\r\n  --iam-account=aperture-vertex@&#x3C;your-project>.iam.gserviceaccount.com\n</code></pre>\n<p>After revoking a key, generate a new key file and update the base64-encoded value in your Aperture provider configuration. Requests that use the revoked key fail immediately.</p>\n<p><img src=\"https://cdn.brandfetch.io/tailscale.com/fallback/lettermark/theme/dark/h/256/w/256/icon?c=1bfwsmEH20zzEfSNTed\" alt=\"Project Logo\"></p>\n<p>Ask AI</p>\n<p>reCAPTCHA</p>\n<p>Recaptcha requires verification.</p>\n<p>protected by <strong>reCAPTCHA</strong></p>\n"}