pub struct ModelRegistry { /* private fields */ }Expand description
Centralized model catalog with pricing, capabilities, and provider metadata.
Lookup order for pricing/model queries:
- Exact match on
"provider::model" - Fuzzy match — any registered model whose name is a substring of the query (or vice-versa), scoped to the same provider
- Provider-level default entry (cache multipliers only, via
get_pricing)
Implementations§
Source§impl ModelRegistry
impl ModelRegistry
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a registry pre-loaded with the embedded defaults.
Sourcepub fn register(&mut self, provider: &str, model_id: &str, info: ModelInfo)
pub fn register(&mut self, provider: &str, model_id: &str, info: ModelInfo)
Register a single model dynamically (e.g. from Ollama discovery).
Sourcepub fn get_fuzzy(&self, provider: &str, model: &str) -> Option<&ModelInfo>
pub fn get_fuzzy(&self, provider: &str, model: &str) -> Option<&ModelInfo>
Fuzzy lookup: tries exact match first, then substring matching against all models for the given provider.
Sourcepub fn get_pricing(&self, provider: &str, model: &str) -> Option<CostRates>
pub fn get_pricing(&self, provider: &str, model: &str) -> Option<CostRates>
Get pricing for a model (convenience wrapper returning just CostRates).
Falls back to provider-level cache multipliers for unknown models.
Sourcepub fn provider(&self, name: &str) -> Option<&ProviderInfo>
pub fn provider(&self, name: &str) -> Option<&ProviderInfo>
Get provider metadata.
Sourcepub fn provider_names(&self) -> Vec<&str>
pub fn provider_names(&self) -> Vec<&str>
List all known provider names, sorted alphabetically.
Sourcepub fn default_model(&self, provider: &str) -> Option<&str>
pub fn default_model(&self, provider: &str) -> Option<&str>
Get the default model for a provider.
Sourcepub fn api_key_env(&self, provider: &str) -> Option<&str>
pub fn api_key_env(&self, provider: &str) -> Option<&str>
Get the API key env var for a provider.
Sourcepub fn models_for_provider(&self, provider: &str) -> Vec<&str>
pub fn models_for_provider(&self, provider: &str) -> Vec<&str>
List all model IDs for a provider, sorted alphabetically.
Trait Implementations§
Source§impl Clone for ModelRegistry
impl Clone for ModelRegistry
Source§fn clone(&self) -> ModelRegistry
fn clone(&self) -> ModelRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModelRegistry
impl Debug for ModelRegistry
Auto Trait Implementations§
impl Freeze for ModelRegistry
impl RefUnwindSafe for ModelRegistry
impl Send for ModelRegistry
impl Sync for ModelRegistry
impl Unpin for ModelRegistry
impl UnsafeUnpin for ModelRegistry
impl UnwindSafe for ModelRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.