Vertex AI
You can also use Google Cloud's Vertex AI models, including Gemini or your own fine-tuned models, with DeepEval.
Command Line
Run the following command in your terminal to configure your deepeval environment to use Gemini models through Vertex AI for all metrics.
deepeval set-gemini \
--model=<model> \ # e.g. "gemini-2.5-flash"
--project=<project_id> \
--location=<location> # e.g. "us-central1"Python
Alternatively, you can specify your model directly in code using GeminiModel from DeepEval's model collection. By default, model is set to gemini-2.5-pro.
from deepeval.models import GeminiModel
from deepeval.metrics import AnswerRelevancyMetric
model = GeminiModel(
model="gemini-2.5-pro",
project="Your Project ID",
location="us-central1",
temperature=0
)
answer_relevancy = AnswerRelevancyMetric(model=model)There are ZERO mandatory and SEVEN optional parameters when creating an GeminiModel through Vertex AI:
- [Optional]
model: A string specifying the name of the Gemini model to use. Defaults toGEMINI_MODEL_NAMEif not passed; raises an error at runtime if unset. - [Optional]
temperature: A float specifying the model temperature. Defaults toTEMPERATUREif not passed; falls back to0.0if unset. - [Optional]
project: A string specifying the Google Cloud project ID for Vertex AI. Defaults toGOOGLE_CLOUD_PROJECTif not passed. - [Optional]
location: A string specifying the Google Cloud location for Vertex AI. Defaults toGOOGLE_CLOUD_LOCATIONif not passed. - [Optional]
service_account_key: A JSON string containing the service account key for authentication when using Vertex AI. This string can be either the path to a service account key file or the raw JSON string. Defaults toGOOGLE_SERVICE_ACCOUNT_KEYif not passed. - [Optional]
use_vertexai: A boolean to explicitly force Vertex AI (True) or Gemini API-key mode (False); if not passed, defaults toGOOGLE_GENAI_USE_VERTEXAIand otherwise falls back to auto-detection viaprojectandlocation. - [Optional]
generation_kwargs: A dictionary of additional generation parameters supported by your model provider.
Available Vertex AI Models
Below is a list of commonly used Gemini models:
gemini-3-pro-preview
gemini-3-flash-preview
gemini-2.5-pro
gemini-2.5-flash
gemini-2.5-flash-lite
gemini-2.0-flash
gemini-2.0-flash-lite
gemini-pro-latest
gemini-flash-latest
gemini-flash-lite-latest