How to Configure Hiring Agent to Use Google Gemini Instead of Ollama

Set the LLM_PROVIDER environment variable to gemini, provide a valid GEMINI_API_KEY, and set DEFAULT_MODEL to a supported Gemini model name such as gemini-2.5-pro in your .env file to switch the LLM backend from Ollama to Google Gemini.

The InterviewStreet Hiring Agent repository selects its Large Language Model (LLM) provider at runtime based on environment configuration rather than hard-coded logic. By updating three specific environment variables, you can redirect all AI interactions from a local Ollama instance to Google's Gemini API without modifying any application code.

Required Environment Variables

Hiring Agent recognizes three critical variables to initialize the Gemini provider:

  • LLM_PROVIDER – Must be set to gemini to trigger the Google Cloud backend
  • DEFAULT_MODEL – The specific Gemini model identifier (e.g., gemini-2.5-pro)
  • GEMINI_API_KEY – Your authentication key from Google AI Studio

If any of these are missing or misconfigured, the system falls back to OllamaProvider according to the logic in llm_utils.py.

How Provider Resolution Works

The provider selection mechanism relies on two core files: prompt.py and llm_utils.py.

In prompt.py, the code loads environment variables and defines MODEL_PROVIDER_MAPPING, which maps model names to the ModelProvider enum. This mapping determines whether a given model name corresponds to Ollama or Gemini infrastructure.

The function initialize_llm_provider() in llm_utils.py performs the actual instantiation:

  1. It reads DEFAULT_MODEL from the environment
  2. Looks up the model in MODEL_PROVIDER_MAPPING (defined in prompt.py)
  3. If the mapping returns ModelProvider.GEMINI and GEMINI_API_KEY is non-empty, it returns an instance of GeminiProvider
  4. Otherwise, it instantiates OllamaProvider

Both provider classes implement an identical interface, exposing a chat() method with the same signature, ensuring seamless switching between backends.

Step-by-Step Configuration

Follow these steps to migrate from Ollama to Google Gemini:

  1. Obtain a Gemini API key Visit Google AI Studio and generate a new API key for the Gemini API.

  2. Update your environment file Create or edit the .env file in the project root:

    LLM_PROVIDER=gemini
    DEFAULT_MODEL=gemini-2.5-pro
    GEMINI_API_KEY=your_actual_key_here
  3. Verify the configuration Run any existing command to confirm the switch:

    python score.py path/to/resume.pdf

    The system will now route LLM calls through GeminiProvider instead of OllamaProvider.

Implementation Details

The configuration flow is implemented in prompt.py, where environment variables are validated and loaded at startup. The GEMINI_API_KEY constant is exported from this module and consumed by the provider initialization logic.

Here is a simplified view of how the system initializes the correct backend:

import os
from dotenv import load_dotenv
from prompt import MODEL_PROVIDER_MAPPING, GEMINI_API_KEY, DEFAULT_MODEL
from llm_utils import initialize_llm_provider

load_dotenv()  # Loads variables from .env file

model_name = os.getenv("DEFAULT_MODEL", DEFAULT_MODEL)

# Returns GeminiProvider or OllamaProvider based on mapping and API key presence

provider = initialize_llm_provider(model_name)

response = provider.chat(
    model=model_name,
    messages=[{"role": "user", "content": "Hello"}],
    options={"temperature": 0.1}
)

print(response["message"]["content"])

The GeminiProvider class (defined in models.py) handles authentication using the GEMINI_API_KEY and communicates directly with Google's generative AI endpoints, while OllamaProvider manages local HTTP connections to your Ollama server.

Summary

  • Hiring Agent uses runtime environment variables to select between OllamaProvider and GeminiProvider
  • Set LLM_PROVIDER=gemini, DEFAULT_MODEL to a valid Gemini model, and GEMINI_API_KEY to your Google key
  • The provider resolution in llm_utils.py checks MODEL_PROVIDER_MAPPING (defined in prompt.py) to instantiate the correct class
  • Both providers expose identical interfaces, ensuring compatibility when switching backends

Frequently Asked Questions

Where do I find my Gemini API key?

Visit the Google AI Studio website and navigate to the API keys section. Create a new key specifically for the Gemini API, then copy it into your .env file as the value for GEMINI_API_KEY. This key authenticates requests sent by the GeminiProvider class defined in models.py.

Can I switch back to Ollama after configuring Gemini?

Yes. Simply change LLM_PROVIDER back to ollama in your .env file, or remove the GEMINI_API_KEY variable. The initialize_llm_provider() function in llm_utils.py will detect the missing key and fall back to instantiating OllamaProvider automatically.

What happens if I set the wrong model name in DEFAULT_MODEL?

If DEFAULT_MODEL contains a value not recognized in MODEL_PROVIDER_MAPPING (defined in prompt.py), the system may fail to resolve the provider or default to Ollama behavior. Always use supported model identifiers like gemini-2.5-pro when LLM_PROVIDER is set to gemini to ensure proper routing to the Gemini backend.

Do I need to restart the application after changing the .env file?

Yes. Environment variables are read at startup when load_dotenv() executes and prompt.py initializes its constants. Changes to .env require a restart of the Hiring Agent process to trigger a new call to initialize_llm_provider() with the updated configuration.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →