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

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