Skip to content

Gemini Enterprise plugin

The Gemini Enterprise plugin provides access to Google’s Gemini models via the Gemini Enterprise API using Google Cloud authentication.

To use this plugin, add the genkit_vertexai package to your project:

Terminal window
dart pub add genkit_vertexai

Then, 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 Gemini Enterprise API requests, and your Google Cloud project credentials.

  • By default, vertexAI gets your Google Cloud project ID from the GOOGLE_CLOUD_PROJECT or GCLOUD_PROJECT environment variable.

    You can also pass this value directly:

vertexAI(projectId: 'my-project-id')
  • By default, vertexAI uses the global location.

    To use a regional endpoint, pass the location directly:

vertexAI(location: 'us-central1')
  • To provide API credentials, you need to set up Google Cloud Application Default Credentials.

    1. 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:

Terminal window
gcloud auth application-default login
  1. In addition, make sure the account is granted the roles/aiplatform.user IAM role. See the Gemini Enterprise access control docs.

To get a reference to a model, pass its Vertex model ID to vertexAI.gemini. The Gemini API’s -latest aliases (such as gemini-flash-latest) are not available on Vertex, so use a versioned ID:

final model = vertexAI.gemini('gemini-3.6-flash');
final ai = Genkit(
plugins: [vertexAI()],
);
final response = await ai.generate(
model: vertexAI.gemini('gemini-3.6-flash'),
prompt: 'Tell me a joke.',
);
print(response.text);

See Generating content with AI models for more information.

The following embedding models are supported:

  • text-embedding-005 - English text embeddings (768 dimensions)
  • text-multilingual-embedding-002 - Multilingual text embeddings (768 dimensions)
  • multimodalembedding@001 - Multimodal embeddings for text, image, and video
  • gemini-embedding-001 - Gemini embedding model (default 3072 dimensions)

To get a reference to a supported embedding model, specify its identifier to vertexAI.textEmbedding:

final embeddings = await ai.embed(
embedder: vertexAI.textEmbedding('gemini-embedding-001'),
documents: [
DocumentData(content: [TextPart(text: 'Hello world')]),
],
);
print(embeddings[0].embedding);

See Retrieval-augmented generation (RAG) for more information.

The Gemini Enterprise plugin provides access to Gemini Enterprise, offering capabilities for building, scaling, and governing agents alongside model access, grounding, Vector Search, Model Garden, and evaluation metrics.

Accessing Google GenAI Models via the Gemini Enterprise API

Section titled “Accessing Google GenAI Models via the Gemini Enterprise API”

All languages support accessing Google’s generative AI models (Gemini, Imagen, etc.) via the Gemini Enterprise API with enterprise authentication and features.