Class ModelMetadataProvider
Fetches, caches, parses, and applies model metadata from LiteLLM's catalog. Fallback chain: fetched data -> cached data -> hardcoded record defaults.
public sealed class ModelMetadataProvider
- Inheritance
-
ModelMetadataProvider
- Inherited Members
Constructors
ModelMetadataProvider(IModelMetadataSource?)
public ModelMetadataProvider(IModelMetadataSource? source = null)
Parameters
sourceIModelMetadataSource
Properties
EntryCount
Number of parsed catalog entries.
public int EntryCount { get; }
Property Value
IsLoaded
Whether the catalog has been loaded.
public bool IsLoaded { get; }
Property Value
LastFetched
When the catalog was last fetched (from meta file).
public DateTime? LastFetched { get; }
Property Value
Methods
Enrich(IReadOnlyList<ProviderModelInfo>)
Enriches a list of models with metadata from the loaded catalog. Unmatched models are returned unchanged.
public IReadOnlyList<ProviderModelInfo> Enrich(IReadOnlyList<ProviderModelInfo> models)
Parameters
modelsIReadOnlyList<ProviderModelInfo>
Returns
GetEntriesSnapshot()
Returns a copy of the currently loaded metadata entries keyed by LiteLLM model key. Returns an empty dictionary when metadata has not been loaded.
public IReadOnlyDictionary<string, ModelMetadataEntry> GetEntriesSnapshot()
Returns
LoadAsync(bool, CancellationToken)
Loads model metadata. Tries cache first (within TTL), then fetches, then falls back to stale cache. Never throws.
public Task LoadAsync(bool forceRefresh = false, CancellationToken ct = default)
Parameters
forceRefreshboolctCancellationToken