Skip to content

Gemini Enterprise plugin

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.

The genkit-google-genai package provides access to Gemini Enterprise (Vertex AI) models through the VertexAI plugin, and genkit-vertexai provides ModelGarden for partner models on Vertex AI.

Terminal window
uv add genkit-google-genai
from genkit import Genkit
from genkit_google_genai import VertexAI
ai = Genkit(
plugins=[
VertexAI(location='global'), # Global endpoint for Gemini 3 models
],
)

VertexAI also accepts network options: headers, timeout (seconds), max_retries, and http_client_factory.

Authentication Methods:

  • Application Default Credentials (ADC): Standard IAM authentication for production GCP workloads and local gcloud auth application-default login sessions. Requires a Google Cloud project with billing and aiplatform.googleapis.com enabled.
  • Gemini Enterprise Express Mode: API-key access for quick prototyping without full project setup. Learn more about Express Mode.
import os
from genkit import Genkit
from genkit_google_genai import VertexAI
ai = Genkit(
plugins=[
VertexAI(api_key=os.environ['VERTEX_EXPRESS_API_KEY']),
],
)

Express Mode needs no project or location.

Any model ID Gemini Enterprise serves in your location works, including newer models and tuned endpoints (endpoints/<id>). The -latest aliases exist only on the Gemini API, so pass a versioned ID. Use the helper for the model’s family (VertexAI.gemini(), gemini_image(), or gemini_tts()) or a 'vertexai/<model-id>' string. The list below is curated metadata, not an allowlist. Partner models use Model Garden.

Gemini 3 Series:

  • gemini-3.8-flash — High-intelligence Flash model for reasoning, coding, and agentic workflows
  • gemini-3.1-pro-preview — Preview Pro model for complex reasoning
  • gemini-3.5-flash-lite — High-throughput, low-latency model
  • gemini-3.1-flash-image — Fast native image generation and editing
  • gemini-3-pro-image — High-fidelity image generation and editing

Configure VertexAI(location='global') for Gemini 3 models. gemini-3.8-flash, gemini-3.5-flash-lite, and gemini-3.1-flash-image are also served in the us and eu multi-regions (project is required for multi-region endpoints); gemini-3.1-pro-preview and gemini-3-pro-image are global only. Override the location for a single Gemini call with GeminiConfig(location='global').

from genkit import Genkit
from genkit_google_genai import VertexAI
ai = Genkit(
plugins=[VertexAI(location='global')],
)
response = await ai.generate(
model=VertexAI.gemini('gemini-3.8-flash'),
prompt='Explain Gemini Enterprise IAM authentication in two sentences.',
)
print(response.text)
from genkit_google_genai import VertexAI
embeddings = await ai.embed(
embedder=VertexAI.embedder('text-embedding-005'),
content='Embed this support ticket.',
)

VertexAI.imagen() raises INVALID_ARGUMENT; Imagen models are not supported. Use Gemini native image models via VertexAI.gemini_image() and GeminiImageConfig:

from genkit_google_genai import GeminiImageConfig, VertexAI
response = await ai.generate(
model=VertexAI.gemini_image('gemini-3.1-flash-image'),
prompt='A watercolor architectural sketch of a mountain train station.',
config=GeminiImageConfig(
aspect_ratio='16:9',
image_size='2K',
),
)
image = response.media[0]
print(image.content_type, image.url[:40])

Vertex AI also supports Virtual Try-On (VertexAI.virtual_try_on('virtual-try-on-001') with VirtualTryOnConfig) and Veo background video generation (await ai.generate_operation(model=VertexAI.veo('veo-3.1-fast-generate-001'), ...) with VeoConfig).

Pass thinking_level directly on GeminiConfig:

from genkit_google_genai import GeminiConfig, VertexAI
response = await ai.generate(
model=VertexAI.gemini('gemini-3.1-pro-preview'),
prompt='What is heavier, one kilo of steel or one kilo of feathers?',
config=GeminiConfig(
thinking_level='HIGH', # 'MINIMAL', 'LOW', 'MEDIUM', or 'HIGH'
),
)

On Gemini 2.5 models, pass thinking_budget and include_thoughts directly on GeminiConfig:

from genkit_google_genai import GeminiConfig, VertexAI
response = await ai.generate(
model=VertexAI.gemini('gemini-2.5-flash'),
prompt='What is heavier, one kilo of steel or one kilo of feathers?',
config=GeminiConfig(
thinking_budget=1024,
include_thoughts=True,
),
)
reasoning = ''.join(p.reasoning or '' for p in response.message.content)
print(reasoning)
print(response.text)

Core Gemini Enterprise features (genkit-google-genai):

Terminal window
uv add genkit-google-genai

Model Garden (genkit-vertexai with publisher extras):

Terminal window
# Install the extra matching the publisher(s) you call:
uv add 'genkit-vertexai[anthropic]' # Claude on Vertex AI
uv add 'genkit-vertexai[openai]' # Llama, Mistral, and OpenAI-compatible endpoints
uv add 'genkit-vertexai[anthropic,openai]' # Both

Installing bare genkit-vertexai without [anthropic] or [openai] installs neither SDK client, and model calls fail with FAILED_PRECONDITION and the uv add command to run.

from genkit import Genkit
from genkit_google_genai import VertexAI
ai = Genkit(
plugins=[VertexAI(project='your-gcp-project', location='global')],
)
  • Project ID: Pass project= to VertexAI() or set GCLOUD_PROJECT / GOOGLE_CLOUD_PROJECT.
  • Location: Pass location= to VertexAI() or set GOOGLE_CLOUD_LOCATION / GCLOUD_LOCATION (defaults to us-central1). Override per Gemini request with GeminiConfig(location='global').
  • Credentials: Configure Application Default Credentials (gcloud auth application-default login --project YOUR_PROJECT_ID locally, or an attached service account with roles/aiplatform.user on GCP).

Set google_search=True on GeminiConfig to ground responses with Google Search (see Gemini Enterprise pricing for grounding charges):

from genkit_google_genai import GeminiConfig, VertexAI
response = await ai.generate(
model=VertexAI.gemini('gemini-3.8-flash'),
prompt='What are the latest developments in fault-tolerant quantum computing?',
config=GeminiConfig(google_search=True),
)

Set metadata={'cache': {'ttl_seconds': ...}} on a message to cache the prompt prefix up to and including that message. Explicit caching supports gemini-2.0-flash, gemini-2.0-flash-001, and gemini-3-flash-preview, and cannot be combined with tools in the same request:

from pathlib import Path
from genkit import Genkit, Message, Part, Role
from genkit_google_genai import VertexAI
ai = Genkit(
plugins=[VertexAI(location='global')],
)
text_content = Path('path/to/war_and_peace.txt').read_text()
response = await ai.generate(
messages=[
Message(
role=Role.USER,
content=[Part.from_text(text_content)],
),
Message(
role=Role.MODEL,
content=[Part.from_text('This analysis is based on the provided text from War and Peace.')],
metadata={
'cache': {
'ttl_seconds': 300, # Cache prefix for 5 minutes
},
},
),
],
model=VertexAI.gemini('gemini-3-flash-preview'),
prompt='Analyze the relationship between Pierre and Natasha.',
)
print(response.text)

Import ModelGarden directly from genkit_vertexai and reference partner models as 'modelgarden/<publisher>/<model-id>' strings:

  • Pass project= (or set GCLOUD_PROJECT / GOOGLE_CLOUD_PROJECT) and location= (defaults to us-central1, or GOOGLE_CLOUD_LOCATION / GOOGLE_CLOUD_REGION).
  • Pin per-model regions with model_locations={'<publisher>/<model-id>': '<location>'}.
  • ModelGarden authenticates only with Application Default Credentials. A per-request api_key in context={'secrets': ...} is rejected with INVALID_ARGUMENT.

Requires uv add 'genkit-vertexai[openai]':

from genkit import Genkit
from genkit_vertexai import ModelGarden
ai = Genkit(
plugins=[
ModelGarden(
project='my-gcp-project',
location='us-east5',
),
],
)
response = await ai.generate(
model='modelgarden/meta/llama-4-maverick-17b-128e-instruct-maas',
prompt='Write a Python function that merges two sorted lists.',
)

Llama 4 Scout (modelgarden/meta/llama-4-scout-17b-16e-instruct-maas) is also served from us-east5. Other OpenAI-compatible Model Garden publishers (such as Mistral) use the same 'modelgarden/<publisher>/<model-id>' naming. Confirm exact model IDs and regions in the Model Garden console.

Requires uv add 'genkit-vertexai[anthropic]':

from genkit import Genkit
from genkit_vertexai import ModelGarden
ai = Genkit(
plugins=[
ModelGarden(
project='my-gcp-project',
location='global',
),
],
)
response = await ai.generate(
model='modelgarden/anthropic/claude-haiku-4-5@20251001',
prompt='Plan a two-day architecture walking tour in Melbourne.',
)

When VertexAI resolves a project (from project=, the environment, or ADC), it registers Vertex AI evaluation metrics as vertexai/bleu, vertexai/rouge, vertexai/fluency, vertexai/safety, vertexai/groundedness, vertexai/summarization_quality, vertexai/summarization_helpfulness, and vertexai/summarization_verbosity. The Evaluation Service is regional only: with location set to global, us, or eu, evaluator calls fail with FAILED_PRECONDITION, so use a region such as us-central1:

from genkit import Genkit
from genkit_google_genai import VertexAI
ai = Genkit(
plugins=[VertexAI(project='your-project-id', location='us-central1')],
)