# Environment Variables to Configure Provider Selection and API Keys in Hiring-Agent

> Configure Hiring-Agent provider selection and API keys using LLM_PROVIDER, DEFAULT_MODEL, and GEMINI_API_KEY environment variables. Easily set credentials without code changes.

- Repository: [HackerRank/hiring-agent](https://github.com/interviewstreet/hiring-agent)
- Tags: configuration
- Published: 2026-07-19

---

**The hiring-agent application reads three environment variables—`LLM_PROVIDER`, `DEFAULT_MODEL`, and `GEMINI_API_KEY`—to determine which LLM provider to use and supply the necessary API credentials without modifying source code.**

The `interviewstreet/hiring-agent` repository provides a flexible LLM integration that relies on environment variables to configure provider selection and API keys. Instead of hardcoding backend details, the application reads runtime configuration from environment variables defined in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) to switch between local Ollama instances and cloud-based Google Gemini models. Understanding these three variables is essential for securely deploying the hiring-agent across different infrastructure setups.

## Core Environment Variables

The configuration system centers on three variables read at import time in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py).

### LLM_PROVIDER

The **`LLM_PROVIDER`** variable selects which backend handles inference. At line 21 of [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py), the code calls `os.getenv("LLM_PROVIDER")` and validates the value against the `ModelProvider` enum. If the variable is unset or contains an unrecognized provider, the system falls back to **`ModelProvider.OLLAMA`** (the string `"ollama"`). This value is stored in the module-level constant `PROVIDER`, which [`llm_utils.py`](https://github.com/interviewstreet/hiring-agent/blob/main/llm_utils.py) and [`evaluator.py`](https://github.com/interviewstreet/hiring-agent/blob/main/evaluator.py) reference when instantiating clients.

### DEFAULT_MODEL

The **`DEFAULT_MODEL`** variable specifies the concrete model name passed to the provider. Defined at line 20 of [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) via `os.getenv("DEFAULT_MODEL")`, it defaults to **`"gemma3:4b"`** when omitted. The code uses this value to look up the correct provider implementation through the **`MODEL_PROVIDER_MAPPING`** dictionary, ensuring the selected model aligns with the chosen backend.

### GEMINI_API_KEY

The **`GEMINI_API_KEY`** variable supplies the authentication token required by the Google Gemini provider. Read at line 67 of [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py), it defaults to an empty string (`""`). When [`llm_utils.py`](https://github.com/interviewstreet/hiring-agent/blob/main/llm_utils.py) initializes a Gemini client, it checks this variable; if the provider is set to `ModelProvider.GEMINI` and the key is missing, the code raises an exception to prevent unauthenticated API calls.

## How Configuration is Loaded

Configuration loading happens at import time in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py). The module reads all three variables via `os.getenv()`, applies defaults where specified, and exposes them as module-level constants (`PROVIDER`, `DEFAULT_MODEL`, `GEMINI_API_KEY`). 

[`llm_utils.py`](https://github.com/interviewstreet/hiring-agent/blob/main/llm_utils.py) consumes these constants to construct the appropriate LLM client—whether that means connecting to a local Ollama server or initializing the Gemini SDK with the provided API key. Similarly, [`evaluator.py`](https://github.com/interviewstreet/hiring-agent/blob/main/evaluator.py) relies on this configuration when executing resume-evaluation tasks, ensuring the entire pipeline uses a consistent backend without hardcoded credentials.

## Practical Configuration Examples

### Running with Ollama (Default)

When no environment variables are set, the application defaults to Ollama with the `gemma3:4b` model:

```bash

# Uses LLM_PROVIDER=ollama and DEFAULT_MODEL=gemma3:4b

python -m main

```

### Switching to Google Gemini

To use the Gemini provider, export all three variables before starting the application:

```bash
export LLM_PROVIDER=gemini
export DEFAULT_MODEL=gemini-2.5-pro
export GEMINI_API_KEY=YOUR_API_KEY_HERE

python -m main

```

### Overriding the Default Ollama Model

You can change the local model without switching providers:

```bash
export DEFAULT_MODEL=mistral:7b
python -m main

```

### Accessing Configuration Programmatically

Import the constants directly from [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) to inspect the current configuration:

```python
from prompt import PROVIDER, DEFAULT_MODEL, GEMINI_API_KEY

print(f"Provider: {PROVIDER}")              # e.g., "gemini" or "ollama"

print(f"Model: {DEFAULT_MODEL}")            # e.g., "gemini-2.5-pro"

print(f"Key configured: {bool(GEMINI_API_KEY)}")

```

## Key Source Files

| File | Purpose |
|------|---------|
| **[`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py)** | Reads environment variables at lines 20, 21, and 67; defines `MODEL_PROVIDER_MAPPING` and provider enum validation. |
| **[`llm_utils.py`](https://github.com/interviewstreet/hiring-agent/blob/main/llm_utils.py)** | Consumes `PROVIDER`, `DEFAULT_MODEL`, and `GEMINI_API_KEY` to instantiate the correct LLM client. |
| **[`evaluator.py`](https://github.com/interviewstreet/hiring-agent/blob/main/evaluator.py)** | Executes evaluation tasks using the provider configuration imported from [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py). |
| **`.env.example`** | Template file documenting the expected environment variables for developer setups. |

## Summary

- **`LLM_PROVIDER`** selects the backend (Ollama or Gemini) and defaults to `"ollama"` if unset.
- **`DEFAULT_MODEL`** sets the specific model name (e.g., `gemma3:4b`, `gemini-2.5-pro`) and is resolved through `MODEL_PROVIDER_MAPPING`.
- **`GEMINI_API_KEY`** provides authentication for the Gemini provider and must be set when using that backend.
- All variables are read in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) and consumed by [`llm_utils.py`](https://github.com/interviewstreet/hiring-agent/blob/main/llm_utils.py) and [`evaluator.py`](https://github.com/interviewstreet/hiring-agent/blob/main/evaluator.py) to maintain a clean separation between configuration and implementation.

## Frequently Asked Questions

### What happens if `LLM_PROVIDER` is set to an invalid value?

If the value does not match a known member of the `ModelProvider` enum, the code in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) reverts to the default `ModelProvider.OLLAMA`, ensuring the application remains functional rather than crashing on invalid input.

### Is `GEMINI_API_KEY` required when using Ollama?

No. The `GEMINI_API_KEY` is only required when `LLM_PROVIDER` is set to `"gemini"`. When using the default Ollama provider, the application ignores this variable and connects to the local Ollama server without external authentication.

### Where is the provider validation logic located?

Provider validation occurs in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) immediately after reading `LLM_PROVIDER` at line 21. The code checks the value against the `ModelProvider` enum members; if validation fails, it falls back to the Ollama default before the value is exported for use by other modules.

### How do I add support for a new model in the mapping?

To add a new model, update the **`MODEL_PROVIDER_MAPPING`** dictionary in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) to associate the new model name with the appropriate `ModelProvider` enum value. Ensure the corresponding environment variables (such as API keys for new cloud providers) are read and validated in the same file before updating [`llm_utils.py`](https://github.com/interviewstreet/hiring-agent/blob/main/llm_utils.py) to handle the client initialization.