downloadAsset( )
Downloads an asset (model file) without loading it into memory.
function downloadAsset(options): Promise<string>;Description
This function is specifically designed for download-only operations and doesn't accept runtime configuration options like modelConfig or delegate. Use this for download-only operations instead of loadModel for better semantic clarity.
Parameters
| Name | Type | Required? | Description |
|---|---|---|---|
| options | object | ✓ | Download configuration |
options
| Field | Type | Required? | Default | Description |
|---|---|---|---|---|
| assetSrc | string | ✓ | - | The location from which the asset is downloaded (local path, remote URL, or Hyperdrive URL) |
| seed | boolean | ✗ | false | Whether to seed the hyperdrive |
| onProgress | function | ✗ | - | Optional callback for download progress |
Returns
Promise<string> — Promise that resolves to the asset ID (either the provided assetSrc or a generated ID)
Throws
- When asset download fails, with details in the error message
- When streaming ends unexpectedly (only when using onProgress)
- When receiving an invalid response type from the server
Example
// Download model without loading
const assetId = await downloadAsset({
assetSrc: "/path/to/model.gguf",
seed: true
});
// Download with progress tracking
const assetId = await downloadAsset({
assetSrc: "pear://key123/model.gguf",
onProgress: (progress) => {
console.log(`Downloaded: ${progress.percentage}%`);
}
});