Skip to main content

EdgeModelKit API reference

EdgeModelKit contains helpers for model download, cache management, and device-tier selection.

HFDownloader

public final class HFDownloader: NSObject

Downloads registered models into the local model cache.

APIDescription
HFDownloader.sharedShared downloader instance.
download(config:progress:)Downloads files for a ModelConfig.
cancel(modelID:)Cancels an active download for a model ID.

Example:

try await HFDownloader.shared.download(config: config) { progress in
print(progress)
}

ModelCache

public final class ModelCache

Manages the local model cache directory.

APIDescription
ModelCache.sharedShared cache manager.
cachedURL(for:)Returns the local cache URL for a model config.
isCached(_:)Checks whether the model directory exists.
cacheSize(for:)Returns byte size for one model directory.
totalCacheSize()Returns total cache byte size.
evict(_:)Removes one cached model.
evictAll()Removes all cached models.

ModelTierManager

public final class ModelTierManager: ObservableObject

Selects a model tier for the current device.

Property or methodDescription
ModelTierManager.sharedShared tier manager.
currentTierCurrent recommended or selected tier.
availableTiersTiers available on this device.
refresh()Recomputes available tiers.
select(tier:)Selects an available tier.
currentConfigModelConfig for the current tier.

ModelTier

public enum ModelTier: String, CaseIterable, Sendable
CaseIntended use
.standardSmaller models for broad device support.
.proMid-sized models.
.maxLarger models for higher-memory devices.
.ultraHighest local tier for validated devices.