The LEAP SDK provides multiple model loading options:
LeapModelDownloader— Platform-specific downloader with background download support (Android: WorkManager + notifications; Apple: NSURLSession background downloads)LeapDownloader— Cross-platform (Android, iOS, macOS, JVM), lightweight downloader for all platformsLeap.load()— Swift convenience API via the compatibility layer
LeapModelDownloader
The recommended option for production apps on Android and Apple platforms. It provides platform-specific features for robust background downloads.
- Kotlin
- Swift
This class is part of the
ai.liquid.leap:leap-model-downloader module. It uses Android WorkManager for background downloads and displays foreground service notifications.Constructor Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
context | Context | Yes | - | Android context (Activity or Application) |
modelFileDir | File | No | null | Directory to save models. If null, uses app’s external files directory. |
extraHTTPRequestHeaders | Map<String, String> | No | mapOf() | Additional HTTP headers for download requests |
notificationConfig | LeapModelDownloaderNotificationConfig | No | LeapModelDownloaderNotificationConfig() | Notification configuration for the foreground service |
loadModel
Download and load a model in one operation. If the model is already cached, it loads directly without downloading.| Name | Type | Required | Default | Description |
|---|---|---|---|---|
modelSlug | String | Yes | - | The model name (e.g., “LFM2-1.2B”). See the LEAP Model Library. |
quantizationSlug | String | Yes | - | The quantization level (e.g., “Q4_K_M”, “Q5_K_M”). |
modelLoadingOptions | ModelLoadingOptions | No | null | Options for loading the model. See ModelLoadingOptions. |
generationTimeParameters | GenerationTimeParameters | No | null | Parameters to control generation. See GenerationTimeParameters. |
progress | (ProgressData) -> Unit | No | {} | Callback for download progress updates |
ModelRunner instance.downloadModel
Download a model without loading it into memory. Useful for pre-downloading models in the background.| Name | Type | Required | Default | Description |
|---|---|---|---|---|
modelSlug | String | Yes | - | The model name |
quantizationSlug | String | Yes | - | The quantization level |
progress | (ProgressData) -> Unit | No | {} | Callback for download progress |
Manifest metadata about the downloaded model.Example
Leap.load() (Swift)
Leap is the static entry point for loading models on Apple platforms via the Swift compatibility layer.
Leap.load(model:quantization:options:downloadProgressHandler:)
Download a model from the LEAP Model Library and load it into memory. If already downloaded, it loads from the local cache.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model | String | Yes | - | The model name. See the LEAP Model Library. |
quantization | String | Yes | - | The quantization level. |
options | LiquidInferenceEngineManifestOptions | No | nil | Override options for loading (advanced). |
downloadProgressHandler | (Double, Int64) -> Void | No | nil | Progress callback (0–1 fraction, bytes/sec). |
ModelRunner instance.
Legacy: Leap.load(url:options:)
Legacy: Leap.load(url:options:)
Load a local model file (
.bundle or .gguf) directly:LiquidInferenceEngineOptions
Override runtime configuration when loading from a local file:
cpuThreads: Number of CPU threads for token generation.contextSize: Override maximum context length.nGpuLayers: Layers to offload to GPU (macOS/Mac Catalyst with Metal).mmProjPath: Auxiliary multimodal projection model path. Leavenilto auto-detectmmproj-*.gguf.audioDecoderPath: Audio decoder model. Leavenilto auto-detect.
LeapDownloader (Cross-Platform)
A lightweight, cross-platform model loader available in the core leap-sdk module. Works on all platforms (Android, iOS, macOS, JVM).
loadModel
Download and load a model. If already cached, loads from the local cache.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
modelSlug | String | Yes | - | The model name. See the LEAP Model Library. |
quantizationSlug | String | Yes | - | The quantization level. |
modelLoadingOptions | ModelLoadingOptions | No | null | Options for loading. See ModelLoadingOptions. |
generationTimeParameters | GenerationTimeParameters | No | null | Generation parameters. See GenerationTimeParameters. |
progress | (ProgressData) -> Unit | No | {} | Download progress callback. |
ModelRunner instance.
downloadModel
Download a model without loading it into memory.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
modelSlug | String | Yes | - | The model name. |
quantizationSlug | String | Yes | - | The quantization level. |
progress | (ProgressData) -> Unit | No | {} | Download progress callback. |
Manifest metadata about the downloaded model.
Supporting Types
LeapDownloaderConfig
GenerationTimeParameters
SamplingParameters
ProgressData
Manifest
ModelLoadingOptions
randomSeed: Set the random seed to reproduce output.cpuThreads: Number of threads for generation.
Legacy: LeapClient
Legacy: LeapClient
The
LeapClient class is a legacy entry point. Use LeapDownloader or LeapModelDownloader instead.