Direct uploads

The Assets class provides methods to upload your media files to the platform. This method creates an asset that you can use in different workflows.

Workflow

1

Upload your file using the assets.create method. You receive the asset ID in the response.

2

For URL uploads larger than 200 MB, check the asset status using the assets.retrieve method until status is ready before proceeding.

3

What you do next depends on your use case:

  • For creating embeddings (videos, audio, images): Use the asset ID with the Embed API v2.
  • For entity search (images): Use the asset ID to create entities.
  • For search and analysis (videos): Index your asset using the asset ID.

Methods

Create an asset

Description: This method creates an asset by uploading a file to the platform. Assets are media files that you can use in downstream workflows, including indexing, analyzing video content, and creating entities.

Supported content: Video, audio, and images.

Upload methods:

  • Local file: Set the method parameter to direct and use the file parameter to specify the file.
  • Publicly accessible URL: Set the method parameter to url and use the url parameter to specify the URL of your file.

Upload limits:

  • Video and audio, local files: Up to 200 MB
  • Video and audio, public URLs: Up to 4 GB
  • Images: Up to 5 MB

Additional requirements depend on your workflow:

Note

This method is rate-limited. For details, see the Rate limits page.

Function signature and example:

1create(
2 request: TwelvelabsApi.AssetsCreateRequest,
3 requestOptions?: Assets.RequestOptions
4): core.HttpResponsePromise<TwelvelabsApi.Asset>

Parameters

NameTypeRequiredDescription
requestTwelvelabsApi.AssetsCreateRequestYesParameters for creating an asset.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.AssetsCreateRequest interface has the following properties:

NameTypeRequiredDescription
methodTwelvelabsApi.AssetsCreateRequestMethodYesSpecifies the upload method for the asset. Use direct to upload a local file or url for a publicly accessible URL.
fileFile | fs.ReadStream | Blob | undefinedNoThe local file to upload. This parameter is required when method is set to direct.

Local video and audio files support up to 200 MB. Image files support up to 5 MB.
urlstringNoThe publicly accessible URL of a media file to upload. This parameter is required when method is set to url.

Public video and audio URLs support up to 4 GB. Image URLs support up to 5 MB.
filenamestringNoThe optional filename of the asset. If not provided, the platform determines the filename from the file or URL.
enableHlsbooleanNoWhen set to true, the platform generates an HLS playlist and segments for streaming. Applicable to video and audio assets only. Default: false.
enableThumbnailbooleanNoWhen set to true, the platform generates thumbnail images from the uploaded content. Default: false.

Return value

Returns an HttpResponsePromise that resolves to a TwelvelabsApi.Asset object representing the created asset.

The TwelvelabsApi.Asset interface contains the following properties:

NameTypeDescription
idstringThe unique identifier of the asset.
methodTwelvelabsApi.AssetMethodIndicates how you uploaded the asset. Values: direct (uploaded from your local file system), url (uploaded from a publicly accessible URL), multipart (uploaded using the multipart upload flow).
statusTwelvelabsApi.AssetStatusIndicates the current status of the asset. Values: failed (the platform failed to process the upload), processing (the platform is processing the uploaded file), ready (the asset is ready to use).
filenamestringThe name of the file used to create the asset.
fileTypestringThe MIME type of the asset file.
sizenumberThe file size of the asset in bytes. This field is absent while the asset is still being processed.
durationnumberThe duration of the asset in seconds. Only present for video and audio assets. This field is absent for image assets or while the asset is still being processed.
createdAtDateThe date and time, in RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the asset was created.

API Reference

Create an asset

List assets

Description: This method returns a list of assets in your account.

The platform returns your assets sorted by creation date, with the newest at the top of the list.

Function signature and example:

1list(
2 request?: TwelvelabsApi.AssetsListRequest,
3 requestOptions?: Assets.RequestOptions
4): Promise<core.Page<TwelvelabsApi.AssetDetail>>

Parameters

NameTypeRequiredDescription
requestTwelvelabsApi.AssetsListRequestYesParameters for creating the index.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.AssetsListRequest interface has the following properties:

NameTypeRequiredDescription
pagenumberNoA number that identifies the page to retrieve. Default: 1.
pageLimitnumberNoThe number of items to return on each page. Default: 10. Max: 50.
assetIdsstring | string[]NoFilters the response to include only assets with the specified IDs. Provide one or more asset IDs. When you specify multiple IDs, the platform returns all matching assets.
assetTypesTwelvelabsApi.AssetsListRequestAssetTypesItem | TwelvelabsApi.AssetsListRequestAssetTypesItem[]NoFilters the response to include only assets of the specified types. Provide one or more asset types. When you specify multiple types, the platform returns all matching assets. Values: image, video, audio.
filenamestringNoFilters the response to include only assets whose filename contains the specified string. The match is case-insensitive and supports partial matching.

Return value

Returns a Promise that resolves to a Page<TwelvelabsApi.AssetDetail> object that allows you to iterate through the paginated asset results. The AssetDetail interface extends Asset with additional fields for HLS streaming and thumbnail details. For details about the TwelvelabsApi.AssetDetail interface, see the Retrieve an asset section below.

The Page<T> interface contains the following properties and methods:

NameTypeDescription
dataT[]An array containing the current page of items.
hasNextPage()booleanReturns whether there is a next page to load.
getNextPage()Promise<Page<T>>Retrieves the next page and returns the updated Page object.
Symbol.asyncIteratorAsyncIterator<T>Allows iteration through all items across all pages using for await loops.

API Reference

List assets

Retrieve an asset

Description: This method retrieves details about the specified asset.

Function signature and example:

1retrieve(
2 assetId: string,
3 requestOptions?: Assets.RequestOptions
4): core.HttpResponsePromise<TwelvelabsApi.AssetDetail>

Parameters

NameTypeRequiredDescription
assetIdstringYesThe unique identifier of the asset to retrieve.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

Return value

Returns an HttpResponsePromise that resolves to a TwelvelabsApi.AssetDetail object containing details about the specified asset.

The TwelvelabsApi.AssetDetail interface extends TwelvelabsApi.Asset (documented in the Create an asset section above) with the following additional properties:

NameTypeDescription
hlsTwelvelabsApi.AssetHlsHLS streaming details for the asset. Present only when HLS generation has been requested.
thumbnailTwelvelabsApi.AssetThumbnailThumbnail details for the asset. Present only when thumbnail generation has been requested.

The TwelvelabsApi.AssetHls interface contains the following properties:

NameTypeDescription
manifestUrlstringThe URL of the HLS manifest file for streaming. Only present when the status is ready.
statusTwelvelabsApi.AssetHlsStatusThe status of the HLS stream. Values: pending (the platform has not yet started HLS generation), processing (the platform is generating HLS segments), ready (the HLS stream is ready for playback), error (HLS generation failed).

The TwelvelabsApi.AssetThumbnail interface contains the following properties:

NameTypeDescription
representativeUrlstringThe URL of the representative thumbnail image. Only present when the status is ready.
statusTwelvelabsApi.AssetThumbnailStatusThe status of the thumbnail. Values: pending (the platform has not yet started thumbnail generation), processing (the platform is generating the thumbnail), ready (the thumbnail is ready), error (thumbnail generation failed).

API Reference

Retrieve an asset

Delete an asset

Description: This method deletes the specified asset. This action cannot be undone. By default, the platform checks whether any indexed assets reference the asset. If references exist, the request fails with a 409 Conflict error. Set the force parameter to true to delete the asset regardless.

Function signature and example:

1delete(
2 assetId: string,
3 request?: TwelvelabsApi.AssetsDeleteRequest,
4 requestOptions?: Assets.RequestOptions
5): core.HttpResponsePromise<void>

Parameters

NameTypeRequiredDescription
assetIdstringYesThe unique identifier of the asset to delete.
requestTwelvelabsApi.AssetsDeleteRequestNoParameters for deleting an asset.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.AssetsDeleteRequest interface has the following properties:

NameTypeRequiredDescription
forcebooleanNoWhen set to true, the platform deletes the asset even if indexed assets reference it. When set to false or omitted, the request fails with 409 Conflict if references exist. Default: false.

Return value

Returns an HttpResponsePromise that resolves to void.

API Reference

Delete asset