Create async embeddings
The Embed.V2.Tasks interface provides methods to create embeddings asynchronously for audio and video content. Use this class for processing files longer than 10 minutes.
Note
This interface only supports Marengo version 3.0 or newer.
When to use this interface:
- Process audio or video files longer than 10 minutes
- Process files up to 4 hours in duration
Input requirements
Video:
- Minimum duration: 4 seconds
- Maximum duration: 4 hours
- Maximum file size: 4 GB
- Formats: FFmpeg supported formats
- Resolution: 360x360 to 5184x2160 pixels
- Aspect ratio: Between 1:1 and 1:2.4, or between 2.4:1 and 1:1
Audio:
- Minimum duration: 4 seconds
- Maximum duration: 4 hours
- Maximum file size: 2 GB
- Formats: WAV (uncompressed), MP3 (lossy), FLAC (lossless)
Creating embeddings asynchronously requires three steps:
- Create a task using the
createmethod. The platform returns a task ID. - Poll for the status of the task using the
retrievemethod. Wait until the status isready. - Retrieve the embeddings from the response when the status is
readyusing theretrievemethod.
Methods
List embedding tasks
Description: This method returns a list of the async embedding tasks in your account. The platform returns your async embedding tasks sorted by creation date, with the newest at the top of the list.
Function signature and example:
Parameters:
The TwelvelabsApi.embed.v2.TasksListRequest interface has the following properties:
Return value: Returns a Promise that resolves to a Page<TwelvelabsApi.MediaEmbeddingTask> object that allows you to iterate through the paginated task results.
The Page<T> class contains the following properties and methods:
The TwelvelabsApi.MediaEmbeddingTask interface contains the following properties:
API Reference: List async embedding tasks
Create an async embedding task
Description: This method creates embeddings for audio and video content asynchronously.
Note
This method is rate-limited. For details, see the Rate limits page.
Function signature and example:
Parameters:
The TwelvelabsApi.embed.v2.CreateAsyncEmbeddingRequest interface has the following properties:
AudioInputRequest
The TwelvelabsApi.AudioInputRequest interface specifies configuration for processing audio content. Required when inputType is audio.
VideoInputRequest
The TwelvelabsApi.VideoInputRequest interface specifies configuration for processing video content. Required when inputType is video.
MediaSource
The TwelvelabsApi.MediaSource interface specifies the source of the media file. Provide exactly one of the following:
AudioSegmentation
The TwelvelabsApi.AudioSegmentation interface specifies how the platform divides the audio into segments using fixed-length intervals.
AudioSegmentationFixed
The TwelvelabsApi.AudioSegmentationFixed interface configures fixed-length segmentation for audio.
VideoSegmentation
The TwelvelabsApi.VideoSegmentation type specifies how the platform divides the video into segments. Use one of the following:
Fixed segmentation: Divides the video into equal-length segments:
Dynamic segmentation: Divides the video into adaptive segments based on scene changes:
VideoSegmentationFixedFixed
The TwelvelabsApi.VideoSegmentationFixedFixed interface configures fixed-length segmentation for video.
VideoSegmentationDynamicDynamic
The TwelvelabsApi.VideoSegmentationDynamicDynamic interface configures dynamic segmentation for video based on scene changes.
Return value: Returns an HttpResponsePromise that resolves to a TwelvelabsApi.embed.v2.TasksCreateResponse object containing the task details.
The TwelvelabsApi.embed.v2.TasksCreateResponse.TasksCreateResponse interface contains the following properties:
API Reference: Create an async embedding task
Retrieve task status and results
Description: This method retrieves the status and the results of an async embedding task.
Task statuses:
processing: The platform is creating the embeddings.ready: Processing is complete. Embeddings are available in the response.failed: The task failed. Embeddings were not created.
Invoke this method repeatedly until the status field is ready. When status is ready, use the embeddings from the response.
Function signature and example:
Parameters:
Return value: Returns an HttpResponsePromise that resolves to a TwelvelabsApi.EmbeddingTaskResponse object containing the task status and results.
The TwelvelabsApi.EmbeddingTaskResponse interface contains the following properties:
For details about the EmbeddingData class, see the Create an async embedding task section.
API Reference: Retrieve embedding task
API Reference: Retrieve task status and results