Skip to main content

Vertex AI

Use Google’s Gemini models through Vertex AI — Google Cloud’s enterprise ML platform. Same models as the Gemini API, but with Google Cloud IAM authentication, VPC support, and enterprise compliance.
Use vertex() when you need Google Cloud authentication (service accounts, ADC). Use google() when you have a simple API key.

Setup

Vertex AI uses the same SDK as Gemini:
npm install @google/genai

Factory

import { vertex } from "@radaros/core";

const model = vertex("gemini-2.0-flash", {
  project: "my-gcp-project",
  location: "us-central1",
});
modelId
string
required
The Gemini model identifier (same model IDs as the Gemini API).
config
object
Optional configuration. See Config below.

Supported Models

Model IDDescription
gemini-2.5-flashFast, efficient. Great for high-throughput and latency-sensitive apps.
gemini-2.5-proHighest capability. Best for complex reasoning and long-context tasks.
gemini-2.0-flashPrevious generation flash model.
All Gemini models available in your Vertex AI region can be used.

Config

project
string
required
Google Cloud project ID. Falls back to GOOGLE_CLOUD_PROJECT env var.
location
string
default:"us-central1"
Google Cloud region. Falls back to GOOGLE_CLOUD_LOCATION env var.
credentials
string
Service account key JSON string or file path. If omitted, uses Application Default Credentials.

Example

const model = vertex("gemini-2.5-flash", {
  project: "my-project-id",
  location: "europe-west4",
});

Vertex AI vs Gemini API

Featuregoogle() (Gemini API)vertex() (Vertex AI)
AuthAPI keyGoogle Cloud IAM / ADC
PricingPay-per-useGCP billing
VPC / PrivateNoYes
Enterprise complianceLimitedSOC2, HIPAA, etc.
Same modelsYesYes
Multi-modalYesYes

Multi-Modal Support

Vertex AI supports the same multi-modal capabilities as the Gemini API — images, audio, and files (including XLSX). All content is processed via inlineData.

Images

import { Agent, vertex, type ContentPart } from "@radaros/core";
import { readFileSync } from "node:fs";

const agent = new Agent({
  name: "vision-agent",
  model: vertex("gemini-2.5-flash", {
    project: "my-project",
    location: "us-central1",
  }),
  instructions: "Describe images in detail.",
});

const imageData = readFileSync("photo.jpg").toString("base64");
const result = await agent.run([
  { type: "text", text: "What's happening in this photo?" },
  { type: "image", data: imageData, mimeType: "image/jpeg" },
] as ContentPart[]);

Audio

const audioData = readFileSync("meeting.mp3").toString("base64");
const result = await agent.run([
  { type: "text", text: "Transcribe this meeting recording and list action items." },
  { type: "audio", data: audioData, mimeType: "audio/mp3" },
] as ContentPart[]);

Files & Documents

Vertex AI supports PDF, CSV, XLSX, and other formats natively:
const result = await agent.run([
  { type: "text", text: "Analyze the quarterly revenue trends." },
  {
    type: "file",
    data: readFileSync("financials.xlsx").toString("base64"),
    mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    filename: "financials.xlsx",
  },
] as ContentPart[]);
All multi-modal features work identically to the google() provider. See the Google Gemini docs for the full supported file type list.

Reasoning

Vertex AI Gemini models support thinking/reasoning via the same reasoning config:
const agent = new Agent({
  name: "analyst",
  model: vertex("gemini-2.5-pro", {
    project: "my-project",
    location: "us-central1",
  }),
  reasoning: { enabled: true, budgetTokens: 4000 },
  instructions: "You are a precise financial analyst.",
});

const result = await agent.run("Calculate the IRR of a $10K investment returning $3K/year for 5 years.");
console.log(result.thinking); // Model's step-by-step reasoning
console.log(result.text);     // Final answer

Full Example

import { Agent, vertex, defineTool } from "@radaros/core";
import { z } from "zod";

const agent = new Agent({
  name: "enterprise-assistant",
  model: vertex("gemini-2.5-flash", {
    project: "my-project",
    location: "us-central1",
  }),
  instructions: "You are an enterprise assistant with access to internal tools.",
  tools: [
    defineTool({
      name: "lookup_employee",
      description: "Look up an employee by name",
      parameters: z.object({
        name: z.string().describe("Employee name"),
      }),
      execute: async (args) => `Employee ${args.name} found in Engineering.`,
    }),
  ],
  logLevel: "info",
});

const output = await agent.run("Look up John Smith");
console.log(output.text);

Environment Variables

VariableDescription
GOOGLE_CLOUD_PROJECTDefault GCP project ID
GOOGLE_CLOUD_LOCATIONDefault GCP region (default: us-central1)
GOOGLE_APPLICATION_CREDENTIALSPath to service account key JSON