Assets

Access assets through client.assets in the Datature Vi SDK.

Assets are the image files stored inside a dataset. You upload them before adding annotations, download them for local processing, and delete them when they are no longer needed. The asset resource handles single files, folder batches, and async upload sessions.

Before You Start

Get started with the Vi SDK →


Methods

list()

List assets in a dataset.

assets = client.assets.list(dataset_id="dataset_abc123")

for asset in assets.items:
    print(f"{asset.filename}: {asset.metadata.width}x{asset.metadata.height}")
from vi.api.types import PaginationParams
from vi.api.resources.datasets.assets.types import (
    AssetSortCriterion,
    SortCriterion,
    SortOrder
)

pagination = PaginationParams(page_size=100)
sort_by = AssetSortCriterion(
    criterion=SortCriterion.FILENAME,
    order=SortOrder.ASC
)

for page in client.assets.list(
    dataset_id="dataset_abc123",
    pagination=pagination,
    sort_by=sort_by
):
    for asset in page.items:
        print(f"{asset.filename}")
assets = client.assets.list(
    dataset_id="dataset_abc123",
    contents=True
)

for asset in assets.items:
    if asset.contents and asset.contents.asset:
        print(f"{asset.filename}: {asset.contents.asset.url}")
assets = client.assets.list(
    dataset_id="dataset_abc123",
    metadata_query='custom_field == "value"'
)
Expected output
Output
image_001.jpg: 1920x1080 image_002.jpg: 3840x2160 image_003.jpg: 1280x720

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Dataset identifier.
Required
pagination
object
Pagination settings. See PaginationParams.
Optional
None
contents
boolean
Include pre-signed download URLs in the response.
Optional
false
sort_by
object
Sorting criteria. See AssetSortCriterion.
Optional
None
filter_criteria
string
Filter query string.
Optional
None
metadata_query
string
Metadata filter query.
Optional
None

Returns: PaginatedResponse[Asset]


get()

Get a specific asset.

asset = client.assets.get(
    dataset_id="dataset_abc123",
    asset_id="asset_xyz789"
)

print(f"Filename: {asset.filename}")
print(f"Size: {asset.metadata.file_size} bytes")
asset = client.assets.get(
    dataset_id="dataset_abc123",
    asset_id="asset_xyz789",
    contents=True
)

if asset.contents and asset.contents.asset:
    print(f"Download URL: {asset.contents.asset.url}")
    print(f"Expires: {asset.contents.asset.expiry}")
asset = client.assets.get(
    dataset_id="dataset_abc123",
    asset_id="asset_xyz789"
)
asset.info()  # Prints formatted asset summary
Expected output
Output
Filename: image_001.jpg Size: 245760 bytes

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Dataset identifier.
Required
asset_id
string
Asset identifier.
Required
contents
boolean
Include pre-signed download URL.
Optional
false

Returns: Asset


upload()

Upload assets to a dataset. Supports single files, multiple files, and entire directories.

result = client.assets.upload(
    dataset_id="dataset_abc123",
    paths="image.jpg",
    wait_until_done=True
)

print(f"Uploaded: {result.total_succeeded}")
result = client.assets.upload(
    dataset_id="dataset_abc123",
    paths="./images/",
    wait_until_done=True
)

print(f"Uploaded: {result.total_succeeded}")
print(f"Failed: {result.total_failed}")
print(result.summary())
result = client.assets.upload(
    dataset_id="dataset_abc123",
    paths=["image1.jpg", "image2.png", "image3.webp"],
    wait_until_done=True
)
from vi import ViUploadError, ViFileTooLargeError

try:
    result = client.assets.upload(
        dataset_id="dataset_abc123",
        paths="./images/",
        wait_until_done=True
    )

    print(f"Uploaded: {result.total_succeeded}")
    print(f"Failed: {result.total_failed}")

    if result.failed_files:
        print("Failed files:")
        for f in result.failed_files:
            print(f"  - {f}")

except ViFileTooLargeError as e:
    print(f"File too large: {e.message}")
except ViUploadError as e:
    print(f"Upload failed: {e.message}")
result = client.assets.upload(
    dataset_id="dataset_abc123",
    paths="./large_folder/",
    wait_until_done=False
)

# Save session IDs to check status later
print(f"Session IDs: {result.session_ids}")
Expected output
Output
Uploaded: 25 Failed: 0

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Dataset identifier.
Required
paths
string
File path, folder path, or list of file paths.
Required
wait_until_done
boolean
Block until all assets finish ingestion.
Optional
true
failure_mode
string
How to handle upload failures. See FailureMode enum.
Optional
FailAfterOne
on_asset_overwritten
string
What to do when an asset is overwritten. See ResourceRetentionMode enum.
Optional
RemoveLinkedResource

Returns: AssetUploadResult


download()

Download assets from a dataset to a local directory.

downloaded = client.assets.download(
    dataset_id="dataset_abc123",
    save_dir="./assets"
)
downloaded = client.assets.download(
    dataset_id="dataset_abc123",
    save_dir="./assets",
    overwrite=True,
    show_progress=True
)

print(f"Downloaded to: {downloaded}")

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Dataset identifier.
Required
save_dir
string
Local directory to save downloaded assets.
Required
overwrite
boolean
Overwrite existing files.
Optional
false
show_progress
boolean
Show progress bars.
Optional
true

Returns: AssetDownloadResult


delete()

Delete an asset from a dataset.

deleted = client.assets.delete(
    dataset_id="dataset_abc123",
    asset_id="asset_xyz789"
)
asset_ids = ["asset_1", "asset_2", "asset_3"]

for asset_id in asset_ids:
    client.assets.delete(
        dataset_id="dataset_abc123",
        asset_id=asset_id
    )
    print(f"Deleted: {asset_id}")

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Dataset identifier.
Required
asset_id
string
Asset identifier.
Required

Returns: DeletedAsset


wait_until_done()

Wait for an upload session to complete. Use this after an async upload (wait_until_done=False) to block until ingestion finishes.

status = client.assets.wait_until_done(
    dataset_id="dataset_abc123",
    asset_ingestion_session_id="session_id"
)

print(f"Succeeded: {status.status.progressCount.succeeded}")
print(f"Failed: {status.status.progressCount.errored}")
result = client.assets.upload(
    dataset_id="dataset_abc123",
    paths="./images/",
    wait_until_done=False
)

# Do other work...

# Then wait for each session to finish
for session_id in result.session_ids:
    status = client.assets.wait_until_done(
        dataset_id="dataset_abc123",
        asset_ingestion_session_id=session_id
    )
    print(f"Session {session_id}: {status.status.progressCount.succeeded} succeeded")

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Dataset identifier.
Required
asset_ingestion_session_id
string
Session identifier from the upload result.
Required

Returns: AssetIngestionSession


Supported file formats

Supported file formats

Name
Type
Description
Required
Default
JPEG
.jpg, .jpeg, .jfif
Optional
PNG
.png
Optional
TIFF
.tiff, .tif
Optional
BMP
.bmp
Optional
WebP
.webp
Optional
HEIF
.heif, .heic
Optional
AVIF
.avif
Optional
JPEG 2000
.jp2, .j2k
Optional
GIF
.gif
Optional

Response types

Asset

from vi.api.resources.datasets.assets.responses import Asset

Properties

Name
Type
Description
Required
Default
asset_id
string
Unique identifier
Optional
dataset_id
string
Parent dataset ID
Optional
organization_id
string
Organization ID
Optional
filename
string
Original filename
Optional
kind
string
Resource kind
Optional
owner
string
Owner identifier
Optional
metadata
object
Asset metadata (AssetMetadata)
Optional
self_link
string
API link
Optional
etag
string
Entity tag
Optional
contents
object
Download URLs, if requested (AssetContents)
Optional

Methods: info() → prints a formatted asset summary.


AssetMetadata

from vi.api.resources.datasets.assets.responses import AssetMetadata

Properties

Name
Type
Description
Required
Default
width
integer
Image width in pixels
Optional
height
integer
Image height in pixels
Optional
file_size
integer
File size in bytes
Optional
mime_type
string
MIME type
Optional
upload_status
string
Upload status
Optional
status
string
Processing status
Optional
frames
integer
Number of frames
Optional
visibility
string
Visibility setting
Optional
generations
object
Asset URLs (AssetGenerations)
Optional
annotations
object
Annotation info (AssetAnnotations)
Optional
dimensions
object
Dimension details (AssetDimensions)
Optional
pixel_ratio
object
Pixel ratio (AssetPixelRatio)
Optional
hash
object
File hash (AssetHash)
Optional
inserted_by
string
Uploader ID
Optional
cohorts
array
Cohort IDs
Optional
user_defined
object
User metadata
Optional
custom_metadata
object
Custom metadata
Optional
comments
integer
Comment count
Optional
time_created
integer
Creation timestamp
Optional
last_updated
integer
Update timestamp
Optional

AssetGenerations

from vi.api.resources.datasets.assets.responses import AssetGenerations

Properties

Name
Type
Description
Required
Default
asset
string
Full-size asset URL
Optional
thumbnail
string
Thumbnail URL
Optional

AssetAnnotations

from vi.api.resources.datasets.assets.responses import AssetAnnotations

Properties

Name
Type
Description
Required
Default
with_tag
object
Tag counts
Optional
total
integer
Total annotations
Optional

AssetDimensions

from vi.api.resources.datasets.assets.responses import AssetDimensions

Properties

Name
Type
Description
Required
Default
height
integer
Height in pixels
Optional
width
integer
Width in pixels
Optional
depth
integer
Depth (for 3D images)
Optional

AssetPixelRatio

from vi.api.resources.datasets.assets.responses import AssetPixelRatio

Properties

Name
Type
Description
Required
Default
height
integer
Height ratio
Optional
width
integer
Width ratio
Optional
depth
integer
Depth ratio
Optional

AssetHash

from vi.api.resources.datasets.assets.responses import AssetHash

Properties

Name
Type
Description
Required
Default
algorithm
string
Hash algorithm (e.g., sha256)
Optional
contents
string
Hash value
Optional

AssetContents

from vi.api.resources.datasets.assets.responses import AssetContents

Properties

Name
Type
Description
Required
Default
asset
object
Full asset URL info (Contents)
Optional
thumbnail
object
Thumbnail URL info (Contents)
Optional

Contents

from vi.api.resources.datasets.assets.responses import Contents

Properties

Name
Type
Description
Required
Default
url
string
Pre-signed URL
Optional
expiry
integer
Expiration timestamp
Optional
headers
object
Required headers
Optional
method
string
HTTP method
Optional

AssetUploadResult

Aggregates results from batched upload operations.

Properties

Name
Type
Description
Required
Default
total_files
integer
Total files processed
Optional
total_succeeded
integer
Successfully uploaded
Optional
total_failed
integer
Failed uploads
Optional
success_rate
number
Success percentage
Optional
sessions
array
Batch sessions
Optional
session_ids
array
Session IDs
Optional
failed_files
array
Failed file paths
Optional

Methods: summary() → returns a summary string.


AssetIngestionSession

from vi.api.resources.datasets.assets.responses import AssetIngestionSession

Properties

Name
Type
Description
Required
Default
organization_id
string
Organization ID
Optional
dataset_id
string
Dataset ID
Optional
asset_ingestion_session_id
string
Session identifier
Optional
asset_source_class
string
Source classification
Optional
asset_source_provider
string
Source provider
Optional
asset_source_id
string
Source identifier
Optional
self_link
string
API link
Optional
etag
string
Entity tag
Optional
metadata
object
Metadata
Optional
spec
object
Optional
status
object
Optional

AssetIngestionSessionSpec

from vi.api.resources.datasets.assets.responses import AssetIngestionSessionSpec

Properties

Name
Type
Description
Required
Default
kind
string
Resource kind
Optional
failureMode
object
Failure handling
Optional
onAssetOverwritten
object
Overwrite handling
Optional
assets
array
Assets being uploaded
Optional

AssetIngestionSessionStatus

from vi.api.resources.datasets.assets.responses import AssetIngestionSessionStatus

Properties

Name
Type
Description
Required
Default
conditions
array
Status conditions
Optional
events
array
Ingestion events
Optional
progressCount
object
Optional
assets
array
Assets being uploaded
Optional

AssetIngestionProgressCount

from vi.api.resources.datasets.assets.responses import AssetIngestionProgressCount

Properties

Name
Type
Description
Required
Default
total
integer
Total assets
Optional
succeeded
integer
Succeeded
Optional
errored
integer
Errored
Optional

UploadedAssetMetadata

from vi.api.resources.datasets.assets.responses import UploadedAssetMetadata

Properties

Name
Type
Description
Required
Default
kind
string
Resource kind
Optional
filename
string
File name
Optional
mime
string
MIME type
Optional
size
integer
Size in bytes
Optional
crc32c
integer
CRC32C checksum
Optional
custom_metadata
object
Custom metadata
Optional

AssetForUpload

from vi.api.resources.datasets.assets.responses import AssetForUpload

Properties

Name
Type
Description
Required
Default
metadata
object
Asset metadata (UploadedAssetMetadata)
Optional
upload
object
Upload URL info
Optional

Request types

AssetSortCriterion

from vi.api.resources.datasets.assets.types import AssetSortCriterion

Properties

Name
Type
Description
Required
Default
criterion
object
Sort field
Optional
Required
order
object
Sort direction
Optional
ASC

AssetCustomMetadata

from vi.api.resources.datasets.assets.types import AssetCustomMetadata

# Type alias
AssetCustomMetadata = dict[str, str | int | float | bool]

Custom metadata dictionary with string keys and primitive values.


Enums

SortCriterion

from vi.api.resources.datasets.assets.types import SortCriterion

Values

Name
Type
Description
Required
Default
DEFAULT
Default sorting
Optional
ASSET_ID
Sort by asset ID
Optional
FILENAME
Sort by filename
Optional
LAST_MODIFIED_CONTENTS
Sort by last modified
Optional
METADATA_FILE_SIZE
Sort by file size
Optional

SortOrder

from vi.api.resources.datasets.assets.types import SortOrder

Values

Name
Type
Description
Required
Default
ASC
Ascending order
Optional
DESC
Descending order
Optional

FailureMode

from vi.api.resources.datasets.assets.responses import FailureMode

Values

Name
Type
Description
Required
Default
FAIL_AFTER_ONE
Stop on first error
Optional
FAIL_AFTER_ALL
Continue and report all errors
Optional

ResourceRetentionMode

from vi.api.resources.datasets.assets.responses import ResourceRetentionMode

Values

Name
Type
Description
Required
Default
REMOVE_LINKED_RESOURCE
Remove linked annotations when asset is overwritten
Optional
KEEP_LINKED_RESOURCES
Keep linked annotations when asset is overwritten
Optional

AssetIngestionError

from vi.api.resources.datasets.assets.responses import AssetIngestionError

Values

Name
Type
Description
Required
Default
EALREADY
Asset already exists
Optional
EBADMIME
Invalid MIME type
Optional
EBADSIZE
Invalid file size
Optional
ECORRUPT
Corrupted file
Optional
ENOQUOTA
Quota exceeded
Optional
ETIMEOUT
Upload timeout
Optional
EUNKNOWN
Unknown error
Optional

Related resources

Annotations API

Upload, list, and download annotations for assets you've uploaded.

Datasets API

Create and manage the datasets that contain your assets.

Upload Assets

UI guide for uploading images via drag-and-drop.

Manage Assets

UI guide for organizing and deleting assets.