pub struct Model { /* private fields */ }Expand description
The public model type.
A Model may represent either a group of variants (as returned by
Catalog::get_model) or a single variant (as
returned by Catalog::get_model_variant
or Model::variants).
Implementations§
Source§impl Model
impl Model
Sourcepub fn info(&self) -> Result<ModelInfo, FoundryLocalError>
pub fn info(&self) -> Result<ModelInfo, FoundryLocalError>
Full catalog metadata for the (selected) variant.
The native model is the source of truth. Each call returns a fresh point-in-time snapshot so cache state remains correct after download or removal.
Sourcepub fn context_length(&self) -> Option<u64>
pub fn context_length(&self) -> Option<u64>
Maximum context length (in tokens), or None if unknown.
Sourcepub fn input_modalities(&self) -> Option<&str>
pub fn input_modalities(&self) -> Option<&str>
Comma-separated input modalities (e.g. "text,image"), or None.
Sourcepub fn output_modalities(&self) -> Option<&str>
pub fn output_modalities(&self) -> Option<&str>
Comma-separated output modalities (e.g. "text"), or None.
Sourcepub fn capabilities(&self) -> Option<&str>
pub fn capabilities(&self) -> Option<&str>
Capability tags (e.g. "reasoning"), or None.
Sourcepub fn supports_tool_calling(&self) -> Option<bool>
pub fn supports_tool_calling(&self) -> Option<bool>
Whether the model supports tool/function calling, or None.
Sourcepub async fn is_cached(&self) -> Result<bool, FoundryLocalError>
pub async fn is_cached(&self) -> Result<bool, FoundryLocalError>
Whether the (selected) variant is cached on disk.
Sourcepub async fn is_loaded(&self) -> Result<bool, FoundryLocalError>
pub async fn is_loaded(&self) -> Result<bool, FoundryLocalError>
Whether the (selected) variant is loaded into memory.
Sourcepub async fn download<F>(
&self,
progress: Option<F>,
) -> Result<(), FoundryLocalError>
pub async fn download<F>( &self, progress: Option<F>, ) -> Result<(), FoundryLocalError>
Download the (selected) variant. If progress is provided it
receives download progress as a percentage (0.0–100.0).
Sourcepub fn download_builder(&self) -> DownloadBuilder<'_>
pub fn download_builder(&self) -> DownloadBuilder<'_>
Configure and run a model download with a builder.
Use this for call sites that need progress, cancellation, or future download options.
Sourcepub async fn path(&self) -> Result<PathBuf, FoundryLocalError>
pub async fn path(&self) -> Result<PathBuf, FoundryLocalError>
Return the local file-system path of the (selected) variant.
Sourcepub async fn load(&self) -> Result<(), FoundryLocalError>
pub async fn load(&self) -> Result<(), FoundryLocalError>
Load the (selected) variant into memory.
Sourcepub async fn unload(&self) -> Result<(), FoundryLocalError>
pub async fn unload(&self) -> Result<(), FoundryLocalError>
Unload the (selected) variant from memory.
Sourcepub async fn remove_from_cache(&self) -> Result<(), FoundryLocalError>
pub async fn remove_from_cache(&self) -> Result<(), FoundryLocalError>
Remove the (selected) variant from the local cache.
Sourcepub fn create_chat_client(&self) -> ChatClient
👎Deprecated since 2.0.0: The OpenAI direct clients are deprecated; use ChatSession::new(&model) instead.
pub fn create_chat_client(&self) -> ChatClient
The OpenAI direct clients are deprecated; use ChatSession::new(&model) instead.
Create a ChatClient bound to the (selected) variant.
Sourcepub fn create_audio_client(&self) -> AudioClient
👎Deprecated since 2.0.0: The OpenAI direct clients are deprecated; use AudioSession::new(&model) instead.
pub fn create_audio_client(&self) -> AudioClient
The OpenAI direct clients are deprecated; use AudioSession::new(&model) instead.
Create an AudioClient bound to the (selected) variant.
Sourcepub fn create_embedding_client(&self) -> EmbeddingClient
👎Deprecated since 2.0.0: The OpenAI direct clients are deprecated; use EmbeddingsSession::new(&model) instead.
pub fn create_embedding_client(&self) -> EmbeddingClient
The OpenAI direct clients are deprecated; use EmbeddingsSession::new(&model) instead.
Create an EmbeddingClient bound to the (selected) variant.
Sourcepub fn variants(&self) -> Vec<Arc<Model>>
pub fn variants(&self) -> Vec<Arc<Model>>
Available variants of this model.
For a single-variant model (e.g. from
Catalog::get_model_variant),
this returns a single-element list containing itself.
Sourcepub fn select_variant(&self, variant: &Model) -> Result<(), FoundryLocalError>
pub fn select_variant(&self, variant: &Model) -> Result<(), FoundryLocalError>
Select a variant to use for subsequent operations.
The variant must be one of the models returned by variants.
§Errors
Returns an error if the variant does not belong to this model.
For single-variant models this always returns an error — use
Catalog::get_model to obtain a model
with all variants available.
Sourcepub fn select_variant_by_id(&self, id: &str) -> Result<(), FoundryLocalError>
pub fn select_variant_by_id(&self, id: &str) -> Result<(), FoundryLocalError>
Select a variant by its unique id string.
This is a convenience method for cases where you have a variant id
from an external source. Prefer select_variant
when you already have a Model reference from variants.
§Errors
Returns an error if no variant with the given id exists.
For single-variant models this always returns an error — use
Catalog::get_model to obtain a model
with all variants available.