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(),.with_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 - Per-family construction trait. Implemented (directly or via the
CompatFamilySpecblanket) by every typed<Family>ModelProviderConfig.
Functions§
- apply_
compat_ options - Apply cross-cutting compat post-processing (timeout, headers, api_path, max_tokens, reasoning effort) to a freshly-constructed compat provider and box it for trait-object dispatch. Single source of the post-process chain — every compat impl funnels through here.
- dispatch_
family_ factory - Dispatch family construction by routing
(family, alias)to the typed slot’sFamilyProviderFactoryimpl. Generated fromfor_each_model_provider_slot!so the family list lives in exactly one place — adding a row to the slot macro requires a corresponding impl, caught at compile time when the macro expands.