pub struct CliModelRegistry { /* private fields */ }Expand description
CLI-specific model registry with auth storage integration.
This extends the base model data from oxi_ai::model_db with:
- API key resolution via
AuthStorage models.jsonfile parsing- OAuth token detection
- Available model filtering (only models with configured auth)
For SDK usage without CLI-specific features, use oxi_ai::ModelRegistry instead.
Implementations§
Source§impl CliModelRegistry
impl CliModelRegistry
Sourcepub fn create(
auth_storage: AuthStorage,
models_json_path: Option<PathBuf>,
) -> CliModelRegistry
pub fn create( auth_storage: AuthStorage, models_json_path: Option<PathBuf>, ) -> CliModelRegistry
Create a new ModelRegistry that loads models from the given path.
If models_json_path is None, falls back to
$HOME/.oxi/models.json (or the XDG config dir equivalent).
Sourcepub fn in_memory(auth_storage: AuthStorage) -> CliModelRegistry
pub fn in_memory(auth_storage: AuthStorage) -> CliModelRegistry
Create an in-memory registry (no models.json loading).
Sourcepub fn get_available(&self) -> Vec<Model>
pub fn get_available(&self) -> Vec<Model>
Get only models that have auth configured.
Sourcepub fn find(&self, provider: &str, model_id: &str) -> Option<Model>
pub fn find(&self, provider: &str, model_id: &str) -> Option<Model>
Find a model by provider and ID.
Sourcepub fn resolve_model(&self, model_str: &str) -> Option<Model>
pub fn resolve_model(&self, model_str: &str) -> Option<Model>
Resolve a model string (e.g. "anthropic/claude-sonnet-4-20250514")
into a Model object.
Supports:
"provider/model-id""model-id"(searches all providers)
Sourcepub fn has_configured_auth(&self, model: &Model) -> bool
pub fn has_configured_auth(&self, model: &Model) -> bool
Check if a model has auth configured.
Sourcepub fn get_api_key_and_headers(&self, model: &Model) -> ResolvedRequestAuth
pub fn get_api_key_and_headers(&self, model: &Model) -> ResolvedRequestAuth
Get API key and request headers for a model.
Sourcepub fn is_using_oauth(&self, model: &Model) -> bool
pub fn is_using_oauth(&self, model: &Model) -> bool
Check if a model is using OAuth credentials.
Sourcepub fn get_provider_display_name(&self, provider: &str) -> String
pub fn get_provider_display_name(&self, provider: &str) -> String
Get display name for a provider.
Returns a static string for known providers, or the raw provider string.
Sourcepub fn get_provider_display_name_owned(&self, provider: &str) -> String
pub fn get_provider_display_name_owned(&self, provider: &str) -> String
Get the display name for a provider, allocating if necessary for dynamically registered names.
Sourcepub fn get_provider_auth_status(&self, provider: &str) -> AuthStatus
pub fn get_provider_auth_status(&self, provider: &str) -> AuthStatus
Return auth status for a provider, including request auth configured in models.json.
Sourcepub fn get_api_key_for_provider(&self, provider: &str) -> Option<String>
pub fn get_api_key_for_provider(&self, provider: &str) -> Option<String>
Get API key for a provider.
Sourcepub fn get_available_providers(&self) -> Vec<String>
pub fn get_available_providers(&self) -> Vec<String>
Get all unique providers from loaded models.
Sourcepub fn get_providers_with_credentials(&self) -> Vec<String>
pub fn get_providers_with_credentials(&self) -> Vec<String>
Get all providers that have credentials configured.
Sourcepub fn get_available_models(&self) -> Vec<Model>
pub fn get_available_models(&self) -> Vec<Model>
Get all models that have credentials configured.
Sourcepub fn get_default_model(&self) -> Option<Model>
pub fn get_default_model(&self) -> Option<Model>
Get the user’s default model.
Returns the first available model, preferring:
- Anthropic Claude Sonnet 4
- OpenAI GPT-4o
- Any available model
Sourcepub fn register_provider(
&self,
provider_name: &str,
config: ProviderConfigInput,
)
pub fn register_provider( &self, provider_name: &str, config: ProviderConfigInput, )
Register a provider dynamically (from extensions).
Sourcepub fn unregister_provider(&self, provider_name: &str)
pub fn unregister_provider(&self, provider_name: &str)
Unregister a previously registered provider.
Sourcepub fn filter_by_provider(&self, provider: &str) -> Vec<Model>
pub fn filter_by_provider(&self, provider: &str) -> Vec<Model>
Filter models by provider.
Sourcepub fn filter_by_capability(&self, reasoning: bool) -> Vec<Model>
pub fn filter_by_capability(&self, reasoning: bool) -> Vec<Model>
Filter models by capability (reasoning).
Sourcepub fn filter_by_modality(&self, modality: InputModality) -> Vec<Model>
pub fn filter_by_modality(&self, modality: InputModality) -> Vec<Model>
Filter models by input modality (e.g., vision/image support).
Auto Trait Implementations§
impl !Freeze for CliModelRegistry
impl !RefUnwindSafe for CliModelRegistry
impl Send for CliModelRegistry
impl Sync for CliModelRegistry
impl Unpin for CliModelRegistry
impl UnsafeUnpin for CliModelRegistry
impl !UnwindSafe for CliModelRegistry
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§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>
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>
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 more