pub struct ProviderIndex { /* private fields */ }Expand description
Immutable provider catalog with O(1) lookup by id.
The catalog is compiled into the binary from catalog.json via include_str!.
Access it through ProviderIndex::embedded().
Implementations§
Source§impl ProviderIndex
impl ProviderIndex
Sourcepub fn embedded() -> &'static ProviderIndex
pub fn embedded() -> &'static ProviderIndex
Access the static catalog embedded at compile time.
Sourcepub fn all(&self) -> &[ServiceDescriptor]
pub fn all(&self) -> &[ServiceDescriptor]
Return all providers in catalog order.
Sourcepub fn get(&self, id: &str) -> Option<&ServiceDescriptor>
pub fn get(&self, id: &str) -> Option<&ServiceDescriptor>
Look up a provider by ID. O(1).
Sourcepub fn categories(&self) -> Vec<String>
pub fn categories(&self) -> Vec<String>
Unique categories in catalog order.
Sourcepub fn providers_by_category(&self, category: &str) -> Vec<&ServiceDescriptor>
pub fn providers_by_category(&self, category: &str) -> Vec<&ServiceDescriptor>
Filter providers by category.
Sourcepub fn builtin_secret_keys(&self) -> HashSet<String>
pub fn builtin_secret_keys(&self) -> HashSet<String>
Collect all secret key variable names from providers that require one.
Sourcepub fn models_for(&self, provider_id: &str) -> &[ModelDescriptor]
pub fn models_for(&self, provider_id: &str) -> &[ModelDescriptor]
Get models for a specific provider.
Sourcepub fn find_model(
&self,
model_id: &str,
) -> Option<(&ServiceDescriptor, &ModelDescriptor)>
pub fn find_model( &self, model_id: &str, ) -> Option<(&ServiceDescriptor, &ModelDescriptor)>
Find a model by ID across all providers. Returns the first match (provider, model).
Sourcepub fn estimate_cost(
&self,
model_id: &str,
prompt_tokens: u32,
completion_tokens: u32,
) -> Option<f64>
pub fn estimate_cost( &self, model_id: &str, prompt_tokens: u32, completion_tokens: u32, ) -> Option<f64>
Estimate the USD cost of an LLM call given token counts.
Looks up model_id across all providers and computes:
(input_price * prompt_tokens + output_price * completion_tokens) / 1_000_000
Returns None if the model is not found or has no pricing data.
Trait Implementations§
Source§impl Clone for ProviderIndex
impl Clone for ProviderIndex
Source§fn clone(&self) -> ProviderIndex
fn clone(&self) -> ProviderIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more