Vertex AI¶
Code written for Google Cloud's Vertex AI calls its own paths, with a project and a region in them. The gateway accepts those paths as they are, so a Vertex AI app is governed and recorded like any other, without Google Cloud credentials on the app's side: the gateway holds them.
What it is¶
Vertex AI's model paths:
POST /v1/projects/{project}/locations/{location}/publishers/google/models/{model}:generateContent
POST /v1/projects/{project}/locations/{location}/publishers/google/models/{model}:streamGenerateContent
POST /v1/projects/{project}/locations/{location}/publishers/anthropic/models/{model}:rawPredict
POST /v1/projects/{project}/locations/{location}/publishers/anthropic/models/{model}:streamRawPredict
/v1beta1/projects/…, the version Google's GenAI SDK uses for Vertex AI, works the same. The body is the one in
Generate content for publishers/google, and Anthropic's Messages body for
publishers/anthropic.
| Path | Model behind the name | What the gateway does |
|---|---|---|
publishers/google |
Gemini on Vertex AI | Sends the call to Vertex AI as it is, under the provider's own project and region |
publishers/google |
Gemini on Google AI Studio, or another provider's model | Sends it as it is to Gemini; translates it for OpenAI, Azure, Claude and Bedrock |
publishers/anthropic |
Claude | Sends it on as Anthropic's format |
The project and region in your path don't choose anything: the gateway uses the ones set up for the provider in the Control room, so any values pass.
The two settings¶
With the Google GenAI SDK in Vertex AI mode (vertexai=True):
| Setting | Environment variable | Python | TypeScript | Value |
|---|---|---|---|---|
| Base address | GOOGLE_VERTEX_BASE_URL |
HttpOptions(base_url=…) |
httpOptions: { baseUrl } |
https://<your-gateway> |
| Key | none | credentials=Credentials(token="vk_…") |
googleAuthOptions: { authClient } |
Your Vidai key, sent as Authorization: Bearer |
| Project, location | GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION |
project, location |
project, location |
Any values; the SDK needs them to build the path |
In Vertex AI mode the SDK sends an OAuth token as Authorization: Bearer. Giving it your Vidai key as a fixed token
makes it send that instead, and the gateway accepts Authorization: Bearer. No Google Cloud login is needed on the
app's side.
Don't use a Vertex AI API key (express mode, api_key with vertexai=True): the SDK then leaves the project out of
the path, and the gateway doesn't recognise the call as Vertex AI.
A minimal call¶
from google import genai
from google.genai import types
from google.oauth2.credentials import Credentials
client = genai.Client(
vertexai=True,
project="my-project",
location="europe-west4",
credentials=Credentials(token="vk_…"), # your Vidai key, sent as Authorization: Bearer
http_options=types.HttpOptions(base_url="https://<your-gateway>"),
)
response = client.models.generate_content(
model="gemini-3.5-flash",
contents="Say hello in Dutch.",
)
print(response.text)
import { GoogleGenAI } from "@google/genai";
import { OAuth2Client } from "google-auth-library";
const authClient = new OAuth2Client();
authClient.setCredentials({ access_token: "vk_…" }); // your Vidai key, sent as Authorization: Bearer
const ai = new GoogleGenAI({
vertexai: true,
project: "my-project",
location: "europe-west4",
googleAuthOptions: { authClient },
httpOptions: { baseUrl: "https://<your-gateway>" },
});
const response = await ai.models.generateContent({ model: "gemini-3.5-flash", contents: "Say hello in Dutch." });
console.log(response.text);
curl "https://<your-gateway>/v1/projects/my-project/locations/europe-west4/publishers/google/models/gemini-3.5-flash:generateContent" \
-H "Authorization: Bearer $VIDAI_KEY" \
-H "content-type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"Say hello in Dutch."}]}]}'
Both samples rely on a token with no expiry never being refreshed, which is how Google's auth libraries treat it: the Vidai key is sent as the bearer token on every call.
Streaming, tools and the rest work as in Generate content; model can be any name your key may
call, gpt-4.1 or claude-sonnet-4.5 included.
Claude with Anthropic's Vertex AI client¶
Anthropic's SDK has a Vertex AI client that calls publishers/anthropic/…:rawPredict. Give it the gateway's address
with /v1 and your Vidai key as the access token:
from anthropic import AnthropicVertex
client = AnthropicVertex(
base_url="https://<your-gateway>/v1", # or ANTHROPIC_VERTEX_BASE_URL
region="europe-west1",
project_id="my-project",
access_token="vk_…",
)
message = client.messages.create(
model="claude-sonnet-4.5",
max_tokens=200,
messages=[{"role": "user", "content": "Say hello in Dutch."}],
)
print(message.content[0].text)
The answer, streams and errors are Anthropic's, as on Messages.
Media from Cloud Storage¶
Vertex AI has no Files API. Put large media in a Cloud Storage bucket and refer to it by URI; the URI passes through the gateway unchanged:
response = client.models.generate_content(
model="gemini-3.5-flash",
contents=[
types.Part.from_uri(file_uri="gs://your-bucket/clip.mp4", mime_type="video/mp4"),
"Describe this clip.",
],
)
{"contents": [{"role": "user", "parts": [
{"text": "Describe this clip."},
{"fileData": {"mimeType": "video/mp4", "fileUri": "gs://your-bucket/clip.mp4"}}
]}]}
Google's rule: the bucket must be in the same project as the Vertex AI credentials the gateway uses, so ask your admin
which project that is. A gs:// URI means nothing to other providers: on another provider's model it is reported as
fileData and not sent.
Reading what the gateway did¶
As in Generate content: response.sdk_http_response.headers in
Python, response.sdkHttpResponse?.headers in TypeScript. x-vidai-request-id goes into
Request logs › Request reference; x-vidai-model says which model answered.
Errors¶
On publishers/google paths, in Google's shape ({"error":{"code","message","status"}}), as on
Generate content. On publishers/anthropic paths, in Anthropic's shape. Match on
x-vidai-error-code. A path with a publisher other than google or anthropic is not served.
Model names¶
The names your organisation approved, as listed under Models in the Control room, in the models/{model} part of
the path. @ versions in Vertex AI model ids (claude-sonnet-4-5@20250929) are the provider's names; use the
Control room's name and the gateway sends the right id.
What goes through the gateway¶
| Feature | Through the gateway |
|---|---|
generateContent, streamGenerateContent (publishers/google) |
Yes, to every provider, as in Generate content |
rawPredict, streamRawPredict (publishers/anthropic) |
Yes, to Claude |
countTokens |
Yes; for another provider's model the gateway counts, as in Count tokens |
| Media | By Cloud Storage URI (gs://) |
| Files API | No: Vertex AI has none |
| Vertex AI API key (express mode) | No: use project and location with your Vidai key as the token |
Check it works in a minute¶
Run the curl above with your key in VIDAI_KEY: a 200 and a short answer mean the address and key are right. The call
shows in Request logs within seconds.
Good to know¶
- Your app needs no Google Cloud credentials: the gateway holds them, and your Vidai key is the only secret on the app's side.
- Always give the SDK your Vidai key as the fixed token, as above. Without it, the SDK looks for Google Cloud credentials and sends a Google token, which isn't a Vidai key and gets a 401.
- Embedding calls on Vertex AI's own
:predictpath go through, but their token counts aren't recorded, so they show no tokens or cost in Request logs. For recorded embeddings, call a Gemini embedding model with Embed content.