Skip to main content

Module providers

Module providers 

Source
Expand description

Static vendor preset catalog, embedded at compile time.

Structs§

ModelPricingSpec
Per-million-token pricing embedded in a provider preset model entry. USD.
ModelSpec
A single model entry within a provider preset.
ProviderPreset
WrittenPreset
Result of writing a user override preset — returned to the caller so recursive init and recursive providers add can show the user exactly where the file landed and what was written.

Functions§

additional_presets
User-supplied presets loaded from <user_data_dir>/providers.d/*.toml. Returned in stable order (lexicographic by file name so unit tests can pin a specific order).
all_presets
all_presets_dynamic
All presets: bundled + user overrides from providers.d/. Returns an owned Vec because user overrides are loaded at runtime, not at compile time, so we cannot hand back &'static references. Use find_preset_extended when you only need to look one up.
all_presets_effective
All presets: remote cache + bundled + providers.d/. Returns an owned Vec because the cache and user overrides are loaded at runtime. Use find_preset_effective / find_model_pricing_effective when you only need to look one up.
bundled_presets
Bundled presets only. Same data as all_presets — kept as a separate function so call sites that need only the compile-time catalog can spell that intent out and avoid the disk-touching additional_presets work. Implemented as a thin alias so the OnceLock / expect site stays in all_presets (its pre-Goal-254 home) and does not show up as a new expect in the Goal 254 diff.
find_model_pricing
Look up pricing for a model name across all presets. Returns None if the model is not listed or has no pricing field.
find_model_pricing_effective
Look up pricing for a model name across the effective catalog (remote cache + bundled + providers.d/). This is the path used by pricing_for so per-token cost reflects upstream catalog refreshes, not just the compile-time providers.toml. Owned result.
find_preset
find_preset_by_api_base
Look up a preset by its API base URL. Used to recover the preset id from a config file that only stores api_base (e.g. recursive config show) and to pick sensible defaults in the manual branch of recursive init instead of guessing the model from URL substrings.
find_preset_effective
Look up a preset by id in the effective catalog (remote cache + bundled + providers.d/). Owned result, since the effective catalog is a runtime-merged Vec.
find_preset_extended
Look up a preset by id in the extended catalog (bundled + user overrides). Preserves the strict, compiled-catalog-only semantics of find_preset for callers that depend on it (e.g. Config::from_env rejecting unknown preset ids at startup).
write_user_preset
Serialize preset to TOML and write it to <user_data_dir>/providers.d/<id>.toml. Creates the directory if missing. Used by recursive init’s “save as reusable preset?” path (init.rs) and by recursive providers add so the persistence surface lives in one place rather than being reimplemented at each caller.