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.
Basic model access
Section titled “Basic model access”Installation
Section titled “Installation”uv add genkit-google-genaiConfiguration
Section titled “Configuration”from genkit import Genkitfrom 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 loginsessions. Requires a Google Cloud project with billing andaiplatform.googleapis.comenabled. - Gemini Enterprise Express Mode: API-key access for quick prototyping without full project setup. Learn more about Express Mode.
import os
from genkit import Genkitfrom genkit_google_genai import VertexAI
ai = Genkit( plugins=[ VertexAI(api_key=os.environ['VERTEX_EXPRESS_API_KEY']), ],)Express Mode needs no project or location.
Available models
Section titled “Available models”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 workflowsgemini-3.1-pro-preview— Preview Pro model for complex reasoninggemini-3.5-flash-lite— High-throughput, low-latency modelgemini-3.1-flash-image— Fast native image generation and editinggemini-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').
Basic usage
Section titled “Basic usage”from genkit import Genkitfrom 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)Text embedding
Section titled “Text embedding”from genkit_google_genai import VertexAI
embeddings = await ai.embed( embedder=VertexAI.embedder('text-embedding-005'), content='Embed this support ticket.',)Image generation
Section titled “Image generation”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).
Thinking config
Section titled “Thinking config”Thinking level (Gemini 3)
Section titled “Thinking level (Gemini 3)”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' ),)Thinking budget
Section titled “Thinking budget”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)Enterprise features
Section titled “Enterprise features”Installation for advanced features
Section titled “Installation for advanced features”Core Gemini Enterprise features (genkit-google-genai):
uv add genkit-google-genaiModel Garden (genkit-vertexai with publisher extras):
# Install the extra matching the publisher(s) you call:uv add 'genkit-vertexai[anthropic]' # Claude on Vertex AIuv add 'genkit-vertexai[openai]' # Llama, Mistral, and OpenAI-compatible endpointsuv add 'genkit-vertexai[anthropic,openai]' # BothInstalling 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.
Project, location, and ADC configuration
Section titled “Project, location, and ADC configuration”from genkit import Genkitfrom genkit_google_genai import VertexAI
ai = Genkit( plugins=[VertexAI(project='your-gcp-project', location='global')],)- Project ID: Pass
project=toVertexAI()or setGCLOUD_PROJECT/GOOGLE_CLOUD_PROJECT. - Location: Pass
location=toVertexAI()or setGOOGLE_CLOUD_LOCATION/GCLOUD_LOCATION(defaults tous-central1). Override per Gemini request withGeminiConfig(location='global'). - Credentials: Configure Application Default Credentials (
gcloud auth application-default login --project YOUR_PROJECT_IDlocally, or an attached service account withroles/aiplatform.useron GCP).
Grounding
Section titled “Grounding”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),)Context caching
Section titled “Context caching”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 Pathfrom genkit import Genkit, Message, Part, Rolefrom 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)Model Garden integration
Section titled “Model Garden integration”Import ModelGarden directly from genkit_vertexai and reference partner models as 'modelgarden/<publisher>/<model-id>' strings:
- Pass
project=(or setGCLOUD_PROJECT/GOOGLE_CLOUD_PROJECT) andlocation=(defaults tous-central1, orGOOGLE_CLOUD_LOCATION/GOOGLE_CLOUD_REGION). - Pin per-model regions with
model_locations={'<publisher>/<model-id>': '<location>'}. ModelGardenauthenticates only with Application Default Credentials. A per-requestapi_keyincontext={'secrets': ...}is rejected withINVALID_ARGUMENT.
Llama (Meta) and OpenAI-compatible models
Section titled “Llama (Meta) and OpenAI-compatible models”Requires uv add 'genkit-vertexai[openai]':
from genkit import Genkitfrom 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.
Anthropic (Claude) models in Model Garden
Section titled “Anthropic (Claude) models in Model Garden”Requires uv add 'genkit-vertexai[anthropic]':
from genkit import Genkitfrom 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.',)Evaluation metrics
Section titled “Evaluation metrics”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 Genkitfrom genkit_google_genai import VertexAI
ai = Genkit( plugins=[VertexAI(project='your-project-id', location='us-central1')],)Next steps
Section titled “Next steps”- Learn about generating content
- See RAG to implement retrieval-augmented generation
- Check out creating flows to build structured AI workflows
- For API key access via Google AI Studio, see the Google Generative AI plugin