Configuration & Provider Registry¶
config.config¶
Script¶
config.py
Purpose¶
Unified configuration management for Hillstar.
Handles: - Loading default registry from provider_registry.default.json - Merging user overrides from user config - Validating provider configurations against registry schema - Compliance checks for provider configurations - Managing user-level API keys and settings
Author: Julen Gamboa <julen.gamboa.ds@gmail.com>
Created¶
2026-02-07
Last Edited¶
2026-02-22
- class config.config.HillstarConfig[source]¶
Bases:
objectUnified configuration management for Hillstar.
Combines registry-based provider configuration with user-level API key management. Provides methods for: - Loading and merging configurations - Validating provider configurations - Managing user API keys and settings - Checking compliance requirements
- USER_CONFIG_DIR = PosixPath('/home/runner/.hillstar')¶
- USER_CONFIG_FILE = PosixPath('/home/runner/.hillstar/provider_registry.json')¶
- USER_OVERRIDE_PATH = PosixPath('/home/runner/.hillstar/provider_registry.json')¶
- set_provider_key(provider, api_key)[source]¶
Store API key for a provider.
- Parameters:
- Raises:
ValueError – If provider name or api_key is empty
- Return type:
None
- validate_key(provider, api_key)[source]¶
Validate that an API key is non-empty and reasonably formatted.
This is basic validation (non-empty, reasonable length). Full validation (API call) deferred to runtime.
- save_config()[source]¶
Write configuration to ~/.hillstar/provider_registry.json.
Creates the directory if it doesn’t exist.
- Raises:
IOError – If unable to write file
- Return type:
None
- load_config()[source]¶
Load configuration from ~/.hillstar/provider_registry.json.
Creates empty config if file doesn’t exist.
- Return type:
None
- validate_provider_config(provider, config)[source]¶
Validate provider configuration against registry.
config.model_selector¶
config.provider_registry¶
Script¶
provider_registry.py
Path¶
python/hillstar/config/provider_registry.py
Purpose¶
Provider Registry: Central registry for LLM providers, models, and compliance rules.
Provides a ProviderRegistry class that loads provider configurations from JSON and provides lookup methods for model selection, cost estimation, and compliance verification. Supports package defaults with user overrides for customization.
Inputs¶
Provider registry JSON files (default + optional user override)
Outputs¶
Registry instance with lookup methods for providers, models, and compliance
Assumptions¶
Default registry file exists at package location
User override follows same schema as default
Parameters¶
None (per-query)
Failure Modes¶
Missing default registry FileNotFoundError
Malformed JSON JSONDecodeError
Invalid provider/model Returns None
Author: Julen Gamboa <julen.gamboa.ds@gmail.com>
Created¶
2026-02-14
Last Edited¶
2026-02-14 (initial implementation)
- class config.provider_registry.ProviderRegistry[source]¶
Bases:
objectLoad and query the provider registry with fallback to user overrides.
The registry is loaded from: 1. Package default: python/hillstar/config/provider_registry.default.json 2. User override: ~/.hillstar/provider_registry.json (optional)
- DEFAULT_REGISTRY_PATH = PosixPath('/home/runner/work/hillstar-orchestrator/hillstar-orchestrator/config/provider_registry.default.json')¶
- USER_OVERRIDE_PATH = PosixPath('/home/runner/.hillstar/provider_registry.json')¶
- __init__(custom_registry_path=None)[source]¶
Initialize the provider registry.
- Parameters:
custom_registry_path (str | None) – Optional path to a custom registry file.
provided (If)
override. (this takes precedence over both default and user)
- find_models(capabilities=None, max_tier=None, provider_type=None, require_ollama=None)[source]¶
Find models matching criteria.
- Parameters:
capabilities (List[str] | None) – List of required capabilities (e.g., [“coding”, “reasoning”])
max_tier (str | None) – Maximum cost tier (e.g., “cheap”, “standard”)
provider_type (str | None) – Filter by provider type (e.g., “cloud_api”, “local”)
require_ollama (bool | None) – If True, only return models requiring Ollama
- Returns:
List of matching model configs with provider context
- Return type:
- get_cheapest_model(capabilities=None, provider_preference=None)[source]¶
Get the cheapest model matching criteria, respecting provider preference.
- estimate_cost(provider_name, model_id, input_tokens, output_tokens)[source]¶
Estimate cost for a model call.
- get_fallback_chain(complexity, provider_preference=None)[source]¶
Get provider fallback chain for a complexity level.
- is_usage_compliant(provider_name, use_case)[source]¶
Check if a use case is compliant for a provider.
- get_model_sampling_params(provider_name, model_id)[source]¶
Get default sampling parameters for a model.