Access assets through client.assets.
📋 Get started with Vi SDK →
List assets in a dataset.
Python
# Basic listing
assets = client.assets.list(dataset_id="dataset_abc123")
for asset in assets.items:
print(f"{asset.filename}: {asset.metadata.width}x{asset.metadata.height}")
Python
# With pagination and sorting
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}")
Python
# Get assets with download URLs
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}")
Python
# Filter by metadata
assets = client.assets.list(
dataset_id="dataset_abc123",
metadata_query='custom_field == "value"'
)
Parameters:
Parameter Type Description Default dataset_idstrDataset identifier Required paginationPaginationParamsPagination settings NonecontentsboolInclude download URLs Falsesort_byAssetSortCriterionSorting criteria Nonefilter_criteriastrFilter query Nonemetadata_querystrMetadata query None
Returns: PaginatedResponse[Asset]
Get a specific asset.
Python
# Basic usage
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")
Python
# Get with download URL
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}")
Python
# Display detailed information
asset = client.assets.get(
dataset_id="dataset_abc123",
asset_id="asset_xyz789"
)
asset.info() # Prints formatted asset summary
Parameters:
Parameter Type Description Default dataset_idstrDataset identifier Required asset_idstrAsset identifier Required contentsboolInclude download URL False
Returns: Asset
Upload assets to a dataset.
Python
# Upload single file
result = client.assets.upload(
dataset_id="dataset_abc123",
paths="image.jpg",
wait_until_done=True
)
print(f"Uploaded: {result.total_succeeded}")
Python
# Upload entire folder
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())
Python
# Upload multiple specific files
result = client.assets.upload(
dataset_id="dataset_abc123",
paths=["image1.jpg", "image2.png", "image3.webp"],
wait_until_done=True
)
Python
# Upload with error handling
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}")
Python
# Async upload (don't wait)
result = client.assets.upload(
dataset_id="dataset_abc123",
paths="./large_folder/",
wait_until_done=False
)
# Get session IDs for later status check
print(f"Session IDs: {result.session_ids}")
Parameters:
Parameter Type Description Default dataset_idstrDataset identifier Required pathsstr | list[str]File/folder paths Required wait_until_doneboolWait for completion Truefailure_modeFailureModeFailure handling "FailAfterOne"on_asset_overwrittenResourceRetentionModeOverwrite behavior "RemoveLinkedResource"
Returns: AssetUploadResult
Download assets from a dataset.
Python
# Basic download
downloaded = client.assets.download(
dataset_id="dataset_abc123",
save_dir="./assets"
)
Python
# Download with progress and overwrite
downloaded = client.assets.download(
dataset_id="dataset_abc123",
save_dir="./assets",
overwrite=True,
show_progress=True
)
print(f"Downloaded to: {downloaded}")
Parameters:
Parameter Type Description Default dataset_idstrDataset identifier Required save_dirstr | PathSave directory Required overwriteboolOverwrite existing Falseshow_progressboolShow progress bars True
Returns: AssetDownloadResult
Delete an asset.
Python
# Delete single asset
deleted = client.assets.delete(
dataset_id="dataset_abc123",
asset_id="asset_xyz789"
)
Python
# Delete multiple assets
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:
Parameter Type Description dataset_idstrDataset identifier asset_idstrAsset identifier
Returns: DeletedAsset
Wait for an upload session to complete.
Python
# Basic usage
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}")
Python
# After async upload
result = client.assets.upload(
dataset_id="dataset_abc123",
paths="./images/",
wait_until_done=False
)
# Do other work...
# Then wait for completion
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:
Parameter Type Description dataset_idstrDataset identifier asset_ingestion_session_idstrSession identifier
Returns: AssetIngestionSession
Main asset response object.
Python
from vi.api.resources.datasets.assets.responses import Asset
Property Type Description asset_idstrUnique identifier dataset_idstrParent dataset ID organization_idstrOrganization ID filenamestrOriginal filename kindstrResource kind ownerstrOwner identifier metadataAssetMetadataAsset metadata self_linkstrAPI link etagstrEntity tag contentsAssetContents | NoneDownload URLs (if requested)
Methods:
Method Returns Description info()NoneDisplay formatted asset information
Python
from vi.api.resources.datasets.assets.responses import AssetMetadata
Property Type Description widthintImage width in pixels heightintImage height in pixels file_sizeintFile size in bytes mime_typestrMIME type upload_statusstrUpload status statusstrProcessing status framesintNumber of frames visibilitystrVisibility setting generationsAssetGenerationsAsset URLs annotationsAssetAnnotationsAnnotation info dimensionsAssetDimensionsDimension details pixel_ratioAssetPixelRatioPixel ratio hashAssetHashFile hash inserted_bystrUploader ID cohortslist[str]Cohort IDs user_defineddict[str, Any]User metadata custom_metadataAssetCustomMetadataCustom metadata commentsintComment count time_createdintCreation timestamp last_updatedintUpdate timestamp
Python
from vi.api.resources.datasets.assets.responses import AssetGenerations
Property Type Description assetstrFull-size asset URL thumbnailstrThumbnail URL
Python
from vi.api.resources.datasets.assets.responses import AssetAnnotations
Property Type Description with_tagdict[str, int]Tag counts totalintTotal annotations
Python
from vi.api.resources.datasets.assets.responses import AssetDimensions
Property Type Description heightintHeight in pixels widthintWidth in pixels depthint | NoneDepth (for 3D)
Python
from vi.api.resources.datasets.assets.responses import AssetPixelRatio
Property Type Description heightintHeight ratio widthintWidth ratio depthint | NoneDepth ratio
Python
from vi.api.resources.datasets.assets.responses import AssetHash
Property Type Description algorithmstrHash algorithm (e.g., 'sha256') contentsstrHash value
Python
from vi.api.resources.datasets.assets.responses import AssetContents
Property Type Description assetContents | NoneFull asset URL info thumbnailContents | NoneThumbnail URL info
Python
from vi.api.resources.datasets.assets.responses import Contents
Property Type Description urlstrPre-signed URL expiryintExpiration timestamp headersdict[str, str] | NoneRequired headers methodstr | NoneHTTP method
Aggregates results from batched uploads.
Property Type Description total_filesintTotal files processed total_succeededintSuccessfully uploaded total_failedintFailed uploads success_ratefloatSuccess percentage sessionslist[AssetIngestionSession]Batch sessions session_idslist[str]Session IDs failed_fileslist[str]Failed file paths
Methods:
Method Returns Description summary()strGet summary string
Python
from vi.api.resources.datasets.assets.responses import AssetIngestionSession
Property Type Description organization_idstrOrganization ID dataset_idstrDataset ID asset_ingestion_session_idstrSession identifier asset_source_classstrSource classification asset_source_providerstrSource provider asset_source_idstrSource identifier self_linkstrAPI link etagstrEntity tag metadataResourceMetadataMetadata specAssetIngestionSessionSpecSession spec statusAssetIngestionSessionStatusSession status
Python
from vi.api.resources.datasets.assets.responses import AssetIngestionSessionSpec
Python
from vi.api.resources.datasets.assets.responses import AssetIngestionSessionStatus
Python
from vi.api.resources.datasets.assets.responses import AssetIngestionProgressCount
Property Type Description totalintTotal assets succeededintSucceeded erroredintErrored
Union type for ingestion events.
Python
AssetIngestionEvent = AssetIngestionEventError | AssetIngestionEventProgress
Python
from vi.api.resources.datasets.assets.responses import UploadedAssetMetadata
Property Type Description kindstrResource kind filenamestrFile name mimestrMIME type sizeintSize in bytes crc32cint | NoneCRC32C checksum custom_metadataAssetCustomMetadata | NoneCustom metadata
Python
from vi.api.resources.datasets.assets.responses import AssetForUpload
Python
from vi.api.resources.datasets.assets.types import AssetSortCriterion
Python
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.
Python
from vi.api.resources.datasets.assets.types import SortCriterion
Value Description DEFAULTDefault sorting ASSET_IDSort by asset ID FILENAMESort by filename LAST_MODIFIED_CONTENTSSort by last modified METADATA_FILE_SIZESort by file size
Python
from vi.api.resources.datasets.assets.types import SortOrder
Value Description ASCAscending order DESCDescending order
Python
from vi.api.resources.datasets.assets.responses import FailureMode
Value Description FAIL_AFTER_ONEStop on first error FAIL_AFTER_ALLContinue and report all errors
Python
from vi.api.resources.datasets.assets.responses import ResourceRetentionMode
Value Description REMOVE_LINKED_RESOURCERemove linked annotations KEEP_LINKED_RESOURCESKeep linked annotations
Python
from vi.api.resources.datasets.assets.responses import AssetIngestionError
Value Description EALREADYAsset already exists EBADMIMEInvalid MIME type EBADSIZEInvalid file size ECORRUPTCorrupted file ENOQUOTAQuota exceeded ETIMEOUTUpload timeout EUNKNOWNUnknown error
Format Extensions JPEG .jpg, .jpeg, .jfifPNG .pngTIFF .tiff, .tifBMP .bmpWebP .webpHEIF .heif, .heicAVIF .avifJPEG 2000 .jp2, .j2kGIF .gif
We're here to support your VLMOps journey. Reach out through any of these channels: