FoundryLocalManager
May 27, 2026 · View on GitHub
Namespace: Microsoft.AI.Foundry.Local
public class FoundryLocalManager : System.IDisposable
Inheritance Object → FoundryLocalManager
Implements IDisposable
Attributes NullableContextAttribute, NullableAttribute
Properties
IsInitialized
public static bool IsInitialized { get; }
Property Value
Instance
public static FoundryLocalManager Instance { get; }
Property Value
Urls
Bound Urls if the web service has been started. Null otherwise. See FoundryLocalManager.StartWebServiceAsync(Nullable<CancellationToken>).
public String[] Urls { get; private set; }
Property Value
Methods
CreateAsync(Configuration, ILogger, Nullable<CancellationToken>)
Create the FoundryLocalManager singleton instance.
public static Task CreateAsync(Configuration configuration, ILogger logger, Nullable<CancellationToken> ct)
Parameters
configuration Configuration
Configuration to use.
logger ILogger
Application logger to use.
Use Microsoft.Extensions.Logging.NullLogger.Instance if you wish to ignore log output from the SDK.
ct Nullable<CancellationToken>
Optional cancellation token for the initialization.
Returns
Task
Task creating the instance.
Exceptions
GetCatalogAsync(Nullable<CancellationToken>)
Get the model catalog instance.
public Task<ICatalog> GetCatalogAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<ICatalog>
The model catalog.
Remarks:
The catalog is populated on first use and returns models based on currently available execution providers. To ensure all hardware-accelerated models are listed, call FoundryLocalManager.DownloadAndRegisterEpsAsync(Nullable<CancellationToken>) first to register execution providers, then access the catalog.
StartWebServiceAsync(Nullable<CancellationToken>)
Start the optional web service. This will provide an OpenAI-compatible REST endpoint that supports /v1/chat_completions /v1/models to list downloaded models /v1/models/{model_id} to get model details
FoundryLocalManager.Urls is populated with the actual bound Urls after startup.
public Task StartWebServiceAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task
Task starting the web service.
StopWebServiceAsync(Nullable<CancellationToken>)
Stops the web service if started.
public Task StopWebServiceAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task
Task stopping the web service.
DiscoverEps()
Discovers all available execution providers. Returns metadata about each EP including whether it is already registered.
public EpInfo[] DiscoverEps()
Returns
EpInfo[]
Array of EP info describing available EPs.
DownloadAndRegisterEpsAsync(Nullable<CancellationToken>)
Downloads and registers all available execution providers.
public Task<EpDownloadResult> DownloadAndRegisterEpsAsync(Nullable<CancellationToken> ct)
Parameters
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<EpDownloadResult>
Result describing which EPs succeeded and which failed.
Remarks:
Catalog and model requests use whatever EPs are currently registered and do not block on EP downloads. After downloading new EPs, re-fetch the model catalog to include models requiring the newly registered EPs.
DownloadAndRegisterEpsAsync(IEnumerable<String>, Nullable<CancellationToken>)
Downloads and registers the specified execution providers.
public Task<EpDownloadResult> DownloadAndRegisterEpsAsync(IEnumerable<string> names, Nullable<CancellationToken> ct)
Parameters
names IEnumerable<String>
Subset of EP names to download (as returned by FoundryLocalManager.DiscoverEps()).
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<EpDownloadResult>
Result describing which EPs succeeded and which failed.
Remarks:
Catalog and model requests use whatever EPs are currently registered and do not block on EP downloads. After downloading new EPs, re-fetch the model catalog to include models requiring the newly registered EPs.
DownloadAndRegisterEpsAsync(Action<String, Double>, Nullable<CancellationToken>)
Downloads and registers all available execution providers, reporting progress.
public Task<EpDownloadResult> DownloadAndRegisterEpsAsync(Action<string, double> progressCallback, Nullable<CancellationToken> ct)
Parameters
progressCallback Action<String, Double>
Callback invoked as each EP downloads. Parameters are (epName, percentComplete) where percentComplete is 0-100.
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<EpDownloadResult>
Result describing which EPs succeeded and which failed.
Remarks:
Catalog and model requests use whatever EPs are currently registered and do not block on EP downloads. After downloading new EPs, re-fetch the model catalog to include models requiring the newly registered EPs.
DownloadAndRegisterEpsAsync(IEnumerable<String>, Action<String, Double>, Nullable<CancellationToken>)
Downloads and registers the specified execution providers, reporting progress.
public Task<EpDownloadResult> DownloadAndRegisterEpsAsync(IEnumerable<string> names, Action<string, double> progressCallback, Nullable<CancellationToken> ct)
Parameters
names IEnumerable<String>
Subset of EP names to download (as returned by FoundryLocalManager.DiscoverEps()).
progressCallback Action<String, Double>
Callback invoked as each EP downloads. Parameters are (epName, percentComplete) where percentComplete is 0-100.
ct Nullable<CancellationToken>
Optional cancellation token.
Returns
Task<EpDownloadResult>
Result describing which EPs succeeded and which failed.
Remarks:
Catalog and model requests use whatever EPs are currently registered and do not block on EP downloads. After downloading new EPs, re-fetch the model catalog to include models requiring the newly registered EPs.
Dispose(Boolean)
protected void Dispose(bool disposing)
Parameters
disposing Boolean
Dispose()
public void Dispose()