Configuration Layers
VoiceGateway merges configuration from three sources with a clear priority order. This allows base configuration in YAML, dynamic management via the dashboard/MCP, and environment-level overrides.Priority Order
ConfigManager
File:src/voicegateway/core/config_manager.py
The ConfigManager is responsible for merging YAML and SQLite sources into a single GatewayConfig.
Merge Rules
The key rule is: YAML always takes precedence. If a provider, model, or project exists in both YAML and SQLite, the YAML version wins.The source Field
Each ProjectConfig carries a source field indicating where it came from:
source Value | Meaning |
|---|---|
"yaml" | Defined in voicegw.yaml |
"db" | Created via dashboard or MCP, stored in managed_projects |
_source key is injected into the config dict:
YAML Configuration
File:src/voicegateway/core/config.py
Environment Variable Substitution
YAML values containing${ENV_VAR} are replaced with the corresponding environment variable at load time:
Config File Search
When no explicit path is provided:- Check
VOICEGW_CONFIGenv var. - Search these paths in order:
./voicegw.yaml~/.config/voicegateway/voicegw.yaml/etc/voicegateway/voicegw.yaml
Pydantic Validation
File:src/voicegateway/core/schema.py
Before parsing, the raw YAML dict is validated against a Pydantic model (VoiceGatewayConfig). Validation errors are formatted with field paths and messages:
GatewayConfig Dataclass
The parsed config is stored as aGatewayConfig dataclass with these fields:
| Field | Type | Description |
|---|---|---|
providers | dict[str, dict] | Provider configs keyed by name |
models | dict[str, dict[str, dict]] | Models keyed by modality, then model ID |
fallbacks | dict[str, list[str]] | Fallback chains per modality |
cost_tracking | dict | DB path, enabled flag |
latency | dict | TTFB warning threshold |
rate_limits | dict[str, dict] | RPM limits per provider |
dashboard | dict | Dashboard config |
projects | dict[str, ProjectConfig] | Project configs |
stacks | dict[str, dict[str, str]] | Named model bundles |
observability | dict | Feature flags for tracking |