Module factory
Expand description
Per-family construction dispatch for model providers.
Each <Family>ModelProviderConfig typed slot from
zeroclaw-config::providers::ModelProviders declares its own construction
via one of two traits:
-
CompatFamilySpecfor OpenAI-compatible families. DeclareDISPLAY/DEFAULT_URL/AUTH; the blanketimpl<T: CompatFamilySpec> FamilyProviderFactory for Tproduces the provider. Families with minor modifiers (.without_native_tools(),.models_dev_key(...), multi-endpoint URI fallback) overridebuild_compat— still one place per family, no flat dispatch arm. -
FamilyProviderFactorydirectly for bespoke families that wrap a non-compat runtime provider (azure,gemini,openrouter,bedrock,anthropic, …).
Dispatch is generated by for_each_model_provider_slot! — the same
macro that defines the typed slots is the only place the family list
lives. Adding a family is one slot row plus one trait impl; missing the
impl fails to compile when the dispatch is generated.
Traits§
- Compat
Family Spec - Spec trait for OpenAI-compatible families. Implementing this gives a
FamilyProviderFactoryimpl for free via the blanket below. - Family
Provider Factory
Functions§
- apply_
compat_ options - Apply cross-cutting compat overrides (timeout, headers, api_path,
max_tokens, reasoning effort, TLS CA,
provider_extra) to a compat builder before calling.build()and boxing the trait object. Single source of the override chain — every compat impl funnels through here. - dispatch_
family_ factory - get_
default_ url - Get the default API URL for a provider type (matches CompatFamilySpec::DEFAULT_URL). Returns None if the provider type is not an OpenAI-compatible family with a DEFAULT_URL const.