IModel
April 22, 2026 ยท View on GitHub
Namespace: Microsoft.AI.Foundry.Local
public interface IModel
Attributes NullableContextAttribute
Properties
Id
public abstract string Id { get; }
Property Value
Alias
public abstract string Alias { get; }
Property Value
Info
public abstract ModelInfo Info { get; }
Property Value
Variants
Variants of the model that are available. Variants of the model are optimized for different devices.
public abstract IReadOnlyList<IModel> Variants { get; }
Property Value
Methods
IsCachedAsync(Nullable<CancellationToken>)
Task<bool> IsCachedAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Returns
IsLoadedAsync(Nullable<CancellationToken>)
Task<bool> IsLoadedAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Returns
DownloadAsync(Action<Single>, Nullable<CancellationToken>)
Download the model to local cache if not already present.
Task DownloadAsync(Action<float> downloadProgress, Nullable<CancellationToken> ct)
Parameters
downloadProgress Action<Single>
Optional progress callback for download progress.
Percentage download (0 - 100.0) is reported.
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
GetPathAsync(Nullable<CancellationToken>)
Gets the model path if cached.
Task<string> GetPathAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<String>
Path of model directory.
LoadAsync(Nullable<CancellationToken>)
Load the model into memory if not already loaded.
Task LoadAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
RemoveFromCacheAsync(Nullable<CancellationToken>)
Remove the model from the local cache.
Task RemoveFromCacheAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
UnloadAsync(Nullable<CancellationToken>)
Unload the model if loaded.
Task UnloadAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
GetChatClientAsync(Nullable<CancellationToken>)
Get an OpenAI API based ChatClient
Task<OpenAIChatClient> GetChatClientAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<OpenAIChatClient>
OpenAI.ChatClient
GetAudioClientAsync(Nullable<CancellationToken>)
Get an OpenAI API based AudioClient
Task<OpenAIAudioClient> GetAudioClientAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<OpenAIAudioClient>
OpenAI.AudioClient
GetEmbeddingClientAsync(Nullable<CancellationToken>)
Get an OpenAI API based EmbeddingClient
Task<OpenAIEmbeddingClient> GetEmbeddingClientAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<OpenAIEmbeddingClient>
OpenAI.EmbeddingClient
SelectVariant(IModel)
Select a model variant from IModel.Variants to use for IModel operations.
An IModel from Variants can also be used directly.
void SelectVariant(IModel variant)
Parameters
variant IModel
Model variant to select. Must be one of the variants in IModel.Variants.
Exceptions
FoundryLocalException
If variant is not valid for this model.