Vertex AI plugin
The Vertex AI plugin provides access to Google’s Gemini models through Vertex AI using Google Cloud authentication.
Configuration
Section titled “Configuration”To use this plugin, add the genkit_vertexai package to your project:
dart pub add genkit_vertexaiThen, you can use vertexAI plugin in the Genkit initializer:
import 'package:genkit/genkit.dart';
import 'package:genkit_vertexai/genkit_vertexai.dart';
void main() { final ai = Genkit( plugins: [vertexAI()], );}The plugin requires you to specify your Google Cloud project ID, the region to which you want to make Vertex API requests, and your Google Cloud project credentials.
-
By default,
vertexAIgets your Google Cloud project ID from theGCLOUD_PROJECTenvironment variable.You can also pass this value directly:
vertexAI(projectId: 'my-project-id')-
By default,
vertexAIgets the Vertex AI API location from theGCLOUD_LOCATIONenvironment variable.You can also pass this value directly:
vertexAI(location: 'us-central1')-
To provide API credentials, you need to set up Google Cloud Application Default Credentials.
-
To specify your credentials:
-
If you’re running your flow from a Google Cloud environment (Cloud Functions, Cloud Run, and so on), this is set automatically.
-
On your local dev environment, do this by running:
-
-
gcloud auth application-default login- For other environments, see the Application Default Credentials docs.
- In addition, make sure the account is granted the Vertex AI User IAM role (
roles/aiplatform.user). See the Vertex AI access control docs.
Generative models
Section titled “Generative models”To get a reference to a supported model, specify its identifier to vertexAI method:
final model = vertexAI.gemini('gemini-2.5-flash');final ai = Genkit( plugins: [vertexAI()],);
final response = await ai.generate( model: vertexAI.gemini('gemini-2.5-flash'), prompt: 'Tell me a joke.',);
print(response.text);See Generating content with AI models for more information.
The Vertex AI plugin provides access to Google Cloud’s enterprise-grade AI platform, offering advanced features beyond basic model access. Use this for enterprise applications that need grounding, Vector Search, Model Garden, or evaluation capabilities.
Accessing Google GenAI Models via Vertex AI
Section titled “Accessing Google GenAI Models via Vertex AI”All languages support accessing Google’s generative AI models (Gemini, Imagen, etc.) through Vertex AI with enterprise authentication and features.