# How to Configure Hiring Agent to Use Google Gemini: Complete Setup Guide

> Easily configure Hiring Agent to use Google Gemini. Set your GEMINI_API_KEY, update LLM_PROVIDER to gemini, and choose a model for seamless integration. Get started now.

- Repository: [HackerRank/hiring-agent](https://github.com/interviewstreet/hiring-agent)
- Tags: how-to-guide
- Published: 2026-07-11

---

**Set the `GEMINI_API_KEY` environment variable in your `.env` file, change `LLM_PROVIDER` to `gemini`, and select a Gemini model name like `gemini-2.5-pro` to switch the Hiring Agent from the default Ollama backend to Google Gemini.**

The Hiring Agent by InterviewStreet is an open-source resume evaluation tool that supports multiple Large Language Model (LLM) backends. While it defaults to Ollama for local inference, you can configure Hiring Agent to use Google Gemini by supplying your API key and updating a few configuration settings.

## Prerequisites for Gemini Configuration

Before switching backends, obtain a valid API key from Google AI Studio. The Hiring Agent requires this key to authenticate with the Gemini API. Ensure you have the `google-generativeai` package installed, which is listed in the project's [`requirements.txt`](https://github.com/interviewstreet/hiring-agent/blob/main/requirements.txt).

## Step-by-Step Configuration

### 1. Set the Environment Variables

The application uses `python-dotenv` to load configuration from `.env` files. Create a `.env` file in your project root based on the provided template:

```bash
cp main/.env.example .env

```

Edit the file to include your Gemini credentials:

```bash
GEMINI_API_KEY=your_actual_key_here
LLM_PROVIDER=gemini
DEFAULT_MODEL=gemini-2.5-pro

```

The [`main/prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/main/prompt.py) module loads these variables at lines 12-18 using `load_dotenv()`, then reads `GEMINI_API_KEY` at lines 66-68. If this key is missing, validation logic raises an error early to prevent unauthorized API calls.

### 2. Verify Model-to-Provider Mapping

In [`main/prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/main/prompt.py) (lines 36-44 and 55-63), the application maps model names to provider enums. All Gemini model names (such as `gemini-2.5-pro` or `gemini-2.5-flash`) are automatically mapped to `ModelProvider.GEMINI`. This mapping ensures that when you specify a Gemini model in `DEFAULT_MODEL`, the system instantiates the correct backend class.

### 3. Install Dependencies

Ensure the Google Generative AI SDK is available in your environment:

```bash
pip install -r requirements.txt

```

## How the Gemini Integration Works

Understanding the architecture helps troubleshoot configuration issues.

### Environment Loading in prompt.py

The [`main/prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/main/prompt.py) module handles environment initialization. It calls `load_dotenv()` to read `.env` files, then exposes `GEMINI_API_KEY` to the rest of the application. This design keeps credentials out of source code while making them available to provider classes.

### Provider Implementation in models.py

The `GeminiProvider` class in [`main/models.py`](https://github.com/interviewstreet/hiring-agent/blob/main/main/models.py) (lines 13-21) wraps the Google Gemini API. Its constructor receives the API key and calls `google.generativeai.configure(api_key=...)` to authenticate the client.

When processing chat requests, the `GeminiProvider.chat()` method (lines 48-66) constructs a `GenerativeModel` instance using the model name from `DEFAULT_MODEL` and generation parameters from `MODEL_PARAMETERS` in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py). It forwards user messages to the Gemini API and returns responses in a format compatible with the Hiring Agent's evaluation pipeline.

## Running the Hiring Agent with Gemini

Once configured, execute the evaluation script:

```bash
python -m main.evaluate path/to/resume.json

```

The agent will now route all LLM calls through Google Gemini using the specified model and parameters.

## Alternative: Programmatic Configuration

If you prefer not to use a `.env` file, set the variables in Python before importing the agent modules:

```python
import os

os.environ["GEMINI_API_KEY"] = "your-key-here"
os.environ["LLM_PROVIDER"] = "gemini"
os.environ["DEFAULT_MODEL"] = "gemini-2.5-flash"

from main.evaluate import evaluate_resume

# Your evaluation code here

```

This approach works because [`main/prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/main/prompt.py) reads environment variables at import time, allowing dynamic configuration without touching the filesystem.

## Summary

- **Environment Variables**: Set `GEMINI_API_KEY`, `LLM_PROVIDER=gemini`, and `DEFAULT_MODEL` in your `.env` file or shell environment.
- **Provider Mapping**: The system automatically maps Gemini model names to `ModelProvider.GEMINI` in [`main/prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/main/prompt.py) (lines 36-44).
- **Implementation**: The `GeminiProvider` class in [`main/models.py`](https://github.com/interviewstreet/hiring-agent/blob/main/main/models.py) wraps the Google Generative AI SDK and handles authentication via `google.generativeai.configure()`.
- **Validation**: The application validates the API key presence before constructing the provider to prevent runtime errors.
- **Configuration Source**: The `main/.env.example` file provides a template for all required environment variables.

## Frequently Asked Questions

### What happens if I don't set the GEMINI_API_KEY?

If the `GEMINI_API_KEY` environment variable is empty or missing, the Hiring Agent will raise a validation error during initialization. The validation logic checks for the key's presence before constructing the `GeminiProvider`, ensuring the application fails fast with a clear error message rather than attempting unauthorized API calls.

### Can I use different Gemini models for different evaluation tasks?

Yes. The `DEFAULT_MODEL` environment variable accepts any Gemini model name supported by the Google API, such as `gemini-2.5-pro` or `gemini-2.5-flash`. The model-provider mapping in [`main/prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/main/prompt.py) recognizes these names and routes them to the `GeminiProvider` class accordingly, allowing you to switch models by changing a single environment variable.

### How do I switch back to Ollama from Gemini?

To revert to the default Ollama backend, change the `LLM_PROVIDER` environment variable to `ollama` or remove it entirely, as Ollama is the default provider. Ensure your Ollama server is running locally, and update `DEFAULT_MODEL` to an Ollama-compatible model name such as `llama2` or `mistral`.

### Where does the Hiring Agent validate the Gemini API key?

The application validates the `GEMINI_API_KEY` in [`llm_utils.py`](https://github.com/interviewstreet/hiring-agent/blob/main/llm_utils.py) before instantiating the `GeminiProvider` class. This validation ensures that if the key is missing or empty, the error is raised immediately when the module loads, rather than during the first chat request to the Gemini API.