Environment Variables to Configure Provider Selection and API Keys in Hiring-Agent
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 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.
LLM_PROVIDER
The LLM_PROVIDER variable selects which backend handles inference. At line 21 of 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 and 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 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, it defaults to an empty string (""). When 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. 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 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 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:
# 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:
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:
export DEFAULT_MODEL=mistral:7b
python -m main
Accessing Configuration Programmatically
Import the constants directly from prompt.py to inspect the current configuration:
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 |
Reads environment variables at lines 20, 21, and 67; defines MODEL_PROVIDER_MAPPING and provider enum validation. |
llm_utils.py |
Consumes PROVIDER, DEFAULT_MODEL, and GEMINI_API_KEY to instantiate the correct LLM client. |
evaluator.py |
Executes evaluation tasks using the provider configuration imported from prompt.py. |
.env.example |
Template file documenting the expected environment variables for developer setups. |
Summary
LLM_PROVIDERselects the backend (Ollama or Gemini) and defaults to"ollama"if unset.DEFAULT_MODELsets the specific model name (e.g.,gemma3:4b,gemini-2.5-pro) and is resolved throughMODEL_PROVIDER_MAPPING.GEMINI_API_KEYprovides authentication for the Gemini provider and must be set when using that backend.- All variables are read in
prompt.pyand consumed byllm_utils.pyandevaluator.pyto 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 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 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 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 to handle the client initialization.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →