Vertex AI is part of the unified
@genkit-ai/google-genai package. For simpler setup, see Google AI.Installation
Setup
Vertex AI supports two authentication methods:Method 1: Application Default Credentials (Recommended)
This is the standard authentication method for production applications. Prerequisites:- Google Cloud project with billing enabled
- Vertex AI API enabled
- Appropriate IAM permissions
roles/aiplatform.userroles/storage.objectViewer(for some features)
Method 2: Express Mode (API Key)
Vertex AI Express Mode provides a simplified way to try Vertex AI features using just an API key, without requiring full GCP project setup or billing. Get an API Key:- Visit Vertex AI Studio
- Enable Express Mode
- Generate an API key
With Express Mode, you don’t provide
projectId or location in the config.Available Models
Text Generation (Gemini)
All Gemini models available through Google AI are also available on Vertex AI:- gemini-2.5-flash - Balanced performance and speed
- gemini-2.5-pro - Most powerful Gemini model
- gemini-2.5-flash-lite - Fastest option
Image Generation (Imagen)
- imagen-3.0-generate-002 - High-quality image generation
- imagen-3.0-fast-generate-001 - Faster generation
Music Generation (Lyria)
Vertex AI exclusive:- lyria-002 - Generate music and audio from text descriptions
Video Generation (Veo)
- veo-002 - Generate videos from text prompts
Embeddings
- text-embedding-005 - Latest embedding model
- text-embedding-004 - Previous generation
- text-multilingual-embedding-002 - Multilingual support
Usage Examples
Basic Text Generation
Music Generation with Lyria
Image Generation with Imagen
Multimodal Input
Context Caching
Reduce costs and latency for repeated prompts with large context:Grounding with Google Search
Ground model responses with real-time search results:Function Calling
Embeddings
Model Garden Access
Vertex AI Model Garden provides access to models from various providers:Anthropic Claude via Model Garden
Meta Llama Models
Vector Search Integration
Vertex AI Vector Search enables high-performance similarity search for RAG applications.Setup Vector Search Index
Retrieval-Augmented Generation (RAG)
Configuration Options
Regional Endpoints
Choose the region closest to your users:Global Endpoint
Model Configuration
Advanced Features
Model Tuning
Vertex AI supports fine-tuning Gemini models on your data:Model Evaluation
Use Vertex AI’s evaluation tools to assess model performance:Request Logging
Vertex AI automatically logs requests for monitoring and debugging:Vertex AI vs Google AI
Best Practices
- Use regional endpoints close to your users for lower latency
- Enable context caching for prompts with repeated large context
- Implement proper IAM controls with service accounts
- Monitor usage with Cloud Monitoring
- Use Vector Search for RAG applications instead of manual similarity
- Enable request logging for debugging and auditing
- Set up alerts for quota limits and errors
- Use Model Garden to access diverse models without managing multiple APIs
Troubleshooting
Authentication Errors
GOOGLE_APPLICATION_CREDENTIALS to your service account key:
API Not Enabled
Permission Denied
Region Not Supported
Some models are only available in specific regions. Check the Vertex AI documentation for model availability.Pricing
Vertex AI pricing varies by:- Model type (Flash vs Pro)
- Input/output token count
- Additional features (context caching, grounding)
- Region
- Use
gemini-2.5-flashfor most tasks - Enable context caching for repeated prompts
- Use batch predictions for high-volume processing
- Set appropriate
maxOutputTokenslimits
Next Steps
- Google AI Provider - Simpler alternative for prototyping
- RAG with Vector Search - Build retrieval systems
- Model Evaluation - Test model performance
- Production Deployment - Deploy to production