# Environment Variables Required for LLM Provider Configuration in hiring-agent

> Configure LLM providers in hiring agent by setting required environment variables like DEFAULT_MODEL, LLM_PROVIDER, and GEMINI_API_KEY for seamless integration and authentication.

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

---

**The interviewstreet/hiring-agent repository requires three environment variables—`DEFAULT_MODEL`, `LLM_PROVIDER`, and `GEMINI_API_KEY`—to control which Large Language Model provider serves requests and authenticate provider-specific API calls.**

Setting up the correct environment variables ensures the hiring-agent connects to your preferred LLM backend without runtime errors. All configuration logic is centralized in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py), where the application reads these variables using `os.getenv` and validates them against the `ModelProvider` enum defined in [`models.py`](https://github.com/interviewstreet/hiring-agent/blob/main/models.py).

## Required Environment Variables for LLM Configuration

The repository recognizes three specific environment variables that govern LLM behavior:

| Variable | Purpose | Default Value | Required When |
|----------|---------|---------------|---------------|
| **DEFAULT_MODEL** | Specifies the model name to invoke (e.g., `gemma3:4b`, `gemini-2.5-pro`) | `"gemma3:4b"` | Always used; overrides hard-coded default |
| **LLM_PROVIDER** | Identifies the backend provider (`ollama` or `gemini`) | `"ollama"` | Always used; determines code path and credential requirements |
| **GEMINI_API_KEY** | Authenticates requests to Google Gemini models | `""` (empty string) | Only when **LLM_PROVIDER** is set to `gemini` |

If you run the agent without setting any variables, it automatically falls back to the local Ollama provider with the `gemma3:4b` model.

## How Configuration Loading Works in prompt.py

The [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) file serves as the single source of truth for LLM configuration. It imports `os` and loads variables with default fallbacks to ensure the application starts even when values are missing:

```python

# prompt.py (excerpt)

DEFAULT_MODEL = os.getenv("DEFAULT_MODEL", DEFAULT_MODEL_NAME)
PROVIDER = os.getenv("LLM_PROVIDER", DEFAULT_PROVIDER.value)

# Validate provider against ModelProvider enum

if PROVIDER not in [p.value for p in ModelProvider]:
    PROVIDER = DEFAULT_PROVIDER.value

# Load Gemini-specific credential

GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "")

```

The code first attempts to read **DEFAULT_MODEL** and **LLM_PROVIDER**, falling back to `DEFAULT_MODEL_NAME` and `DEFAULT_PROVIDER.value` (which resolves to `"ollama"`) respectively. It then validates the provider string against all values in the `ModelProvider` enum from [`models.py`](https://github.com/interviewstreet/hiring-agent/blob/main/models.py), reverting to the default if the user provides an invalid identifier.

## Provider-Specific Configuration Requirements

Different providers require different levels of configuration. Understanding these distinctions prevents authentication errors when switching between local and cloud-based models.

### Ollama (Default Provider)

When **LLM_PROVIDER** is set to `ollama` or left unset, the agent expects a locally running Ollama instance. No API keys are required, making this the zero-configuration option for development environments.

```bash

# .env - Ollama configuration

DEFAULT_MODEL=gemma3:4b
LLM_PROVIDER=ollama

# GEMINI_API_KEY can be omitted

```

### Gemini Provider

Switching to Google's Gemini requires setting **LLM_PROVIDER** to `gemini` and supplying a valid **GEMINI_API_KEY**. The application checks for this key at runtime when the Gemini provider is active.

```bash

# .env - Gemini configuration

DEFAULT_MODEL=gemini-2.5-pro
LLM_PROVIDER=gemini
GEMINI_API_KEY=sk-your-actual-key-here

```

## Practical Configuration Examples

Below are complete examples showing how to set these variables in different contexts.

### Environment File (.env)

Create a `.env` file in the repository root based on the provided `.env.example` template:

```bash

# .env

DEFAULT_MODEL=gemini-2.5-pro
LLM_PROVIDER=gemini
GEMINI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx

```

### Python Runtime Verification

You can verify that variables load correctly by importing them directly from [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py):

```python

# verify_config.py

import os
from prompt import DEFAULT_MODEL, PROVIDER, GEMINI_API_KEY

print(f"Using model: {DEFAULT_MODEL}")
print(f"Provider: {PROVIDER}")

if PROVIDER == "gemini":
    assert GEMINI_API_KEY, "GEMINI_API_KEY must be set for Gemini models"
    print("Gemini API key configured successfully")

```

### Command Line Export

For temporary testing without a `.env` file, export variables in your shell:

```bash
export DEFAULT_MODEL=gemma3:4b
export LLM_PROVIDER=ollama
python main.py  # Runs with local Ollama default

```

## Summary

- **Three variables** control LLM configuration: `DEFAULT_MODEL`, `LLM_PROVIDER`, and `GEMINI_API_KEY`.
- Defaults fallback to **Ollama** with the **gemma3:4b** model when variables are unset.
- **GEMINI_API_KEY** is mandatory only when using the Gemini provider.
- All configuration logic resides in **[`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py)**, which validates providers against the **`ModelProvider`** enum in [`models.py`](https://github.com/interviewstreet/hiring-agent/blob/main/models.py).

## Frequently Asked Questions

### What happens if I don't set any environment variables?

The application runs using built-in defaults. According to the source code in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py), it defaults to `DEFAULT_MODEL_NAME` ("gemma3:4b") and `DEFAULT_PROVIDER.value` ("ollama"), connecting to a local Ollama instance without requiring any API credentials.

### Is GEMINI_API_KEY required for all providers?

No. The `GEMINI_API_KEY` variable is only required when **LLM_PROVIDER** is explicitly set to `gemini`. When using the default Ollama provider or any other future provider that does not require authentication, this variable can remain unset or empty.

### Where is the provider validation logic located?

Provider validation occurs in **[`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py)**, where the code checks if the **LLM_PROVIDER** value exists within the list of valid providers defined in the **`ModelProvider`** enum (located in [`models.py`](https://github.com/interviewstreet/hiring-agent/blob/main/models.py)). If the provided value is invalid, the system falls back to the default Ollama provider.

### Can I use other LLM providers beyond Ollama and Gemini?

The current implementation in [`models.py`](https://github.com/interviewstreet/hiring-agent/blob/main/models.py) defines the **`ModelProvider`** enum with specific values for Ollama and Gemini. While the architecture supports extension, adding new providers requires modifying the enum in [`models.py`](https://github.com/interviewstreet/hiring-agent/blob/main/models.py) and implementing the corresponding logic in [`prompt.py`](https://github.com/interviewstreet/hiring-agent/blob/main/prompt.py) to handle that provider's specific configuration and authentication requirements.