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
- Install
- Authentication
Vertex AI uses the same SDK as Gemini:
Factory
The Gemini model identifier (same model IDs as the Gemini API).
Optional configuration. See Config below.
Supported Models
| Model ID | Description |
|---|---|
gemini-2.5-flash | Fast, efficient. Great for high-throughput and latency-sensitive apps. |
gemini-2.5-pro | Highest capability. Best for complex reasoning and long-context tasks. |
gemini-2.0-flash | Previous generation flash model. |
Config
Google Cloud project ID. Falls back to
GOOGLE_CLOUD_PROJECT env var.Google Cloud region. Falls back to
GOOGLE_CLOUD_LOCATION env var.Service account key JSON string or file path. If omitted, uses Application Default Credentials.
Example
Vertex AI vs Gemini API
| Feature | google() (Gemini API) | vertex() (Vertex AI) |
|---|---|---|
| Auth | API key | Google Cloud IAM / ADC |
| Pricing | Pay-per-use | GCP billing |
| VPC / Private | No | Yes |
| Enterprise compliance | Limited | SOC2, HIPAA, etc. |
| Same models | Yes | Yes |
| Multi-modal | Yes | Yes |
Full Example
Environment Variables
| Variable | Description |
|---|---|
GOOGLE_CLOUD_PROJECT | Default GCP project ID |
GOOGLE_CLOUD_LOCATION | Default GCP region (default: us-central1) |
GOOGLE_APPLICATION_CREDENTIALS | Path to service account key JSON |